py2docfx 0.1.11.dev1824276__py3-none-any.whl → 0.1.11.dev1830301__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. py2docfx/convert_prepare/environment.py +1 -1
  2. py2docfx/convert_prepare/package_info.py +1 -1
  3. py2docfx/convert_prepare/pip_utils.py +1 -1
  4. py2docfx/convert_prepare/tests/test_package_info.py +7 -22
  5. py2docfx/convert_prepare/tests/test_params.py +5 -0
  6. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/_collections.py +0 -145
  7. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +1 -2
  8. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/ccompiler.py +7 -11
  9. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/bdist.py +4 -3
  10. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/build_ext.py +1 -4
  11. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/check.py +3 -4
  12. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/install_data.py +39 -29
  13. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/install_lib.py +1 -3
  14. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/command/sdist.py +4 -4
  15. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/compat/py38.py +1 -0
  16. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +21 -42
  17. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/dist.py +3 -12
  18. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/extension.py +9 -4
  19. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +1 -3
  20. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/msvccompiler.py +1 -3
  21. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/spawn.py +0 -1
  22. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/sysconfig.py +44 -25
  23. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_archive_util.py +1 -1
  24. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_build.py +1 -2
  25. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_build_ext.py +1 -1
  26. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_cygwinccompiler.py +0 -42
  27. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_dist.py +1 -1
  28. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_extension.py +4 -1
  29. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_install_data.py +17 -9
  30. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_mingwccompiler.py +5 -4
  31. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_spawn.py +1 -1
  32. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_sysconfig.py +6 -3
  33. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_unixccompiler.py +35 -1
  34. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/tests/test_util.py +4 -24
  35. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/unixccompiler.py +19 -20
  36. py2docfx/venv/0/Lib/site-packages/setuptools/_distutils/util.py +20 -26
  37. py2docfx/venv/0/Lib/site-packages/wheel/__init__.py +3 -0
  38. py2docfx/venv/0/Lib/site-packages/wheel/__main__.py +23 -0
  39. py2docfx/venv/0/Lib/site-packages/wheel/_bdist_wheel.py +604 -0
  40. py2docfx/venv/0/Lib/site-packages/wheel/_setuptools_logging.py +26 -0
  41. py2docfx/venv/0/Lib/site-packages/wheel/bdist_wheel.py +11 -0
  42. py2docfx/venv/0/Lib/site-packages/wheel/cli/__init__.py +155 -0
  43. py2docfx/venv/0/Lib/site-packages/wheel/cli/convert.py +273 -0
  44. py2docfx/venv/0/Lib/site-packages/wheel/cli/pack.py +85 -0
  45. py2docfx/venv/0/Lib/site-packages/wheel/cli/tags.py +139 -0
  46. py2docfx/venv/0/Lib/site-packages/wheel/cli/unpack.py +30 -0
  47. py2docfx/venv/0/Lib/site-packages/wheel/macosx_libfile.py +482 -0
  48. py2docfx/venv/0/Lib/site-packages/wheel/metadata.py +183 -0
  49. py2docfx/venv/0/Lib/site-packages/wheel/util.py +26 -0
  50. py2docfx/venv/0/Lib/site-packages/wheel/vendored/__init__.py +0 -0
  51. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/__init__.py +0 -0
  52. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_elffile.py +108 -0
  53. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_manylinux.py +260 -0
  54. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_musllinux.py +83 -0
  55. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_parser.py +356 -0
  56. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_structures.py +61 -0
  57. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/_tokenizer.py +192 -0
  58. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/markers.py +253 -0
  59. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/requirements.py +90 -0
  60. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/specifiers.py +1011 -0
  61. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/tags.py +571 -0
  62. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/utils.py +172 -0
  63. py2docfx/venv/0/Lib/site-packages/wheel/vendored/packaging/version.py +561 -0
  64. py2docfx/venv/0/Lib/site-packages/wheel/wheelfile.py +227 -0
  65. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/_collections.py +0 -145
  66. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +1 -2
  67. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/ccompiler.py +7 -11
  68. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/bdist.py +4 -3
  69. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/build_ext.py +1 -4
  70. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/check.py +3 -4
  71. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/install_data.py +39 -29
  72. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/install_lib.py +1 -3
  73. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/command/sdist.py +4 -4
  74. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/compat/py38.py +1 -0
  75. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +21 -42
  76. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/dist.py +3 -12
  77. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/extension.py +9 -4
  78. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +1 -3
  79. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/msvccompiler.py +1 -3
  80. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/spawn.py +0 -1
  81. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/sysconfig.py +44 -25
  82. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_archive_util.py +1 -1
  83. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_build.py +1 -2
  84. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_build_ext.py +1 -1
  85. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_cygwinccompiler.py +0 -42
  86. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_dist.py +1 -1
  87. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_extension.py +4 -1
  88. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_install_data.py +17 -9
  89. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_mingwccompiler.py +5 -4
  90. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_spawn.py +1 -1
  91. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_sysconfig.py +6 -3
  92. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_unixccompiler.py +35 -1
  93. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/tests/test_util.py +4 -24
  94. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/unixccompiler.py +19 -20
  95. py2docfx/venv/template/Lib/site-packages/setuptools/_distutils/util.py +20 -26
  96. py2docfx/venv/template/Lib/site-packages/wheel/__init__.py +3 -0
  97. py2docfx/venv/template/Lib/site-packages/wheel/__main__.py +23 -0
  98. py2docfx/venv/template/Lib/site-packages/wheel/_bdist_wheel.py +604 -0
  99. py2docfx/venv/template/Lib/site-packages/wheel/_setuptools_logging.py +26 -0
  100. py2docfx/venv/template/Lib/site-packages/wheel/bdist_wheel.py +11 -0
  101. py2docfx/venv/template/Lib/site-packages/wheel/cli/__init__.py +155 -0
  102. py2docfx/venv/template/Lib/site-packages/wheel/cli/convert.py +273 -0
  103. py2docfx/venv/template/Lib/site-packages/wheel/cli/pack.py +85 -0
  104. py2docfx/venv/template/Lib/site-packages/wheel/cli/tags.py +139 -0
  105. py2docfx/venv/template/Lib/site-packages/wheel/cli/unpack.py +30 -0
  106. py2docfx/venv/template/Lib/site-packages/wheel/macosx_libfile.py +482 -0
  107. py2docfx/venv/template/Lib/site-packages/wheel/metadata.py +183 -0
  108. py2docfx/venv/template/Lib/site-packages/wheel/util.py +26 -0
  109. py2docfx/venv/template/Lib/site-packages/wheel/vendored/__init__.py +0 -0
  110. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/__init__.py +0 -0
  111. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_elffile.py +108 -0
  112. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_manylinux.py +260 -0
  113. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_musllinux.py +83 -0
  114. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_parser.py +356 -0
  115. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_structures.py +61 -0
  116. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/_tokenizer.py +192 -0
  117. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/markers.py +253 -0
  118. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/requirements.py +90 -0
  119. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/specifiers.py +1011 -0
  120. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/tags.py +571 -0
  121. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/utils.py +172 -0
  122. py2docfx/venv/template/Lib/site-packages/wheel/vendored/packaging/version.py +561 -0
  123. py2docfx/venv/template/Lib/site-packages/wheel/wheelfile.py +227 -0
  124. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/METADATA +1 -1
  125. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/RECORD +127 -71
  126. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/WHEEL +0 -0
  127. {py2docfx-0.1.11.dev1824276.dist-info → py2docfx-0.1.11.dev1830301.dist-info}/top_level.txt +0 -0
