|
1 |
| -#! /usr/bin/env python |
2 |
| -# |
3 |
| -# Copyright (C) 2007-2009 Cournapeau David <[email protected]> |
4 |
| -# 2010 Fabian Pedregosa <[email protected]> |
5 |
| - |
6 |
| -descr = """A set of python modules for machine learning and data mining""" |
7 |
| - |
8 |
| -import sys |
9 |
| -import os |
10 |
| -import shutil |
11 |
| -from distutils.core import Command |
12 |
| - |
13 |
| -if sys.version_info[0] < 3: |
14 |
| - import __builtin__ as builtins |
15 |
| -else: |
16 |
| - import builtins |
17 |
| - |
18 |
| -# This is a bit (!) hackish: we are setting a global variable so that the main |
19 |
| -# sklearn __init__ can detect if it is being loaded by the setup routine, to |
20 |
| -# avoid attempting to load components that aren't built yet. |
21 |
| -builtins.__SKLEARN_SETUP__ = True |
22 |
| - |
23 |
| -DISTNAME = 'scikit-learn' |
24 |
| -DESCRIPTION = 'A set of python modules for machine learning and data mining' |
25 |
| -LONG_DESCRIPTION = open('README.rst').read() |
26 |
| -MAINTAINER = 'Andreas Mueller' |
27 |
| -MAINTAINER_EMAIL = '[email protected]' |
28 |
| -URL = 'http://scikit-learn.org' |
29 |
| -LICENSE = 'new BSD' |
30 |
| -DOWNLOAD_URL = 'http://sourceforge.net/projects/scikit-learn/files/' |
31 |
| - |
32 |
| -# We can actually import a restricted version of sklearn that |
33 |
| -# does not need the compiled code |
34 |
| -import sklearn |
35 |
| - |
36 |
| -VERSION = sklearn.__version__ |
37 |
| - |
38 |
| -############################################################################### |
39 |
| -# Optional setuptools features |
40 |
| -# We need to import setuptools early, if we want setuptools features, |
41 |
| -# as it monkey-patches the 'setup' function |
42 |
| - |
43 |
| -# For some commands, use setuptools |
44 |
| -if len(set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
45 |
| - 'bdist_wininst', 'install_egg_info', 'build_sphinx', |
46 |
| - 'egg_info', 'easy_install', 'upload', |
47 |
| - '--single-version-externally-managed', |
48 |
| - )).intersection(sys.argv)) > 0: |
49 |
| - import setuptools |
50 |
| - extra_setuptools_args = dict( |
51 |
| - zip_safe=False, # the package can run out of an .egg file |
52 |
| - include_package_data=True, |
53 |
| - ) |
54 |
| -else: |
55 |
| - extra_setuptools_args = dict() |
56 |
| - |
57 |
| -############################################################################### |
58 |
| - |
59 |
| -class CleanCommand(Command): |
60 |
| - description = "Remove build directories, and compiled file in the source tree" |
61 |
| - user_options = [] |
62 |
| - |
63 |
| - def initialize_options(self): |
64 |
| - self.cwd = None |
65 |
| - |
66 |
| - def finalize_options(self): |
67 |
| - self.cwd = os.getcwd() |
68 |
| - |
69 |
| - def run(self): |
70 |
| - assert os.getcwd() == self.cwd, 'Must be in package root: %s' % self.cwd |
71 |
| - if os.path.exists('build'): |
72 |
| - shutil.rmtree('build') |
73 |
| - for dirpath, dirnames, filenames in os.walk('sklearn'): |
74 |
| - for filename in filenames: |
75 |
| - if (filename.endswith('.so') or filename.endswith('.pyd') |
76 |
| - or filename.endswith('.dll') |
77 |
| - or filename.endswith('.pyc')): |
78 |
| - os.unlink(os.path.join(dirpath, filename)) |
79 |
| - |
80 |
| - |
81 |
| - |
82 |
| -############################################################################### |
83 |
| -def configuration(parent_package='', top_path=None): |
84 |
| - if os.path.exists('MANIFEST'): |
85 |
| - os.remove('MANIFEST') |
86 |
| - |
87 |
| - from numpy.distutils.misc_util import Configuration |
88 |
| - config = Configuration(None, parent_package, top_path) |
89 |
| - |
90 |
| - # Avoid non-useful msg: |
91 |
| - # "Ignoring attempt to set 'name' (from ... " |
92 |
| - config.set_options(ignore_setup_xxx_py=True, |
93 |
| - assume_default_configuration=True, |
94 |
| - delegate_options_to_subpackages=True, |
95 |
| - quiet=True) |
96 |
| - |
97 |
| - config.add_subpackage('sklearn') |
98 |
| - |
99 |
| - return config |
100 |
| - |
101 |
| - |
102 |
| -def setup_package(): |
103 |
| - metadata = dict(name=DISTNAME, |
104 |
| - maintainer=MAINTAINER, |
105 |
| - maintainer_email=MAINTAINER_EMAIL, |
106 |
| - description=DESCRIPTION, |
107 |
| - license=LICENSE, |
108 |
| - url=URL, |
109 |
| - version=VERSION, |
110 |
| - download_url=DOWNLOAD_URL, |
111 |
| - long_description=LONG_DESCRIPTION, |
112 |
| - classifiers=['Intended Audience :: Science/Research', |
113 |
| - 'Intended Audience :: Developers', |
114 |
| - 'License :: OSI Approved', |
115 |
| - 'Programming Language :: C', |
116 |
| - 'Programming Language :: Python', |
117 |
| - 'Topic :: Software Development', |
118 |
| - 'Topic :: Scientific/Engineering', |
119 |
| - 'Operating System :: Microsoft :: Windows', |
120 |
| - 'Operating System :: POSIX', |
121 |
| - 'Operating System :: Unix', |
122 |
| - 'Operating System :: MacOS', |
123 |
| - 'Programming Language :: Python :: 2', |
124 |
| - 'Programming Language :: Python :: 2.6', |
125 |
| - 'Programming Language :: Python :: 2.7', |
126 |
| - 'Programming Language :: Python :: 3', |
127 |
| - 'Programming Language :: Python :: 3.3', |
128 |
| - ], |
129 |
| - cmdclass={'clean': CleanCommand}, |
130 |
| - **extra_setuptools_args) |
131 |
| - |
132 |
| - if (len(sys.argv) >= 2 |
133 |
| - and ('--help' in sys.argv[1:] or sys.argv[1] |
134 |
| - in ('--help-commands', 'egg_info', '--version', 'clean'))): |
135 |
| - |
136 |
| - # For these actions, NumPy is not required. |
137 |
| - # |
138 |
| - # They are required to succeed without Numpy for example when |
139 |
| - # pip is used to install Scikit when Numpy is not yet present in |
140 |
| - # the system. |
141 |
| - try: |
142 |
| - from setuptools import setup |
143 |
| - except ImportError: |
144 |
| - from distutils.core import setup |
145 |
| - |
146 |
| - metadata['version'] = VERSION |
147 |
| - else: |
148 |
| - from numpy.distutils.core import setup |
149 |
| - |
150 |
| - metadata['configuration'] = configuration |
151 |
| - |
152 |
| - setup(**metadata) |
153 |
| - |
154 |
| - |
155 |
| -if __name__ == "__main__": |
156 |
| - setup_package() |
| 1 | +#! /usr/bin/env python |
| 2 | +# |
| 3 | +# Copyright (C) 2007-2009 Cournapeau David <[email protected]> |
| 4 | +# 2010 Fabian Pedregosa <[email protected]> |
| 5 | + |
| 6 | +descr = """A set of python modules for machine learning and data mining""" |
| 7 | + |
| 8 | +import sys |
| 9 | +import os |
| 10 | +import shutil |
| 11 | +from distutils.command.clean import clean as Clean |
| 12 | + |
| 13 | +if sys.version_info[0] < 3: |
| 14 | + import __builtin__ as builtins |
| 15 | +else: |
| 16 | + import builtins |
| 17 | + |
| 18 | +# This is a bit (!) hackish: we are setting a global variable so that the main |
| 19 | +# sklearn __init__ can detect if it is being loaded by the setup routine, to |
| 20 | +# avoid attempting to load components that aren't built yet. |
| 21 | +builtins.__SKLEARN_SETUP__ = True |
| 22 | + |
| 23 | +DISTNAME = 'scikit-learn' |
| 24 | +DESCRIPTION = 'A set of python modules for machine learning and data mining' |
| 25 | +LONG_DESCRIPTION = open('README.rst').read() |
| 26 | +MAINTAINER = 'Andreas Mueller' |
| 27 | +MAINTAINER_EMAIL = '[email protected]' |
| 28 | +URL = 'http://scikit-learn.org' |
| 29 | +LICENSE = 'new BSD' |
| 30 | +DOWNLOAD_URL = 'http://sourceforge.net/projects/scikit-learn/files/' |
| 31 | + |
| 32 | +# We can actually import a restricted version of sklearn that |
| 33 | +# does not need the compiled code |
| 34 | +import sklearn |
| 35 | + |
| 36 | +VERSION = sklearn.__version__ |
| 37 | + |
| 38 | +############################################################################### |
| 39 | +# Optional setuptools features |
| 40 | +# We need to import setuptools early, if we want setuptools features, |
| 41 | +# as it monkey-patches the 'setup' function |
| 42 | + |
| 43 | +# For some commands, use setuptools |
| 44 | +if len(set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
| 45 | + 'bdist_wininst', 'install_egg_info', 'build_sphinx', |
| 46 | + 'egg_info', 'easy_install', 'upload', |
| 47 | + '--single-version-externally-managed', |
| 48 | + )).intersection(sys.argv)) > 0: |
| 49 | + import setuptools |
| 50 | + extra_setuptools_args = dict( |
| 51 | + zip_safe=False, # the package can run out of an .egg file |
| 52 | + include_package_data=True, |
| 53 | + ) |
| 54 | +else: |
| 55 | + extra_setuptools_args = dict() |
| 56 | + |
| 57 | +############################################################################### |
| 58 | + |
| 59 | +class CleanCommand(Clean): |
| 60 | + description = "Remove build directories, and compiled file in the source tree" |
| 61 | + |
| 62 | + def run(self): |
| 63 | + Clean.run(self) |
| 64 | + if os.path.exists('build'): |
| 65 | + shutil.rmtree('build') |
| 66 | + for dirpath, dirnames, filenames in os.walk('sklearn'): |
| 67 | + for filename in filenames: |
| 68 | + if (filename.endswith('.so') or filename.endswith('.pyd') |
| 69 | + or filename.endswith('.dll') |
| 70 | + or filename.endswith('.pyc')): |
| 71 | + os.unlink(os.path.join(dirpath, filename)) |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +############################################################################### |
| 76 | +def configuration(parent_package='', top_path=None): |
| 77 | + if os.path.exists('MANIFEST'): |
| 78 | + os.remove('MANIFEST') |
| 79 | + |
| 80 | + from numpy.distutils.misc_util import Configuration |
| 81 | + config = Configuration(None, parent_package, top_path) |
| 82 | + |
| 83 | + # Avoid non-useful msg: |
| 84 | + # "Ignoring attempt to set 'name' (from ... " |
| 85 | + config.set_options(ignore_setup_xxx_py=True, |
| 86 | + assume_default_configuration=True, |
| 87 | + delegate_options_to_subpackages=True, |
| 88 | + quiet=True) |
| 89 | + |
| 90 | + config.add_subpackage('sklearn') |
| 91 | + |
| 92 | + return config |
| 93 | + |
| 94 | + |
| 95 | +def setup_package(): |
| 96 | + metadata = dict(name=DISTNAME, |
| 97 | + maintainer=MAINTAINER, |
| 98 | + maintainer_email=MAINTAINER_EMAIL, |
| 99 | + description=DESCRIPTION, |
| 100 | + license=LICENSE, |
| 101 | + url=URL, |
| 102 | + version=VERSION, |
| 103 | + download_url=DOWNLOAD_URL, |
| 104 | + long_description=LONG_DESCRIPTION, |
| 105 | + classifiers=['Intended Audience :: Science/Research', |
| 106 | + 'Intended Audience :: Developers', |
| 107 | + 'License :: OSI Approved', |
| 108 | + 'Programming Language :: C', |
| 109 | + 'Programming Language :: Python', |
| 110 | + 'Topic :: Software Development', |
| 111 | + 'Topic :: Scientific/Engineering', |
| 112 | + 'Operating System :: Microsoft :: Windows', |
| 113 | + 'Operating System :: POSIX', |
| 114 | + 'Operating System :: Unix', |
| 115 | + 'Operating System :: MacOS', |
| 116 | + 'Programming Language :: Python :: 2', |
| 117 | + 'Programming Language :: Python :: 2.6', |
| 118 | + 'Programming Language :: Python :: 2.7', |
| 119 | + 'Programming Language :: Python :: 3', |
| 120 | + 'Programming Language :: Python :: 3.3', |
| 121 | + ], |
| 122 | + cmdclass={'clean': CleanCommand}, |
| 123 | + **extra_setuptools_args) |
| 124 | + |
| 125 | + if (len(sys.argv) >= 2 |
| 126 | + and ('--help' in sys.argv[1:] or sys.argv[1] |
| 127 | + in ('--help-commands', 'egg_info', '--version', 'clean'))): |
| 128 | + |
| 129 | + # For these actions, NumPy is not required. |
| 130 | + # |
| 131 | + # They are required to succeed without Numpy for example when |
| 132 | + # pip is used to install Scikit when Numpy is not yet present in |
| 133 | + # the system. |
| 134 | + try: |
| 135 | + from setuptools import setup |
| 136 | + except ImportError: |
| 137 | + from distutils.core import setup |
| 138 | + |
| 139 | + metadata['version'] = VERSION |
| 140 | + else: |
| 141 | + from numpy.distutils.core import setup |
| 142 | + |
| 143 | + metadata['configuration'] = configuration |
| 144 | + |
| 145 | + setup(**metadata) |
| 146 | + |
| 147 | + |
| 148 | +if __name__ == "__main__": |
| 149 | + setup_package() |
0 commit comments