From 22f6a38f0afadebed8174c3a0df27d6ea2d0be41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 7 Feb 2019 15:28:01 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Universal=20wheel=20and=20related?= =?UTF-8?q?=20setup.py=20adjustments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also make sure that our environment specific dependencies get recorded to the wheel so that we don't have to build in the same environment as the software will run later (consider this work towards a PyPI release that might also be backported). --- setup.cfg | 3 +++ setup.py | 31 +++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 4320f0f8a..24ae4b6df 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,9 @@ [metadata] license_file = LICENSE.txt +[bdist_wheel] +universal = 1 + [versioneer] VCS = git style = pep440-tag diff --git a/setup.py b/setup.py index e2414c7eb..300cbd48a 100644 --- a/setup.py +++ b/setup.py @@ -9,11 +9,13 @@ import versioneer import sys sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "src")) import octoprint_setuptools +import setuptools #----------------------------------------------------------------------------------------------------------------------- # Supported python versions -PYTHON_REQUIRES = ">=2.7.9" # py 3 marked as supported so that we can migrate... NOT officially supported though! +# we test against 2.7, 3.6 and 3.7, so that's what we'll mark as supported +PYTHON_REQUIRES = ">=2.7.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" # Requirements for our application INSTALL_REQUIRES = [ @@ -57,14 +59,11 @@ INSTALL_REQUIRES = [ "python-dateutil>=2.7.5,<2.8", "wrapt>=1.10.11,<1.11", "emoji>=0.5.1,<0.6", - "monotonic>=1.5,<1.6", "frozendict>=1.2,<1.3" ] -if sys.version_info[0] < 3: - INSTALL_REQUIRES.append("futures>=3.2,<3.3") -if sys.platform == "darwin": - INSTALL_REQUIRES.append("appdirs>=1.4.0") +INSTALL_REQUIRES_PYTHON2 = ["futures>=3.2,<3.3", "monotonic>=1.5,<1.6"] +INSTALL_REQUIRES_OSX = ["appdirs>=1.4.0",] # Additional requirements for optional install options EXTRA_REQUIRES = dict( @@ -94,6 +93,23 @@ EXTRA_REQUIRES = dict( # Dependency links for any of the aforementioned dependencies DEPENDENCY_LINKS = [] +# adapted from https://hynek.me/articles/conditional-python-dependencies/ +if int(setuptools.__version__.split(".", 1)[0]) < 18: + # no bdist_wheel support for setuptools < 18 since we build universal wheels and our optional dependencies + # would get lost there + assert "bdist_wheel" not in sys.argv + + # add optional dependencies for setuptools versions < 18 that don't yet support environment markers + if sys.version_info[0] < 3: + INSTALL_REQUIRES += INSTALL_REQUIRES_PYTHON2 + + if sys.platform == "darwin": + INSTALL_REQUIRES += INSTALL_REQUIRES_OSX +else: + # environment markers supported + EXTRA_REQUIRES[":python_version < '3'"] = INSTALL_REQUIRES_PYTHON2 + EXTRA_REQUIRES[":sys_platform == 'darwin'"] = INSTALL_REQUIRES_OSX + #----------------------------------------------------------------------------------------------------------------------- # Anything below here is just command setup and general setup configuration @@ -185,6 +201,9 @@ def params(): "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: JavaScript", "Topic :: Printing",