From 08fb925b3418d750f95a565a93689517e7ae56ee Mon Sep 17 00:00:00 2001 From: Ehsan Azarnasab Date: Thu, 20 Aug 2015 18:03:18 -0700 Subject: [PATCH] always clean up dist folder to have a clean sdist and clean builds --- setup.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 245fbe773..4855bd4ec 100644 --- a/setup.py +++ b/setup.py @@ -245,6 +245,25 @@ def copy_file(src, dst): shutil.copy2(src, dst) +def clean_dist(): + """re-create the dist folder + """ + dist_dir = os.path.join(script_dir, "./dist") + if os.path.exists(dist_dir): + log.info('Removing distribution directory %s' % dist_dir) + rmtree(dist_dir) + + dist_dir = os.path.join(script_dir, "./dist/dlib") + try: + os.makedirs(dist_dir) + except OSError: + pass + + +# always start with a clean slate +clean_dist() + + # noinspection PyPep8Naming class build(_build): def run(self): @@ -252,11 +271,6 @@ class build(_build): if not repackage: self.build_dlib() - dist_dir = os.path.join(script_dir, "dist") - if os.path.exists(dist_dir): - log.info('Removing distribution directory %s' % dist_dir) - rmtree(dist_dir) - # this is where the extension examples go dist_dir_examples = os.path.join(script_dir, "./dist/dlib/examples") try: @@ -265,8 +279,8 @@ class build(_build): pass # this is where the extension goes - log.info('Populating the distribution directory %s ...' % dist_dir) dist_dir = os.path.join(script_dir, "./dist/dlib") + log.info('Populating the distribution directory %s ...' % dist_dir) # create the module init files with open(os.path.join(dist_dir, '__init__.py'), 'w') as f: @@ -385,7 +399,7 @@ setup( author_email='davis@dlib.net', url='https://github.com/davisking/dlib', license='Boost Software License', - packages=['dlib', 'dlib.examples'], + packages=['dlib'], package_dir={'': 'dist'}, include_package_data=True, cmdclass={