From e512305905fbc152849a7dc440bd3d69618d1be6 Mon Sep 17 00:00:00 2001 From: Tom Gillespie Date: Tue, 18 Feb 2020 16:25:21 -0800 Subject: [PATCH] setup.py detect if a wheel install is happening from git Needed in order to trigger the correct packaging of data_files in the event that someone or something (usually pip with a git url being using in a Pipfile) tries to build a wheel directly from git. I try to avoid this build workflow because it is difficult to control what files end up being packaged, but it can happen, so we support it. version bump for release --- protcur/protcur/__init__.py | 2 +- protcur/setup.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/protcur/protcur/__init__.py b/protcur/protcur/__init__.py index 56bd823..156d6f9 100644 --- a/protcur/protcur/__init__.py +++ b/protcur/protcur/__init__.py @@ -1 +1 @@ -__version__ = '0.0.4.dev0' +__version__ = '0.0.4' diff --git a/protcur/setup.py b/protcur/setup.py index cfb8b14..9b61860 100644 --- a/protcur/setup.py +++ b/protcur/setup.py @@ -20,9 +20,13 @@ def find_version(filename): long_description = f.read() +ru = Path('resources', 'units') RELEASE = '--release' in sys.argv -if RELEASE: - sys.argv.remove('--release') +WHEEL_FROM_GIT = not ru.exists() and 'bdist_wheel' in sys.argv +if RELEASE or WHEEL_FROM_GIT: + if RELEASE: + sys.argv.remove('--release') + from protcur.config import __anno_tags__, __protc_tags__ from protcur.config import __units_folder__, __units_test_folder__ @@ -36,7 +40,6 @@ def find_version(filename): shutil.copy(__anno_tags__, 'resources') shutil.copy(__protc_tags__, 'resources') -ru = Path('resources', 'units') if ru.exists(): # release or running from sdist not in git data_files = [ ('share/protcur', ['resources/anno-tags.rkt', @@ -85,7 +88,7 @@ def find_version(filename): data_files=data_files, ) finally: - if RELEASE: + if RELEASE or WHEEL_FROM_GIT: shutil.rmtree('resources/units') Path('resources', __anno_tags__.name).unlink() Path('resources', __protc_tags__.name).unlink()