@@ -9,13 +9,11 @@ cygwin in no-cygwin mode).
9
9
  import copy
10
10
  import os
11
11
  import pathlib
12
- import re
13
12
  import shlex
14
13
  import sys
15
14
  import warnings
16
15
  from subprocess import check_output
17
16
 
18
- from ._collections import RangeMap
19
17
  from .errors import (
20
18
  CCompilerError,
21
19
  CompileError,
@@ -26,42 +24,10 @@ from .file_util import write_file
26
24
  from .unixccompiler import UnixCCompiler
27
25
  from .version import LooseVersion, suppress_known_deprecation
28
26
 
29
- _msvcr_lookup = RangeMap.left(
30
- {
31
- # MSVC 7.0
32
- 1300: ['msvcr70'],
33
- # MSVC 7.1
34
- 1310: ['msvcr71'],
35
- # VS2005 / MSVC 8.0
36
- 1400: ['msvcr80'],
37
- # VS2008 / MSVC 9.0
38
- 1500: ['msvcr90'],
39
- # VS2010 / MSVC 10.0
40
- 1600: ['msvcr100'],
41
- # VS2012 / MSVC 11.0
42
- 1700: ['msvcr110'],
43
- # VS2013 / MSVC 12.0
44
- 1800: ['msvcr120'],
45
- # VS2015 / MSVC 14.0
46
- 1900: ['vcruntime140'],
47
- 2000: RangeMap.undefined_value,
48
- },
49
- )
50
-
51
27
 
52
28
  def get_msvcr():
53
- """Include the appropriate MSVC runtime library if Python was built
54
- with MSVC 7.0 or later.
55
- """
56
- match = re.search(r'MSC v\.(\d{4})', sys.version)
57
- try:
58
- msc_ver = int(match.group(1))
59
- except AttributeError:
60
- return []
61
- try:
62
- return _msvcr_lookup[msc_ver]
63
- except KeyError:
64
- raise ValueError(f"Unknown MS Compiler version {msc_ver} ")
29
+ """No longer needed, but kept for backward compatibility."""
30
+ return []
65
31
 
66
32
 
67
33
  _runtime_library_dirs_msg = (
@@ -99,18 +65,20 @@ class CygwinCCompiler(UnixCCompiler):
99
65
  self.cxx = os.environ.get('CXX', 'g++')
100
66
 
101
67
  self.linker_dll = self.cc
68
+ self.linker_dll_cxx = self.cxx
102
69
  shared_option = "-shared"
103
70
 
104
71
  self.set_executables(
105
72
  compiler=f'{self.cc} -mcygwin -O -Wall',
106
73
  compiler_so=f'{self.cc} -mcygwin -mdll -O -Wall',
107
74
  compiler_cxx=f'{self.cxx} -mcygwin -O -Wall',
75
+ compiler_so_cxx=f'{self.cxx} -mcygwin -mdll -O -Wall',
108
76
  linker_exe=f'{self.cc} -mcygwin',
109
- linker_so=(f'{self.linker_dll} -mcygwin {shared_option}'),
77
+ linker_so=f'{self.linker_dll} -mcygwin {shared_option}',
78
+ linker_exe_cxx=f'{self.cxx} -mcygwin',
79
+ linker_so_cxx=f'{self.linker_dll_cxx} -mcygwin {shared_option}',
110
80
  )
111
81
 
112
- # Include the appropriate MSVC runtime library if Python was built
113
- # with MSVC 7.0 or later.
114
82
  self.dll_libraries = get_msvcr()
115
83
 
116
84
  @property
@@ -138,9 +106,17 @@ class CygwinCCompiler(UnixCCompiler):
138
106
  raise CompileError(msg)
139
107
  else: # for other files use the C-compiler
140
108
  try:
141
- self.spawn(
142
- self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs
143
- )
109
+ if self.detect_language(src) == 'c++':
110
+ self.spawn(
111
+ self.compiler_so_cxx
112
+ + cc_args
113
+ + [src, '-o', obj]
114
+ + extra_postargs
115
+ )
116
+ else:
117
+ self.spawn(
118
+ self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs
119
+ )
144
120
  except DistutilsExecError as msg:
145
121
  raise CompileError(msg)
146
122
 
@@ -276,9 +252,12 @@ class Mingw32CCompiler(CygwinCCompiler):
276
252
  self.set_executables(
277
253
  compiler=f'{self.cc} -O -Wall',
278
254
  compiler_so=f'{self.cc} -shared -O -Wall',
255
+ compiler_so_cxx=f'{self.cxx} -shared -O -Wall',
279
256
  compiler_cxx=f'{self.cxx} -O -Wall',
280
257
  linker_exe=f'{self.cc}',
281
258
  linker_so=f'{self.linker_dll} {shared_option}',
259
+ linker_exe_cxx=f'{self.cxx}',
260
+ linker_so_cxx=f'{self.linker_dll_cxx} {shared_option}',
282
261
  )
283
262
 
284
263
  def runtime_library_dir_option(self, dir):
@@ -745,10 +745,7 @@ Common commands: (see '--help-commands' for more)
745
745
  for cmd in std_commands:
746
746
  is_std.add(cmd)
747
747
 
748
- extra_commands = []
749
- for cmd in self.cmdclass.keys():
750
- if cmd not in is_std:
751
- extra_commands.append(cmd)
748
+ extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
752
749
 
753
750
  max_length = 0
754
751
  for cmd in std_commands + extra_commands:
@@ -776,10 +773,7 @@ Common commands: (see '--help-commands' for more)
776
773
  for cmd in std_commands:
777
774
  is_std.add(cmd)
778
775
 
779
- extra_commands = []
780
- for cmd in self.cmdclass.keys():
781
- if cmd not in is_std:
782
- extra_commands.append(cmd)
776
+ extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
783
777
 
784
778
  rv = []
785
779
  for cmd in std_commands + extra_commands:
@@ -1301,7 +1295,4 @@ def fix_help_options(options):
1301
1295
  """Convert a 4-tuple 'help_options' list as found in various command
1302
1296
  classes to the 3-tuple form required by FancyGetopt.
1303
1297
  """
1304
- new_options = []
1305
- for help_tuple in options:
1306
- new_options.append(help_tuple[0:3])
1307
- return new_options
1298
+ return [opt[0:3] for opt in options]
@@ -26,7 +26,7 @@ class Extension:
26
26
  name : string
27
27
  the full name of the extension, including any packages -- ie.
28
28
  *not* a filename or pathname, but Python dotted name
29
- sources : [string]
29
+ sources : [string | os.PathLike]
30
30
  list of source filenames, relative to the distribution root
31
31
  (where the setup script lives), in Unix form (slash-separated)
32
32
  for portability. Source files may be C, C++, SWIG (.i),
@@ -106,11 +106,16 @@ class Extension:
106
106
  ):
107
107
  if not isinstance(name, str):
108
108
  raise AssertionError("'name' must be a string")
109
- if not (isinstance(sources, list) and all(isinstance(v, str) for v in sources)):
110
- raise AssertionError("'sources' must be a list of strings")
109
+ if not (
110
+ isinstance(sources, list)
111
+ and all(isinstance(v, (str, os.PathLike)) for v in sources)
112
+ ):
113
+ raise AssertionError(
114
+ "'sources' must be a list of strings or PathLike objects."
115
+ )
111
116
 
112
117
  self.name = name
113
- self.sources = sources
118
+ self.sources = list(map(os.fspath, sources))
114
119
  self.include_dirs = include_dirs or []
115
120
  self.define_macros = define_macros or []
116
121
  self.undef_macros = undef_macros or []
@@ -640,9 +640,7 @@ class MSVCCompiler(CCompiler):
640
640
  else:
641
641
  ldflags = self.ldflags_shared
642
642
 
643
- export_opts = []
644
- for sym in export_symbols or []:
645
- export_opts.append("/EXPORT:" + sym)
643
+ export_opts = [f"/EXPORT:{sym}" for sym in export_symbols or []]
646
644
 
647
645
  ld_args = (
648
646
  ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename]
@@ -534,9 +534,7 @@ class MSVCCompiler(CCompiler):
534
534
  else:
535
535
  ldflags = self.ldflags_shared
536
536
 
537
- export_opts = []
538
- for sym in export_symbols or []:
539
- export_opts.append("/EXPORT:" + sym)
537
+ export_opts = [f"/EXPORT:{sym}" for sym in export_symbols or []]
540
538
 
541
539
  ld_args = (
542
540
  ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename]
@@ -12,7 +12,6 @@ import shutil
12
12
  import subprocess
13
13
  import sys
14
14
  import warnings
15
-
16
15
  from typing import Mapping
17
16
 
18
17
  from ._log import log
@@ -287,7 +287,7 @@ def _customize_macos():
287
287
  )
288
288
 
289
289
 
290
- def customize_compiler(compiler): # noqa: C901
290
+ def customize_compiler(compiler):
291
291
  """Do any platform-specific customization of a CCompiler instance.
292
292
 
293
293
  Mainly needed on Unix, so we can plug in the information that
@@ -304,6 +304,7 @@ def customize_compiler(compiler): # noqa: C901
304
304
  cflags,
305
305
  ccshared,
306
306
  ldshared,
307
+ ldcxxshared,
307
308
  shlib_suffix,
308
309
  ar,
309
310
  ar_flags,
@@ -313,11 +314,14 @@ def customize_compiler(compiler): # noqa: C901
313
314
  'CFLAGS',
314
315
  'CCSHARED',
315
316
  'LDSHARED',
317
+ 'LDCXXSHARED',
316
318
  'SHLIB_SUFFIX',
317
319
  'AR',
318
320
  'ARFLAGS',
319
321
  )
320
322
 
323
+ cxxflags = cflags
324
+
321
325
  if 'CC' in os.environ:
322
326
  newcc = os.environ['CC']
323
327
  if 'LDSHARED' not in os.environ and ldshared.startswith(cc):
@@ -325,38 +329,42 @@ def customize_compiler(compiler): # noqa: C901
325
329
  # command for LDSHARED as well
326
330
  ldshared = newcc + ldshared[len(cc) :]
327
331
  cc = newcc
328
- if 'CXX' in os.environ:
329
- cxx = os.environ['CXX']
330
- if 'LDSHARED' in os.environ:
331
- ldshared = os.environ['LDSHARED']
332
- if 'CPP' in os.environ:
333
- cpp = os.environ['CPP']
334
- else:
335
- cpp = cc + " -E" # not always
336
- if 'LDFLAGS' in os.environ:
337
- ldshared = ldshared + ' ' + os.environ['LDFLAGS']
338
- if 'CFLAGS' in os.environ:
339
- cflags = cflags + ' ' + os.environ['CFLAGS']
340
- ldshared = ldshared + ' ' + os.environ['CFLAGS']
341
- if 'CPPFLAGS' in os.environ:
342
- cpp = cpp + ' ' + os.environ['CPPFLAGS']
343
- cflags = cflags + ' ' + os.environ['CPPFLAGS']
344
- ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
345
- if 'AR' in os.environ:
346
- ar = os.environ['AR']
347
- if 'ARFLAGS' in os.environ:
348
- archiver = ar + ' ' + os.environ['ARFLAGS']
349
- else:
350
- archiver = ar + ' ' + ar_flags
332
+ cxx = os.environ.get('CXX', cxx)
333
+ ldshared = os.environ.get('LDSHARED', ldshared)
334
+ ldcxxshared = os.environ.get('LDCXXSHARED', ldcxxshared)
335
+ cpp = os.environ.get(
336
+ 'CPP',
337
+ cc + " -E", # not always
338
+ )
351
339
 
340
+ ldshared = _add_flags(ldshared, 'LD')
341
+ ldcxxshared = _add_flags(ldcxxshared, 'LD')
342
+ cflags = _add_flags(cflags, 'C')
343
+ ldshared = _add_flags(ldshared, 'C')
344
+ cxxflags = os.environ.get('CXXFLAGS', cxxflags)
345
+ ldcxxshared = _add_flags(ldcxxshared, 'CXX')
346
+ cpp = _add_flags(cpp, 'CPP')
347
+ cflags = _add_flags(cflags, 'CPP')
348
+ cxxflags = _add_flags(cxxflags, 'CPP')
349
+ ldshared = _add_flags(ldshared, 'CPP')
350
+ ldcxxshared = _add_flags(ldcxxshared, 'CPP')
351
+
352
+ ar = os.environ.get('AR', ar)
353
+
354
+ archiver = ar + ' ' + os.environ.get('ARFLAGS', ar_flags)
352
355
  cc_cmd = cc + ' ' + cflags
356
+ cxx_cmd = cxx + ' ' + cxxflags
357
+
353
358
  compiler.set_executables(
354
359
  preprocessor=cpp,
355
360
  compiler=cc_cmd,
356
361
  compiler_so=cc_cmd + ' ' + ccshared,
357
- compiler_cxx=cxx,
362
+ compiler_cxx=cxx_cmd,
363
+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
358
364
  linker_so=ldshared,
365
+ linker_so_cxx=ldcxxshared,
359
366
  linker_exe=cc,
367
+ linker_exe_cxx=cxx,
360
368
  archiver=archiver,
361
369
  )
362
370
 
@@ -561,3 +569,14 @@ def get_config_var(name):
561
569
 
562
570
  warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning, 2)
563
571
  return get_config_vars().get(name)
572
+
573
+
574
+ @pass_none
575
+ def _add_flags(value: str, type: str) -> str:
576
+ """
577
+ Add any flags from the environment for the given type.
578
+
579
+ type is the prefix to FLAGS in the environment key (e.g. "C" for "CFLAGS").
580
+ """
581
+ flags = os.environ.get(f'{type}FLAGS')
582
+ return f'{value} {flags}' if flags else value
@@ -18,10 +18,10 @@ from distutils.archive_util import (
18
18
  from distutils.spawn import spawn
19
19
  from distutils.tests import support
20
20
  from os.path import splitdrive
21
- from test.support import patch
22
21
 
23
22
  import path
24
23
  import pytest
24
+ from test.support import patch
25
25
 
26
26
  from .compat.py38 import check_warnings
27
27
  from .unix_compat import UID_0_SUPPORT, grp, pwd, require_uid_0, require_unix_id
@@ -4,8 +4,7 @@ import os
4
4
  import sys
5
5
  from distutils.command.build import build
6
6
  from distutils.tests import support
7
- from sysconfig import get_config_var
8
- from sysconfig import get_platform
7
+ from sysconfig import get_config_var, get_platform
9
8
 
10
9
 
11
10
  class TestBuild(support.TempdirManager):
@@ -25,11 +25,11 @@ from distutils.tests.support import (
25
25
  fixup_build_ext,
26
26
  )
27
27
  from io import StringIO
28
- from test import support
29
28
 
30
29
  import jaraco.path
31
30
  import path
32
31
  import pytest
32
+ from test import support
33
33
 
34
34
  from .compat import py38 as import_helper
35
35
 
@@ -71,50 +71,8 @@ class TestCygwinCCompiler(support.TempdirManager):
71
71
  assert check_config_h()[0] == CONFIG_H_OK
72
72
 
73
73
  def test_get_msvcr(self):
74
- # []
75
- sys.version = (
76
- '2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
77
- '\n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]'
78
- )
79
74
  assert get_msvcr() == []
80
75
 
81
- # MSVC 7.0
82
- sys.version = (
83
- '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1300 32 bits (Intel)]'
84
- )
85
- assert get_msvcr() == ['msvcr70']
86
-
87
- # MSVC 7.1
88
- sys.version = (
89
- '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bits (Intel)]'
90
- )
91
- assert get_msvcr() == ['msvcr71']
92
-
93
- # VS2005 / MSVC 8.0
94
- sys.version = (
95
- '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1400 32 bits (Intel)]'
96
- )
97
- assert get_msvcr() == ['msvcr80']
98
-
99
- # VS2008 / MSVC 9.0
100
- sys.version = (
101
- '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1500 32 bits (Intel)]'
102
- )
103
- assert get_msvcr() == ['msvcr90']
104
-
105
- sys.version = (
106
- '3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 18:46:30) '
107
- '[MSC v.1929 32 bit (Intel)]'
108
- )
109
- assert get_msvcr() == ['vcruntime140']
110
-
111
- # unknown
112
- sys.version = (
113
- '2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.2000 32 bits (Intel)]'
114
- )
115
- with pytest.raises(ValueError):
116
- get_msvcr()
117
-
118
76
  @pytest.mark.skipif('sys.platform != "cygwin"')
119
77
  def test_dll_libraries_not_none(self):
120
78
  from distutils.cygwinccompiler import CygwinCCompiler
@@ -88,7 +88,7 @@ class TestDistributionBehavior(support.TempdirManager):
88
88
  'distutils' not in Distribution.parse_config_files.__module__,
89
89
  reason='Cannot test when virtualenv has monkey-patched Distribution',
90
90
  )
91
- def test_venv_install_options(self, tmp_path):
91
+ def test_venv_install_options(self, tmp_path, clear_argv):
92
92
  sys.argv.append("install")
93
93
  file = str(tmp_path / 'file')
94
94
 
@@ -1,6 +1,7 @@
1
1
  """Tests for distutils.extension."""
2
2
 
3
3
  import os
4
+ import pathlib
4
5
  import warnings
5
6
  from distutils.extension import Extension, read_setup_file
6
7
 
@@ -68,13 +69,15 @@ class TestExtension:
68
69
  assert ext.name == 'name'
69
70
 
70
71
  # the second argument, which is the list of files, must
71
- # be a list of strings
72
+ # be a list of strings or PathLike objects
72
73
  with pytest.raises(AssertionError):
73
74
  Extension('name', 'file')
74
75
  with pytest.raises(AssertionError):
75
76
  Extension('name', ['file', 1])
76
77
  ext = Extension('name', ['file1', 'file2'])
77
78
  assert ext.sources == ['file1', 'file2']
79
+ ext = Extension('name', [pathlib.Path('file1'), pathlib.Path('file2')])
80
+ assert ext.sources == ['file1', 'file2']
78
81
 
79
82
  # others arguments have defaults
80
83
  for attr in (
@@ -1,6 +1,7 @@
1
1
  """Tests for distutils.command.install_data."""
2
2
 
3
3
  import os
4
+ import pathlib
4
5
  from distutils.command.install_data import install_data
5
6
  from distutils.tests import support
6
7
 
@@ -18,22 +19,27 @@ class TestInstallData(
18
19
 
19
20
  # data_files can contain
20
21
  # - simple files
22
+ # - a Path object
21
23
  # - a tuple with a path, and a list of file
22
24
  one = os.path.join(pkg_dir, 'one')
23
25
  self.write_file(one, 'xxx')
24
26
  inst2 = os.path.join(pkg_dir, 'inst2')
25
27
  two = os.path.join(pkg_dir, 'two')
26
28
  self.write_file(two, 'xxx')
29
+ three = pathlib.Path(pkg_dir) / 'three'
30
+ self.write_file(three, 'xxx')
27
31
 
28
- cmd.data_files = [one, (inst2, [two])]
29
- assert cmd.get_inputs() == [one, (inst2, [two])]
32
+ cmd.data_files = [one, (inst2, [two]), three]
33
+ assert cmd.get_inputs() == [one, (inst2, [two]), three]
30
34
 
31
35
  # let's run the command
32
36
  cmd.ensure_finalized()
33
37
  cmd.run()
34
38
 
35
39
  # let's check the result
36
- assert len(cmd.get_outputs()) == 2
40
+ assert len(cmd.get_outputs()) == 3
41
+ rthree = os.path.split(one)[-1]
42
+ assert os.path.exists(os.path.join(inst, rthree))
37
43
  rtwo = os.path.split(two)[-1]
38
44
  assert os.path.exists(os.path.join(inst2, rtwo))
39
45
  rone = os.path.split(one)[-1]
@@ -46,21 +52,23 @@ class TestInstallData(
46
52
  cmd.run()
47
53
 
48
54
  # let's check the result
49
- assert len(cmd.get_outputs()) == 2
55
+ assert len(cmd.get_outputs()) == 3
56
+ assert os.path.exists(os.path.join(inst, rthree))
50
57
  assert os.path.exists(os.path.join(inst2, rtwo))
51
58
  assert os.path.exists(os.path.join(inst, rone))
52
59
  cmd.outfiles = []
53
60
 
54
61
  # now using root and empty dir
55
62
  cmd.root = os.path.join(pkg_dir, 'root')
56
- inst4 = os.path.join(pkg_dir, 'inst4')
57
- three = os.path.join(cmd.install_dir, 'three')
58
- self.write_file(three, 'xx')
59
- cmd.data_files = [one, (inst2, [two]), ('inst3', [three]), (inst4, [])]
63
+ inst5 = os.path.join(pkg_dir, 'inst5')
64
+ four = os.path.join(cmd.install_dir, 'four')
65
+ self.write_file(four, 'xx')
66
+ cmd.data_files = [one, (inst2, [two]), three, ('inst5', [four]), (inst5, [])]
60
67
  cmd.ensure_finalized()
61
68
  cmd.run()
62
69
 
63
70
  # let's check the result
64
- assert len(cmd.get_outputs()) == 4
71
+ assert len(cmd.get_outputs()) == 5
72
+ assert os.path.exists(os.path.join(inst, rthree))
65
73
  assert os.path.exists(os.path.join(inst2, rtwo))
66
74
  assert os.path.exists(os.path.join(inst, rone))
@@ -1,8 +1,8 @@
1
- import pytest
2
-
3
- from distutils.util import split_quoted, is_mingw
4
- from distutils.errors import DistutilsPlatformError, CCompilerError
5
1
  from distutils import sysconfig
2
+ from distutils.errors import CCompilerError, DistutilsPlatformError
3
+ from distutils.util import is_mingw, split_quoted
4
+
5
+ import pytest
6
6
 
7
7
 
8
8
  class TestMingw32CCompiler:
@@ -45,6 +45,7 @@ class TestMingw32CCompiler:
45
45
  with pytest.raises(CCompilerError):
46
46
  distutils.cygwinccompiler.Mingw32CCompiler()
47
47
 
48
+ @pytest.mark.skipif('sys.platform == "cygwin"')
48
49
  def test_customize_compiler_with_msvc_python(self):
49
50
  from distutils.cygwinccompiler import Mingw32CCompiler
50
51
 
@@ -7,10 +7,10 @@ import unittest.mock as mock
7
7
  from distutils.errors import DistutilsExecError
8
8
  from distutils.spawn import find_executable, spawn
9
9
  from distutils.tests import support
10
- from test.support import unix_shell
11
10
 
12
11
  import path
13
12
  import pytest
13
+ from test.support import unix_shell
14
14
 
15
15
  from .compat import py38 as os_helper
16
16
 
@@ -9,12 +9,12 @@ import sys
9
9
  from distutils import sysconfig
10
10
  from distutils.ccompiler import new_compiler # noqa: F401
11
11
  from distutils.unixccompiler import UnixCCompiler
12
- from test.support import swap_item
13
12
 
14
13
  import jaraco.envs
15
14
  import path
16
15
  import pytest
17
16
  from jaraco.text import trim
17
+ from test.support import swap_item
18
18
 
19
19
 
20
20
  def _gen_makefile(root, contents):
@@ -134,7 +134,10 @@ class TestSysconfig:
134
134
  assert comp.exes['compiler_so'] == (
135
135
  'env_cc --sc-cflags --env-cflags --env-cppflags --sc-ccshared'
136
136
  )
137
- assert comp.exes['compiler_cxx'] == 'env_cxx --env-cxx-flags'
137
+ assert (
138
+ comp.exes['compiler_cxx']
139
+ == 'env_cxx --env-cxx-flags --sc-cflags --env-cppflags'
140
+ )
138
141
  assert comp.exes['linker_exe'] == 'env_cc'
139
142
  assert comp.exes['linker_so'] == (
140
143
  'env_ldshared --env-ldflags --env-cflags --env-cppflags'
@@ -162,7 +165,7 @@ class TestSysconfig:
162
165
  assert comp.exes['preprocessor'] == 'sc_cc -E'
163
166
  assert comp.exes['compiler'] == 'sc_cc --sc-cflags'
164
167
  assert comp.exes['compiler_so'] == 'sc_cc --sc-cflags --sc-ccshared'
165
- assert comp.exes['compiler_cxx'] == 'sc_cxx'
168
+ assert comp.exes['compiler_cxx'] == 'sc_cxx --sc-cflags'
166
169
  assert comp.exes['linker_exe'] == 'sc_cc'
167
170
  assert comp.exes['linker_so'] == 'sc_ldshared'
168
171
  assert comp.shared_lib_extension == 'sc_shutil_suffix'
@@ -257,9 +257,13 @@ class TestUnixCCompiler(support.TempdirManager):
257
257
  def gcv(v):
258
258
  if v == 'LDSHARED':
259
259
  return 'gcc-4.2 -bundle -undefined dynamic_lookup '
260
+ elif v == 'LDCXXSHARED':
261
+ return 'g++-4.2 -bundle -undefined dynamic_lookup '
260
262
  elif v == 'CXX':
261
263
  return 'g++-4.2'
262
- return 'gcc-4.2'
264
+ elif v == 'CC':
265
+ return 'gcc-4.2'
266
+ return ''
263
267
 
264
268
  def gcvs(*args, _orig=sysconfig.get_config_vars):
265
269
  if args:
@@ -315,3 +319,33 @@ class TestUnixCCompiler(support.TempdirManager):
315
319
  self.cc.output_dir = 'scratch'
316
320
  os.chdir(self.mkdtemp())
317
321
  self.cc.has_function('abort')
322
+
323
+ def test_find_library_file(self, monkeypatch):
324
+ compiler = UnixCCompiler()
325
+ compiler._library_root = lambda dir: dir
326
+ monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d)
327
+
328
+ libname = 'libabc.dylib' if sys.platform != 'cygwin' else 'cygabc.dll'
329
+ dirs = ('/foo/bar/missing', '/foo/bar/existing')
330
+ assert (
331
+ compiler.find_library_file(dirs, 'abc').replace('\\', '/')
332
+ == f'/foo/bar/existing/{libname}'
333
+ )
334
+ assert (
335
+ compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
336
+ == f'/foo/bar/existing/{libname}'
337
+ )
338
+
339
+ monkeypatch.setattr(
340
+ os.path,
341
+ 'exists',
342
+ lambda d: 'existing' in d and '.a' in d and '.dll.a' not in d,
343
+ )
344
+ assert (
345
+ compiler.find_library_file(dirs, 'abc').replace('\\', '/')
346
+ == '/foo/bar/existing/libabc.a'
347
+ )
348
+ assert (
349
+ compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/')
350
+ == '/foo/bar/existing/libabc.a'
351
+ )