15
15
import sysconfig
16
16
from distutils import spawn
17
17
from distutils .command import install , build , build_ext , install_data , install_lib
18
- from wheel import bdist_wheel
19
18
20
19
from setuptools import Extension , setup
21
20
21
+ try :
22
+ from wheel import bdist_wheel
23
+ except ImportError :
24
+ bdist_wheel = None
25
+
22
26
# Allow config/verbosity to be set from cli
23
27
# http://stackoverflow.com/a/4792601/5208670
24
28
CONFIG = "Release" # Release or Debug
@@ -594,21 +598,21 @@ def run(self):
594
598
_update_xlat_devtools ()
595
599
return install .install .run (self )
596
600
601
+ if bdist_wheel :
602
+ class BDistWheelPythonnet (bdist_wheel .bdist_wheel ):
603
+ user_options = bdist_wheel .bdist_wheel .user_options + [("xplat" , None , None )]
597
604
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
600
608
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 )
604
611
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 )
612
616
613
617
###############################################################################
614
618
@@ -621,6 +625,15 @@ def run(self):
621
625
if not os .path .exists (_get_interop_filename ()):
622
626
setup_requires .append ("pycparser" )
623
627
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
+
624
637
setup (
625
638
name = "pythonnet" ,
626
639
version = "2.4.1-dev" ,
@@ -633,13 +646,7 @@ def run(self):
633
646
long_description = _get_long_description (),
634
647
ext_modules = [Extension ("clr" , sources = list (_get_source_files ()))],
635
648
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 ,
643
650
classifiers = [
644
651
"Development Status :: 5 - Production/Stable" ,
645
652
"Intended Audience :: Developers" ,
0 commit comments