File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change
1
+ Fixed TypeError in sdist filelist processing by adding support for pathlib Paths for the build_base.
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ def _get_vc_env(plat_spec):
159
159
stderr = subprocess .STDOUT ,
160
160
).decode ('utf-16le' , errors = 'replace' )
161
161
except subprocess .CalledProcessError as exc :
162
- log .error (exc .output )
162
+ log .error (exc .output ) # noqa: RUF100, TRY400
163
163
raise DistutilsPlatformError (f"Error executing { exc .cmd } " )
164
164
165
165
env = {
Original file line number Diff line number Diff line change @@ -391,7 +391,7 @@ def prune_file_list(self):
391
391
build = self .get_finalized_command ('build' )
392
392
base_dir = self .distribution .get_fullname ()
393
393
394
- self .filelist .exclude_pattern (None , prefix = build .build_base )
394
+ self .filelist .exclude_pattern (None , prefix = os . fspath ( build .build_base ) )
395
395
self .filelist .exclude_pattern (None , prefix = base_dir )
396
396
397
397
if sys .platform == 'win32' :
Original file line number Diff line number Diff line change 14
14
15
15
16
16
class Testmsvccompiler (support .TempdirManager ):
17
- def test_no_compiler (self ):
17
+ def test_no_compiler (self , monkeypatch ):
18
18
# makes sure query_vcvarsall raises
19
19
# a DistutilsPlatformError if the compiler
20
20
# is not found
21
21
def _find_vcvarsall (plat_spec ):
22
22
return None , None
23
23
24
- old_find_vcvarsall = _msvccompiler ._find_vcvarsall
25
- _msvccompiler ._find_vcvarsall = _find_vcvarsall
26
- try :
27
- with pytest .raises (DistutilsPlatformError ):
28
- _msvccompiler ._get_vc_env (
29
- 'wont find this version' ,
30
- )
31
- finally :
32
- _msvccompiler ._find_vcvarsall = old_find_vcvarsall
24
+ monkeypatch .setattr (_msvccompiler , '_find_vcvarsall' , _find_vcvarsall )
25
+
26
+ with pytest .raises (DistutilsPlatformError ):
27
+ _msvccompiler ._get_vc_env (
28
+ 'wont find this version' ,
29
+ )
33
30
34
31
@needs_winreg
35
32
def test_get_vc_env_unicode (self ):
Original file line number Diff line number Diff line change 4
4
import io
5
5
import logging
6
6
import os
7
+ import pathlib
7
8
import sys
8
9
import tarfile
9
10
import tempfile
@@ -822,6 +823,21 @@ def get_source_files(self):
822
823
manifest = cmd .filelist .files
823
824
assert '.myfile~' in manifest
824
825
826
+ @pytest .mark .skipif ("os.environ.get('SETUPTOOLS_USE_DISTUTILS') == 'stdlib'" )
827
+ def test_build_base_pathlib (self , source_dir ):
828
+ """
829
+ Ensure if build_base is a pathlib.Path, the build still succeeds.
830
+ """
831
+ dist = Distribution ({
832
+ ** SETUP_ATTRS ,
833
+ "script_name" : "setup.py" ,
834
+ "options" : {"build" : {"build_base" : pathlib .Path ('build' )}},
835
+ })
836
+ cmd = sdist (dist )
837
+ cmd .ensure_finalized ()
838
+ with quiet ():
839
+ cmd .run ()
840
+
825
841
826
842
def test_default_revctrl ():
827
843
"""
You can’t perform that action at this time.
0 commit comments