3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00

Tweak python setup.py clean to properly clean the native build

This commit is contained in:
Audrey Dutcher 2019-02-10 14:25:20 -08:00
parent b702cad81e
commit 4e687671a5

View file

@ -10,6 +10,7 @@ from distutils.util import get_platform
from distutils.errors import LibError
from distutils.command.build import build as _build
from distutils.command.sdist import sdist as _sdist
from distutils.command.clean import clean as _clean
from setuptools.command.develop import develop as _develop
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
@ -37,13 +38,23 @@ else:
LIBRARY_FILE = "libz3.so"
EXECUTABLE_FILE = "z3"
def rmtree(tree):
if os.path.exists(tree):
shutil.rmtree(tree, ignore_errors=False)
def _clean_bins():
"""
Clean up the binary files and headers that are installed along with the bindings
"""
shutil.rmtree(LIBS_DIR, ignore_errors=True)
shutil.rmtree(BINS_DIR, ignore_errors=True)
shutil.rmtree(HEADERS_DIR, ignore_errors=True)
rmtree(LIBS_DIR)
rmtree(BINS_DIR)
rmtree(HEADERS_DIR)
def _clean_native_build():
"""
Clean the "build" directory in the z3 native root
"""
rmtree(BUILD_DIR)
def _z3_version():
post = os.getenv('Z3_VERSION_SUFFIX', '')
@ -146,10 +157,16 @@ class bdist_egg(_bdist_egg):
class sdist(_sdist):
def run(self):
self.execute(_clean_bins, (), msg="Cleaning binary files")
self.execute(_clean_bins, (), msg="Cleaning binary files and headers")
self.execute(_copy_sources, (), msg="Copying source files")
_sdist.run(self)
class clean(_clean):
def run(self):
self.execute(_clean_bins, (), msg="Cleaning binary files and headers")
self.execute(_clean_native_build, (), msg="Cleaning native build")
_clean.run(self)
# the build directory needs to exist
#try: os.makedirs(os.path.join(ROOT_DIR, 'build'))
#except OSError: pass
@ -191,5 +208,5 @@ setup(
'z3': [os.path.join('lib', '*'), os.path.join('include', '*.h'), os.path.join('include', 'c++', '*.h')]
},
data_files=[('bin',[os.path.join('bin',EXECUTABLE_FILE)])],
cmdclass={'build': build, 'develop': develop, 'sdist': sdist, 'bdist_egg': bdist_egg},
cmdclass={'build': build, 'develop': develop, 'sdist': sdist, 'bdist_egg': bdist_egg, 'clean': clean},
)