Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
setup.py: fix sdist if files are removed
setuptools has a long-standing bug that if files are removed from the
list of sources but were included in a previous run of egg_info, they
remain in the generated list of sources (pypa/setuptools#436). This
affects egg_info and sdist. Let's work around this by removing the old
SOURCES.txt if we can recreate it from git.
  • Loading branch information
osandov committed Nov 19, 2019
1 parent 0df2152 commit 5fbe1b1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions setup.py
@@ -1,13 +1,15 @@
#!/usr/bin/env python3

import contextlib
import re
import os.path
from distutils.dir_util import mkpath
from distutils.file_util import copy_file
import os
import os.path
import re
from setuptools import setup, find_packages
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.egg_info import egg_info
from setuptools.extension import Extension
import subprocess
import sys

Expand Down Expand Up @@ -81,6 +83,17 @@ def get_source_files(self):
return []


# Work around pypa/setuptools#436.
class my_egg_info(egg_info):
def run(self):
if os.path.exists('.git'):
try:
os.remove(os.path.join(self.egg_info, 'SOURCES.txt'))
except FileNotFoundError:
pass
super().run()


with open('libdrgn/drgn.h.in', 'r') as f:
drgn_h = f.read()
version_major = re.search('^#define DRGN_VERSION_MAJOR ([0-9])+$', drgn_h,
Expand All @@ -100,6 +113,7 @@ def get_source_files(self):
ext_modules=[Extension(name='_drgn', sources=[])],
cmdclass={
'build_ext': my_build_ext,
'egg_info': my_egg_info,
},
entry_points={
'console_scripts': ['drgn=drgn.internal.cli:main'],
Expand Down

0 comments on commit 5fbe1b1

Please sign in to comment.