Imported Upstream version 40.4.0 upstream/40.4.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:43:26 +0000 (10:43 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 14 Jan 2019 01:43:26 +0000 (10:43 +0900)
CHANGES.rst
setup.cfg
setup.py
setuptools/build_meta.py
setuptools/tests/test_build_meta.py

index 5da4acfa4f96f71f5324849ef328e4a381dcb781..189ea809b715f0495e2079888439b5cd9d3150bd 100644 (file)
@@ -1,3 +1,9 @@
+v40.4.0
+-------
+
+* #1481: Join the sdist ``--dist-dir`` and the ``build_meta`` sdist directory argument to point to the same target (meaning the build frontend no longer needs to clean manually the dist dir to avoid multiple sdist presence, and setuptools no longer needs to handle conflicts between the two).
+
+
 v40.3.0
 -------
 
index f013124cd7ea2f546b4195bc0ed6e69f5a278e9d..7c878064900deacfc4bf4c6a087e9373326dbc44 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 40.3.0
+current_version = 40.4.0
 commit = True
 tag = True
 
index 38057fd82f4babed079545de8e06aae725ce715b..3ecf1d2e5bf5851e938733084eff5a20ff6cdc67 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
 
 setup_params = dict(
     name="setuptools",
-    version="40.3.0",
+    version="40.4.0",
     description=(
         "Easily download, build, install, upgrade, and uninstall "
         "Python packages"
index f7f9bda241d84da72808b519280b2468239d4042..0067a7ac35c7e468dd4df929c44e8c5d622663c3 100644 (file)
@@ -171,11 +171,9 @@ 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'] + \
-        config_settings["--global-option"]
+        config_settings["--global-option"] + \
+        ["--dist-dir", sdist_directory]
     _run_setup()
-    if sdist_directory != 'dist':
-        shutil.rmtree(sdist_directory)
-        shutil.copytree('dist', sdist_directory)
 
     sdists = [f for f in os.listdir(sdist_directory)
               if f.endswith('.tar.gz')]
index f1d517bb08ba0db45b25aa6b88fb5b91e3d99269..7b195e2c3840717935ae4e5b5c6527e06e8702bd 100644 (file)
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 import os
+import shutil
 
 import pytest
 
@@ -9,7 +10,6 @@ from .textwrap import DALS
 
 __metaclass__ = type
 
-
 futures = pytest.importorskip('concurrent.futures')
 importlib = pytest.importorskip('importlib')
 
@@ -23,12 +23,14 @@ class BuildBackendBase:
 
 class BuildBackend(BuildBackendBase):
     """PEP 517 Build Backend"""
+
     def __init__(self, *args, **kwargs):
         super(BuildBackend, self).__init__(*args, **kwargs)
         self.pool = futures.ProcessPoolExecutor()
 
     def __getattr__(self, name):
         """Handles aribrary function invocations on the build backend."""
+
         def method(*args, **kw):
             root = os.path.abspath(self.cwd)
             caller = BuildBackendCaller(root, self.env, self.backend_name)
@@ -51,6 +53,7 @@ defns = [
         'setup.py': DALS("""
             __import__('setuptools').setup(
                 name='foo',
+                version='0.0.0',
                 py_modules=['hello'],
                 setup_requires=['six'],
             )
@@ -65,6 +68,7 @@ defns = [
             assert __name__ == '__main__'
             __import__('setuptools').setup(
                 name='foo',
+                version='0.0.0',
                 py_modules=['hello'],
                 setup_requires=['six'],
             )
@@ -82,6 +86,7 @@ defns = [
             assert variable
             __import__('setuptools').setup(
                 name='foo',
+                version='0.0.0',
                 py_modules=['hello'],
                 setup_requires=['six'],
             )
@@ -146,3 +151,32 @@ def test_prepare_metadata_for_build_wheel_with_str(build_backend):
     dist_info = build_backend.prepare_metadata_for_build_wheel(dist_dir)
 
     assert os.path.isfile(os.path.join(dist_dir, dist_info, 'METADATA'))
+
+
+def test_build_sdist_explicit_dist(build_backend):
+    # explicitly specifying the dist folder should work
+    # the folder sdist_directory and the ``--dist-dir`` can be the same
+    dist_dir = os.path.abspath('dist')
+    sdist_name = build_backend.build_sdist(dist_dir)
+    assert os.path.isfile(os.path.join(dist_dir, sdist_name))
+
+
+def test_build_sdist_version_change(build_backend):
+    sdist_into_directory = os.path.abspath("out_sdist")
+    os.makedirs(sdist_into_directory)
+
+    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
+    # 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'"))
+
+    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))