3131# We can actually import a restricted version of sklearn that
3232# does not need the compiled code
3333import sklearn
34+
3435VERSION = sklearn .__version__
3536
3637###############################################################################
4546 )).intersection (sys .argv )) > 0 :
4647 import setuptools
4748 extra_setuptools_args = dict (
48- zip_safe = False , # the package can run out of an .egg file
49- include_package_data = True ,
50- )
49+ zip_safe = False , # the package can run out of an .egg file
50+ include_package_data = True ,
51+ )
5152else :
5253 extra_setuptools_args = dict ()
5354
54- ###############################################################################
55- from numpy .distutils .core import setup
5655
5756def configuration (parent_package = '' , top_path = None ):
5857 if os .path .exists ('MANIFEST' ):
@@ -73,29 +72,50 @@ def configuration(parent_package='', top_path=None):
7372 return config
7473
7574
76- if __name__ == "__main__" :
75+ def setup_package ():
76+ metadata = dict (name = DISTNAME ,
77+ maintainer = MAINTAINER ,
78+ maintainer_email = MAINTAINER_EMAIL ,
79+ description = DESCRIPTION ,
80+ license = LICENSE ,
81+ url = URL ,
82+ version = VERSION ,
83+ download_url = DOWNLOAD_URL ,
84+ long_description = LONG_DESCRIPTION ,
85+ classifiers = ['Intended Audience :: Science/Research' ,
86+ 'Intended Audience :: Developers' ,
87+ 'License :: OSI Approved' ,
88+ 'Programming Language :: C' ,
89+ 'Programming Language :: Python' ,
90+ 'Topic :: Software Development' ,
91+ 'Topic :: Scientific/Engineering' ,
92+ 'Operating System :: Microsoft :: Windows' ,
93+ 'Operating System :: POSIX' ,
94+ 'Operating System :: Unix' ,
95+ 'Operating System :: MacOS' ],
96+ ** extra_setuptools_args )
97+
98+ if len (sys .argv ) >= 2 and ('--help' in sys .argv [1 :] or sys .argv [1 ]
99+ in ('--help-commands' , 'egg_info' , '--version' , 'clean' )):
100+
101+ # For these actions, NumPy is not required.
102+ #
103+ # They are required to succeed without Numpy for example when
104+ # pip is used to install Scikit when Numpy is not yet present in
105+ # the system.
106+ try :
107+ from setuptools import setup
108+ except ImportError :
109+ from distutils .core import setup
110+
111+ metadata ['version' ] = VERSION
112+ else :
113+ from numpy .distutils .core import setup
114+
115+ metadata ['configuration' ] = configuration
116+
117+ setup (** metadata )
77118
78- setup (configuration = configuration ,
79- name = DISTNAME ,
80- maintainer = MAINTAINER ,
81- maintainer_email = MAINTAINER_EMAIL ,
82- description = DESCRIPTION ,
83- license = LICENSE ,
84- url = URL ,
85- version = VERSION ,
86- download_url = DOWNLOAD_URL ,
87- long_description = LONG_DESCRIPTION ,
88- classifiers = [
89- 'Intended Audience :: Science/Research' ,
90- 'Intended Audience :: Developers' ,
91- 'License :: OSI Approved' ,
92- 'Programming Language :: C' ,
93- 'Programming Language :: Python' ,
94- 'Topic :: Software Development' ,
95- 'Topic :: Scientific/Engineering' ,
96- 'Operating System :: Microsoft :: Windows' ,
97- 'Operating System :: POSIX' ,
98- 'Operating System :: Unix' ,
99- 'Operating System :: MacOS'
100- ],
101- ** extra_setuptools_args )
119+
120+ if __name__ == "__main__" :
121+ setup_package ()
0 commit comments