Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore support for pathlib paths in build_base #4630

Merged
merged 8 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4615.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed TypeError in sdist filelist processing by adding support for pathlib Paths for the build_base.
2 changes: 1 addition & 1 deletion setuptools/_distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _get_vc_env(plat_spec):
stderr=subprocess.STDOUT,
).decode('utf-16le', errors='replace')
except subprocess.CalledProcessError as exc:
log.error(exc.output)
log.error(exc.output) # noqa: RUF100, TRY400
raise DistutilsPlatformError(f"Error executing {exc.cmd}")

env = {
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/command/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def prune_file_list(self):
build = self.get_finalized_command('build')
base_dir = self.distribution.get_fullname()

self.filelist.exclude_pattern(None, prefix=build.build_base)
self.filelist.exclude_pattern(None, prefix=os.fspath(build.build_base))
self.filelist.exclude_pattern(None, prefix=base_dir)

if sys.platform == 'win32':
Expand Down
17 changes: 7 additions & 10 deletions setuptools/_distutils/tests/test_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@


class Testmsvccompiler(support.TempdirManager):
def test_no_compiler(self):
def test_no_compiler(self, monkeypatch):
# makes sure query_vcvarsall raises
# a DistutilsPlatformError if the compiler
# is not found
def _find_vcvarsall(plat_spec):
return None, None

old_find_vcvarsall = _msvccompiler._find_vcvarsall
_msvccompiler._find_vcvarsall = _find_vcvarsall
try:
with pytest.raises(DistutilsPlatformError):
_msvccompiler._get_vc_env(
'wont find this version',
)
finally:
_msvccompiler._find_vcvarsall = old_find_vcvarsall
monkeypatch.setattr(_msvccompiler, '_find_vcvarsall', _find_vcvarsall)

with pytest.raises(DistutilsPlatformError):
_msvccompiler._get_vc_env(
'wont find this version',
)

@needs_winreg
def test_get_vc_env_unicode(self):
Expand Down
16 changes: 16 additions & 0 deletions setuptools/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io
import logging
import os
import pathlib
import sys
import tarfile
import tempfile
Expand Down Expand Up @@ -822,6 +823,21 @@ def get_source_files(self):
manifest = cmd.filelist.files
assert '.myfile~' in manifest

@pytest.mark.skipif("os.environ.get('SETUPTOOLS_USE_DISTUTILS') == 'stdlib'")
def test_build_base_pathlib(self, source_dir):
jaraco marked this conversation as resolved.
Show resolved Hide resolved
"""
Ensure if build_base is a pathlib.Path, the build still succeeds.
"""
dist = Distribution({
**SETUP_ATTRS,
"script_name": "setup.py",
"options": {"build": {"build_base": pathlib.Path('build')}},
})
cmd = sdist(dist)
cmd.ensure_finalized()
with quiet():
cmd.run()


def test_default_revctrl():
"""
Expand Down
Loading