Commits

Jason R. Coombs committed 342e978

Create the sdist using tarfile and the code is much simpler

Comments (0)

Files changed (1)

setuptools/tests/test_easy_install.py

 import site
 import contextlib
 import textwrap
+import tarfile
 
 from setuptools.command.easy_install import easy_install, get_script_args, main
 from setuptools.command.easy_install import  PthDistributions
     @contextlib.contextmanager
     def create_sdist():
         """
-        Return an sdist generated by self.generate_dist()
-
-        We don't generate it dynamically, because we don't want the test suite
-        to have to connect to the network for the setup_requires declaration
-        just to build the sdist.
+        Return an sdist with a setup_requires dependency (of something that
+        doesn't exist)
         """
         with tempdir_context() as d:
-            dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz')
-            with open(dist_path, 'wb') as dist:
-                dist.write("""
-                    H4sICLBagE8C/2Rpc3RcZGlzdHJpYnV0ZS10ZXN0LWZldGNoZXItMS4wLnRhcgDtmNtvmzAUh/Ns
-                    Kf+DlZduUkmBYJAi5WHaXd2SqlG7h6pCNJwQa9xmm2j57+eQaqGpktKt0F3O9wI+XCJy/JmfCLlU
-                    gt8UCgwFUhlzULMFCMPqmyedJ8LUeJ5XbjW723LfsjzHNBmzXV23HJuxDmWdFiikCgSlT/KQ1Yf7
-                    SwgP9H97zF8f82+P9SGKDJ7Os5Om+m/brutg///4/oeQQxpCOlv5MU+/yr76rvb8Na7rHui/te0/
-                    0/PEdvWgQ03sf+OQDvI/81v+n52+Nz6O301qqHHI/4HFdvwfePp09L8FPoMKwkAFxiUIybN0SHXn
-                    u2QcJDCkeyZHl9w9eVokSSBWQ3oxPh1Pvoy75EOWgJEHEVRqrwq1yMS9ggFJwONK+ROfQSqrV74B
-                    ORM8V+Uv/qyexYGaZyKplFDndv2fTi7OX7+d7nnt1/ffdHb8dxgboP9tIEEVeT9fkdqLPXnMtCC/
-                    lCEfvkpluR/DEuKH5h7SoP81u/D4/M8cC/3H/I88q/81430tNWrn//L7HxswC/3H/I/5/zn932TD
-                    2Txq2H/r3vd/13QZ+t8GVzrM+eswd90lKoj8m4LHIR3RzUivDKAH5mYkl6kvYMnX6m+qqNy/73++
-                    avr9b3ne3fyv/Tdt9L8NeJJnQtGy1SrLYkm2u/1y9wWhmlQHglFvz2zpHZfnLDepYNTTk+e2VN5B
-                    LxrfCi5A6kXj6mgRlTc/uj4mL3H5QBAEQRAEaZsfEynDsQAoAAA=
-                    """.decode('base64'))
-            yield dist_path
-
-    @classmethod
-    def generate_sdist(cls):
-        """
-        generate the sdist suitable for create_sdist
-        """
-        with tempdir_context(cd=os.chdir):
             with open('setup.py', 'wb') as setup_script:
                 setup_script.write(textwrap.dedent("""
                     import setuptools
                     setuptools.setup(
                         name="distribute-test-fetcher",
                         version="1.0",
-                        setup_requires = ['hgtools'],
+                        setup_requires = ['does-not-exist'],
                     )
                     """).lstrip())
-            with argv_context(['setup.py', 'sdist', '-q', '--formats', 'gztar']):
-                setuptools.setup(
-                    name="distribute-test-fetcher",
-                    version = "1.0",
-                    setup_requires = ['hgtools'],
-                )
-            filename = 'distribute-test-fetcher-1.0.tar.gz'
-            dist = os.path.join('dist', filename)
-            assert os.path.isfile(dist)
-            with open(dist, 'rb') as dist_f:
-                print("=====================")
-                print(dist_f.read().encode('base64'))
-
-@contextlib.contextmanager
-def argv_context(repl):
-    old_argv = sys.argv[:]
-    sys.argv[:] = repl
-    yield
-    sys.argv[:] = old_argv
+            dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz')
+            with tarfile.open(dist_path, 'w:gz') as dist:
+                dist.add('setup.py')
+            yield dist_path
 
 @contextlib.contextmanager
 def tempdir_context(cd=lambda dir:None):