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

index 9b84cdc65f1ca6bc16e22898850ac08f64fa7d5c..9ca450318b11848ec105d510843b95d17f8ad4ce 100644 (file)
@@ -1,3 +1,8 @@
+v36.7.3
+-------
+
+* #1175: Bug fixes to ``build_meta`` module.
+
 v36.7.2
 -------
 
index f064fcf915170389e6931376a75b8c292e399b33..850f5762641795659a302ec1ece77886c55a0cf5 100755 (executable)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 36.7.2
+current_version = 36.7.3
 commit = True
 tag = True
 
index 7148962af408af2125cb076e21be520e2e50b10b..b5e7879bf14970d2f1f9be80ce267d2b1e7e0afc 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
 
 setup_params = dict(
     name="setuptools",
-    version="36.7.2",
+    version="36.7.3",
     description="Easily download, build, install, upgrade, and uninstall "
         "Python packages",
     author="Python Packaging Authority",
index 54f2987bf24e5838a8ade3b3e43d9fde6edef22b..609ea1e510c83a480f85ccd9a5d4df1f638b4a7d 100644 (file)
@@ -65,10 +65,11 @@ def _run_setup(setup_script='setup.py'):
     # Note that we can reuse our build directory between calls
     # Correctness comes first, then optimization later
     __file__ = setup_script
+    __name__ = '__main__'
     f = getattr(tokenize, 'open', open)(__file__)
     code = f.read().replace('\\r\\n', '\\n')
     f.close()
-    exec(compile(code, __file__, 'exec'))
+    exec(compile(code, __file__, 'exec'), locals())
 
 
 def _fix_config(config_settings):
@@ -92,6 +93,11 @@ def _get_build_requires(config_settings):
     return requirements
 
 
+def _get_immediate_subdirectories(a_dir):
+    return [name for name in os.listdir(a_dir)
+            if os.path.isdir(os.path.join(a_dir, name))]
+
+
 def get_requires_for_build_wheel(config_settings=None):
     config_settings = _fix_config(config_settings)
     return _get_build_requires(config_settings)
@@ -105,11 +111,29 @@ def get_requires_for_build_sdist(config_settings=None):
 def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
     sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', metadata_directory]
     _run_setup()
+    
+    dist_info_directory = metadata_directory
+    while True:    
+        dist_infos = [f for f in os.listdir(dist_info_directory)
+                      if f.endswith('.dist-info')]
+
+        if len(dist_infos) == 0 and \
+                len(_get_immediate_subdirectories(dist_info_directory)) == 1:
+            dist_info_directory = os.path.join(
+                dist_info_directory, os.listdir(dist_info_directory)[0])
+            continue
+
+        assert len(dist_infos) == 1
+        break
+
+    # PEP 517 requires that the .dist-info directory be placed in the
+    # metadata_directory. To comply, we MUST copy the directory to the root
+    if dist_info_directory != metadata_directory:
+        shutil.move(
+            os.path.join(dist_info_directory, dist_infos[0]),
+            metadata_directory)
+        shutil.rmtree(dist_info_directory, ignore_errors=True)
 
-    dist_infos = [f for f in os.listdir(metadata_directory)
-                  if f.endswith('.dist-info')]
-
-    assert len(dist_infos) == 1
     return dist_infos[0]
 
 
index c6c6dacb78b898460f72918b87cc69e2946c86f0..c45258fa03a3ddd6a73db4514365f8741d16ca86 100644 (file)
@@ -4,7 +4,6 @@ As defined in the wheel specification
 """
 
 import os
-import shutil
 
 from distutils.core import Command
 from distutils import log
@@ -27,14 +26,11 @@ class dist_info(Command):
 
     def run(self):
         egg_info = self.get_finalized_command('egg_info')
+        egg_info.egg_base = self.egg_base
+        egg_info.finalize_options()
         egg_info.run()
         dist_info_dir = egg_info.egg_info[:-len('.egg-info')] + '.dist-info'
         log.info("creating '{}'".format(os.path.abspath(dist_info_dir)))
 
         bdist_wheel = self.get_finalized_command('bdist_wheel')
         bdist_wheel.egg2dist(egg_info.egg_info, dist_info_dir)
-
-        if self.egg_base:
-            destination = os.path.join(self.egg_base, dist_info_dir)
-            log.info("creating '{}'".format(os.path.abspath(destination)))
-            shutil.move(dist_info_dir, destination)
index 69a700c2c12b6c9cda94d2ac1663e779c14fbdbb..659c1a6587ed7ef3a4a207aa8c28cac81e8e6888 100644 (file)
@@ -42,22 +42,55 @@ class BuildBackendCaller(BuildBackendBase):
         return getattr(mod, name)(*args, **kw)
 
 
-@pytest.fixture
-def build_backend(tmpdir):
-    defn = {
-        'setup.py': DALS("""
-            __import__('setuptools').setup(
-                name='foo',
-                py_modules=['hello'],
-                setup_requires=['six'],
-            )
-            """),
-        'hello.py': DALS("""
-            def run():
-                print('hello')
-            """),
-    }
-    build_files(defn, prefix=str(tmpdir))
+defns = [{
+            'setup.py': DALS("""
+                __import__('setuptools').setup(
+                    name='foo',
+                    py_modules=['hello'],
+                    setup_requires=['six'],
+                )
+                """),
+            'hello.py': DALS("""
+                def run():
+                    print('hello')
+                """),
+        },
+        {
+            'setup.py': DALS("""
+                assert __name__ == '__main__'
+                __import__('setuptools').setup(
+                    name='foo',
+                    py_modules=['hello'],
+                    setup_requires=['six'],
+                )
+                """),
+            'hello.py': DALS("""
+                def run():
+                    print('hello')
+                """),
+        },
+        {
+            'setup.py': DALS("""
+                variable = True
+                def function():
+                    return variable
+                assert variable
+                __import__('setuptools').setup(
+                    name='foo',
+                    py_modules=['hello'],
+                    setup_requires=['six'],
+                )
+                """),
+            'hello.py': DALS("""
+                def run():
+                    print('hello')
+                """),
+        }]
+
+
+@pytest.fixture(params=defns)
+def build_backend(tmpdir, request):
+    build_files(request.param, prefix=str(tmpdir))
     with tmpdir.as_cwd():
         yield BuildBackend(cwd='.')