1515import sysconfig
1616from distutils import spawn
1717from distutils .command import install , build , build_ext , install_data , install_lib
18- from wheel import bdist_wheel
1918
2019from 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
2428CONFIG = "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):
621625if 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+
624637setup (
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