Skip to content

Commit 93968d2

Browse files
chrisjbremnerfilmor
authored andcommitted
Safe wheel import (pythonnet#905)
Only allow wheel commands if wheel is installed
1 parent df0574d commit 93968d2

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Callum Noble ([@callumnoble](https://github.com/callumnoble))
2020
- Christian Heimes ([@tiran](https://github.com/tiran))
2121
- Christoph Gohlke ([@cgohlke](https://github.com/cgohlke))
22+
- Christopher Bremner ([@chrisjbremner](https://github.com/chrisjbremner))
2223
- Christopher Pow ([@christopherpow](https://github.com/christopherpow))
2324
- Daniel Fernandez ([@fdanny](https://github.com/fdanny))
2425
- Daniel Santana ([@dgsantana](https://github.com/dgsantana))

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1414
### Changed
1515

1616
- Added argument types information to "No method matches given arguments" message
17+
- Moved wheel import in setup.py inside of a try/except to prevent pip collection failures
1718

1819
### Fixed
1920

setup.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
import sysconfig
1616
from distutils import spawn
1717
from distutils.command import install, build, build_ext, install_data, install_lib
18-
from wheel import bdist_wheel
1918

2019
from setuptools import Extension, setup
2120

21+
try:
22+
from wheel import bdist_wheel
23+
except ImportError:
24+
bdist_wheel = None
25+
2226
# Allow config/verbosity to be set from cli
2327
# http://stackoverflow.com/a/4792601/5208670
2428
CONFIG = "Release" # Release or Debug
@@ -594,21 +598,21 @@ def run(self):
594598
_update_xlat_devtools()
595599
return install.install.run(self)
596600

601+
if bdist_wheel:
602+
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
603+
user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)]
597604

598-
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
599-
user_options = bdist_wheel.bdist_wheel.user_options + [("xplat", None, None)]
605+
def initialize_options(self):
606+
bdist_wheel.bdist_wheel.initialize_options(self)
607+
self.xplat = None
600608

601-
def initialize_options(self):
602-
bdist_wheel.bdist_wheel.initialize_options(self)
603-
self.xplat = None
609+
def finalize_options(self):
610+
bdist_wheel.bdist_wheel.finalize_options(self)
604611

605-
def finalize_options(self):
606-
bdist_wheel.bdist_wheel.finalize_options(self)
607-
608-
def run(self):
609-
if self.xplat:
610-
_update_xlat_devtools()
611-
return bdist_wheel.bdist_wheel.run(self)
612+
def run(self):
613+
if self.xplat:
614+
_update_xlat_devtools()
615+
return bdist_wheel.bdist_wheel.run(self)
612616

613617
###############################################################################
614618

@@ -621,6 +625,15 @@ def run(self):
621625
if not os.path.exists(_get_interop_filename()):
622626
setup_requires.append("pycparser")
623627

628+
cmdclass={
629+
"install": InstallPythonnet,
630+
"build_ext": BuildExtPythonnet,
631+
"install_lib": InstallLibPythonnet,
632+
"install_data": InstallDataPythonnet,
633+
}
634+
if bdist_wheel:
635+
cmdclass["bdist_wheel"] = BDistWheelPythonnet
636+
624637
setup(
625638
name="pythonnet",
626639
version="2.4.1-dev",
@@ -633,13 +646,7 @@ def run(self):
633646
long_description=_get_long_description(),
634647
ext_modules=[Extension("clr", sources=list(_get_source_files()))],
635648
data_files=[("{install_platlib}", ["{build_lib}/Python.Runtime.dll"])],
636-
cmdclass={
637-
"install": InstallPythonnet,
638-
"build_ext": BuildExtPythonnet,
639-
"install_lib": InstallLibPythonnet,
640-
"install_data": InstallDataPythonnet,
641-
"bdist_wheel": BDistWheelPythonnet,
642-
},
649+
cmdclass=cmdclass,
643650
classifiers=[
644651
"Development Status :: 5 - Production/Stable",
645652
"Intended Audience :: Developers",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy