Skip to content

Safe wheel import #905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
47 changes: 27 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
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

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
Expand Down Expand Up @@ -594,21 +598,21 @@ def run(self):
_update_xlat_devtools()
return install.install.run(self)

if 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)

###############################################################################

Expand All @@ -621,6 +625,15 @@ 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,
}
if bdist_wheel:
cmdclass["bdist_wheel"] = BDistWheelPythonnet

setup(
name="pythonnet",
version="2.4.1-dev",
Expand All @@ -633,13 +646,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",
Expand Down