From 7bc4004e2410f8a9138f5442a8080b632a22c8a1 Mon Sep 17 00:00:00 2001 From: Christopher Bremner Date: Tue, 2 Jul 2019 16:30:47 -0700 Subject: [PATCH 1/4] Only allow wheel commands if wheel is installed --- setup.py | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/setup.py b/setup.py index 53c7f3f67..af9e24519 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ import sysconfig from distutils import spawn from distutils.command import install, build, build_ext, install_data, install_lib -from wheel import bdist_wheel from setuptools import Extension, setup @@ -594,21 +593,25 @@ def run(self): _update_xlat_devtools() return install.install.run(self) +try: + from wheel import bdist_wheel + class BDistWheelPythonnet(bdist_wheel.bdist_wheel): + user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)] -class BDistWheelPythonnet(bdist_wheel.bdist_wheel): - user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)] + def initialize_options(self): + bdist_wheel.bdist_wheel.initialize_options(self) + self.xplat = None - def initialize_options(self): - bdist_wheel.bdist_wheel.initialize_options(self) - self.xplat = None - - def finalize_options(self): - bdist_wheel.bdist_wheel.finalize_options(self) + def finalize_options(self): + bdist_wheel.bdist_wheel.finalize_options(self) - def run(self): - if self.xplat: - _update_xlat_devtools() - return bdist_wheel.bdist_wheel.run(self) + def run(self): + if self.xplat: + _update_xlat_devtools() + return bdist_wheel.bdist_wheel.run(self) +except ImportError: + import warnings + warnings.warn("Wheel not installed, bdist_wheel command is disabled", stacklevel=2) ############################################################################### @@ -621,9 +624,20 @@ def run(self): if not os.path.exists(_get_interop_filename()): setup_requires.append("pycparser") +cmdclass={ + "install": InstallPythonnet, + "build_ext": BuildExtPythonnet, + "install_lib": InstallLibPythonnet, + "install_data": InstallDataPythonnet, +} +try: + cmdclass["bdist_wheel"] = BDistWheelPythonnet +except NameError: + pass + setup( name="pythonnet", - version="2.4.1-dev", + version="2.4.0", description=".Net and Mono integration for Python", url="https://pythonnet.github.io/", license="MIT", @@ -633,13 +647,7 @@ def run(self): long_description=_get_long_description(), ext_modules=[Extension("clr", sources=list(_get_source_files()))], data_files=[("{install_platlib}", ["{build_lib}/Python.Runtime.dll"])], - cmdclass={ - "install": InstallPythonnet, - "build_ext": BuildExtPythonnet, - "install_lib": InstallLibPythonnet, - "install_data": InstallDataPythonnet, - "bdist_wheel": BDistWheelPythonnet, - }, + cmdclass=cmdclass, classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", From 05cf7c1f598d07c71e075decc8188ce75540990b Mon Sep 17 00:00:00 2001 From: Christopher Bremner Date: Tue, 2 Jul 2019 16:32:25 -0700 Subject: [PATCH 2/4] Restore original version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index af9e24519..d6d192a24 100644 --- a/setup.py +++ b/setup.py @@ -637,7 +637,7 @@ def run(self): setup( name="pythonnet", - version="2.4.0", + version="2.4.1-dev", description=".Net and Mono integration for Python", url="https://pythonnet.github.io/", license="MIT", From ebff6730f74a6b7ba8b25e0dec05a80d72fc1324 Mon Sep 17 00:00:00 2001 From: Christopher Bremner Date: Tue, 2 Jul 2019 16:49:44 -0700 Subject: [PATCH 3/4] Add to Authors/Changelog --- AUTHORS.md | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index ba954b47d..a45cf6d78 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -19,6 +19,7 @@ - Callum Noble ([@callumnoble](https://github.com/callumnoble)) - Christian Heimes ([@tiran](https://github.com/tiran)) - Christoph Gohlke ([@cgohlke](https://github.com/cgohlke)) +- Christopher Bremner ([@chrisjbremner](https://github.com/chrisjbremner)) - Christopher Pow ([@christopherpow](https://github.com/christopherpow)) - Daniel Fernandez ([@fdanny](https://github.com/fdanny)) - Daniel Santana ([@dgsantana](https://github.com/dgsantana)) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5a990922..ada979147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. ### Changed - Added argument types information to "No method matches given arguments" message +- Moved wheel import in setup.py inside of a try/except to prevent pip collection failures ### Fixed From 16dcc1d3f40a93e44f8ab62e7e674cd29ecf5c4b Mon Sep 17 00:00:00 2001 From: Christopher Bremner Date: Wed, 3 Jul 2019 07:45:57 -0700 Subject: [PATCH 4/4] Move wheel try/except to the top --- setup.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index d6d192a24..c6e4007e6 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,11 @@ from setuptools import Extension, setup +try: + from wheel import bdist_wheel +except ImportError: + bdist_wheel = None + # Allow config/verbosity to be set from cli # http://stackoverflow.com/a/4792601/5208670 CONFIG = "Release" # Release or Debug @@ -593,8 +598,7 @@ def run(self): _update_xlat_devtools() return install.install.run(self) -try: - from wheel import bdist_wheel +if bdist_wheel: class BDistWheelPythonnet(bdist_wheel.bdist_wheel): user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)] @@ -609,9 +613,6 @@ def run(self): if self.xplat: _update_xlat_devtools() return bdist_wheel.bdist_wheel.run(self) -except ImportError: - import warnings - warnings.warn("Wheel not installed, bdist_wheel command is disabled", stacklevel=2) ############################################################################### @@ -630,10 +631,8 @@ def run(self): "install_lib": InstallLibPythonnet, "install_data": InstallDataPythonnet, } -try: +if bdist_wheel: cmdclass["bdist_wheel"] = BDistWheelPythonnet -except NameError: - pass setup( name="pythonnet",