Skip to content

Commit

Permalink
Setuptools creates a dist directory
Browse files Browse the repository at this point in the history
Unfortunately setuptools creates a superfluous 'dist' directory that isn't
removed with clean...

  pypa/setuptools#1347

Working around the test failure it causes...

  ======================================================================
  FAIL: test_sdist
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 141, in <lambda>
      self.method = lambda test: self.result(test)  # method that can be mixed into TestCases
    File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 208, in result
      test.fail(self._result.msg)
  AssertionError: /home/atagar/Desktop/stem/dist already exists, maybe you manually ran 'python setup.py sdist'?
  • Loading branch information
atagar committed Mar 31, 2020
1 parent e4bb1cc commit c132bf0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/integ/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def test_install():
if os.path.exists(BASE_INSTALL_PATH):
shutil.rmtree(BASE_INSTALL_PATH)

if os.path.exists(DIST_PATH):
shutil.rmtree(DIST_PATH)

@asynchronous
def test_sdist(dependency_pid):
"""
Expand All @@ -114,9 +117,6 @@ def test_sdist(dependency_pid):
elif not os.path.exists(git_dir):
raise unittest.case.SkipTest('(not a git checkout)')

if os.path.exists(DIST_PATH):
raise AssertionError("%s already exists, maybe you manually ran 'python setup.py sdist'?" % DIST_PATH)

try:
try:
stem.util.system.call('%s setup.py sdist --dryrun' % PYTHON_EXE, timeout = 60, cwd = test.STEM_BASE)
Expand All @@ -127,7 +127,12 @@ def test_sdist(dependency_pid):

# tarball has a prefix 'stem-[verion]' directory so stipping that out

with tarfile.open(os.path.join(DIST_PATH, 'stem-dry-run-%s.tar.gz' % stem.__version__)) as dist_tar:
dist_content = glob.glob('%s/*' % DIST_PATH)

if len(dist_content) != 1:
raise AssertionError('We should only have a single file in our dist directory, but instead had: %s' % ', '.join(dist_content))

with tarfile.open(dist_content[0]) as dist_tar:
tar_contents = ['/'.join(info.name.split('/')[1:]) for info in dist_tar.getmembers() if info.isfile()]

issues = []
Expand All @@ -137,7 +142,7 @@ def test_sdist(dependency_pid):
issues.append(' * %s is missing from our release tarball' % path)

for path in tar_contents:
if path not in git_contents and path not in ['MANIFEST.in', 'PKG-INFO']:
if path not in git_contents and path not in ['MANIFEST.in', 'PKG-INFO', 'setup.cfg'] and not path.startswith('stem_dry_run.egg-info'):
issues.append(" * %s isn't expected in our release tarball" % path)

if issues:
Expand Down

0 comments on commit c132bf0

Please sign in to comment.