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

In build_meta (PEP 517), always built gztar #1625

Merged
merged 4 commits into from
Jan 3, 2019
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 changelog.d/1625.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In PEP 517 build_meta builder, ensure that sdists are built as gztar per the spec.
2 changes: 1 addition & 1 deletion setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def build_wheel(wheel_directory, config_settings=None,
def build_sdist(sdist_directory, config_settings=None):
config_settings = _fix_config(config_settings)
sdist_directory = os.path.abspath(sdist_directory)
sys.argv = sys.argv[:1] + ['sdist'] + \
sys.argv = sys.argv[:1] + ['sdist', '--formats', 'gztar'] + \
config_settings["--global-option"] + \
["--dist-dir", sdist_directory]
_run_setup()
Expand Down
27 changes: 24 additions & 3 deletions setuptools/tests/test_build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,21 @@ def test_build_sdist_version_change(build_backend):
sdist_name = build_backend.build_sdist(sdist_into_directory)
assert os.path.isfile(os.path.join(sdist_into_directory, sdist_name))

# if the setup.py changes subsequent call of the build meta should still succeed, given the
# if the setup.py changes subsequent call of the build meta
# should still succeed, given the
# sdist_directory the frontend specifies is empty
with open(os.path.abspath("setup.py"), 'rt') as file_handler:
content = file_handler.read()
with open(os.path.abspath("setup.py"), 'wt') as file_handler:
file_handler.write(content.replace("version='0.0.0'", "version='0.0.1'"))
file_handler.write(
content.replace("version='0.0.0'", "version='0.0.1'"))

shutil.rmtree(sdist_into_directory)
os.makedirs(sdist_into_directory)

sdist_name = build_backend.build_sdist("out_sdist")
assert os.path.isfile(os.path.join(os.path.abspath("out_sdist"), sdist_name))
assert os.path.isfile(
os.path.join(os.path.abspath("out_sdist"), sdist_name))


def test_build_sdist_setup_py_exists(tmpdir_cwd):
Expand Down Expand Up @@ -215,3 +218,21 @@ def test_build_sdist_setup_py_manifest_excluded(tmpdir_cwd):
with tarfile.open(os.path.join("temp", targz_path)) as tar:
assert not any('setup.py' in name for name in tar.getnames())


def test_build_sdist_builds_targz_even_if_zip_indicated(tmpdir_cwd):
files = {
'setup.py': DALS("""
__import__('setuptools').setup(
name='foo',
version='0.0.0',
py_modules=['hello']
)"""),
'hello.py': '',
'setup.cfg': DALS("""
[sdist]
formats=zip
""")
}

build_files(files)
build_sdist("temp")