Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ce649c

Browse files
authored
Merge pull request #13542 from anntzer/numpy_requires
BLD: Move {setup,install}_requires from setupext.py to setup.py.
2 parents 7b10000 + 846249f commit 4ce649c

File tree

2 files changed

+45
-82
lines changed

2 files changed

+45
-82
lines changed

setup.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
setupext.Matplotlib(),
5858
setupext.Python(),
5959
setupext.Platform(),
60-
setupext.Numpy(),
6160
setupext.LibAgg(),
6261
setupext.FreeType(),
6362
setupext.FT2Font(),
@@ -175,21 +174,13 @@ def run(self):
175174
packages = []
176175
namespace_packages = []
177176
py_modules = []
178-
# Dummy extension to trigger build_ext, which will swap it out with real
179-
# extensions that can depend on numpy for the build.
180-
ext_modules = [Extension('', [])]
181177
package_data = {}
182-
package_dir = {'': 'lib'}
183-
install_requires = []
184-
setup_requires = []
185178

186179
# If the user just queries for information, don't bother figuring out which
187180
# packages to build or install.
188-
if (any('--' + opt in sys.argv for opt in
189-
Distribution.display_option_names + ['help']) or
190-
'clean' in sys.argv):
191-
setup_requires = []
192-
else:
181+
if not (any('--' + opt in sys.argv
182+
for opt in [*Distribution.display_option_names, 'help'])
183+
or 'clean' in sys.argv):
193184
# Go through all of the packages and figure out which ones we are
194185
# going to build/install.
195186
print_line()
@@ -242,8 +233,6 @@ def run(self):
242233
for key, val in data.items():
243234
package_data.setdefault(key, [])
244235
package_data[key] = list(set(val + package_data[key]))
245-
install_requires.extend(package.get_install_requires())
246-
setup_requires.extend(package.get_setup_requires())
247236

248237
# Write the default matplotlibrc file
249238
with open('matplotlibrc.template') as fd:
@@ -265,6 +254,12 @@ def run(self):
265254
author="John D. Hunter, Michael Droettboom",
266255
author_email="[email protected]",
267256
url="https://matplotlib.org",
257+
download_url="https://matplotlib.org/users/installing.html",
258+
project_urls={
259+
'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues',
260+
'Documentation': 'https://matplotlib.org/contents.html',
261+
'Source Code': 'https://github.com/matplotlib/matplotlib'
262+
},
268263
long_description="""
269264
Matplotlib strives to produce publication quality 2D graphics
270265
for interactive graphing, scientific publishing, user interface
@@ -276,21 +271,24 @@ def run(self):
276271
namespace_packages=namespace_packages,
277272
platforms='any',
278273
py_modules=py_modules,
279-
ext_modules=ext_modules,
280-
package_dir=package_dir,
274+
# Dummy extension to trigger build_ext, which will swap it out with
275+
# real extensions that can depend on numpy for the build.
276+
ext_modules=[Extension("", [])],
277+
package_dir={"": "lib"},
281278
package_data=package_data,
282279
classifiers=classifiers,
283-
download_url="https://matplotlib.org/users/installing.html",
284-
project_urls={
285-
'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues',
286-
'Documentation': 'https://matplotlib.org/contents.html',
287-
'Source Code': 'https://github.com/matplotlib/matplotlib'
288-
},
289280

290281
python_requires='>={}'.format('.'.join(str(n) for n in min_version)),
291-
# List third-party Python packages that we require
292-
install_requires=install_requires,
293-
setup_requires=setup_requires,
282+
setup_requires=[
283+
"numpy>=1.11",
284+
],
285+
install_requires=[
286+
"cycler>=0.10",
287+
"kiwisolver>=1.0.1",
288+
"numpy>=1.11",
289+
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
290+
"python-dateutil>=2.1",
291+
],
294292

295293
# matplotlib has C/C++ extensions, so it's not zip safe.
296294
# Telling setuptools this prevents it from doing an automatic

setupext.py

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,6 @@ def get_extension(self):
350350
"""
351351
return None
352352

353-
def get_install_requires(self):
354-
"""
355-
Get a list of Python packages that we require.
356-
pip/easy_install will attempt to download and install this
357-
package if it is not installed.
358-
"""
359-
return []
360-
361-
def get_setup_requires(self):
362-
"""
363-
Get a list of Python packages that we require at build time.
364-
pip/easy_install will attempt to download and install this
365-
package if it is not installed.
366-
"""
367-
return []
368-
369353
def do_custom_build(self):
370354
"""
371355
If a package needs to do extra custom things, such as building a
@@ -521,14 +505,6 @@ def get_package_data(self):
521505
],
522506
}
523507

524-
def get_install_requires(self):
525-
return [
526-
"cycler>=0.10",
527-
"kiwisolver>=1.0.1",
528-
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
529-
"python-dateutil>=2.1",
530-
]
531-
532508

533509
class SampleData(OptionalPackage):
534510
"""
@@ -568,27 +544,18 @@ def get_package_data(self):
568544
}
569545

570546

571-
class Numpy(SetupPackage):
572-
name = "numpy"
573-
574-
def add_flags(self, ext):
575-
import numpy as np
576-
ext.include_dirs.append(np.get_include())
577-
ext.define_macros.extend([
578-
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each
579-
# extension.
580-
('PY_ARRAY_UNIQUE_SYMBOL',
581-
'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'),
582-
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
583-
# Allow NumPy's printf format specifiers in C++.
584-
('__STDC_FORMAT_MACROS', 1),
585-
])
586-
587-
def get_setup_requires(self):
588-
return ['numpy>=1.11']
589-
590-
def get_install_requires(self):
591-
return ['numpy>=1.11']
547+
def add_numpy_flags(ext):
548+
import numpy as np
549+
ext.include_dirs.append(np.get_include())
550+
ext.define_macros.extend([
551+
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each
552+
# extension.
553+
('PY_ARRAY_UNIQUE_SYMBOL',
554+
'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'),
555+
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
556+
# Allow NumPy's printf format specifiers in C++.
557+
('__STDC_FORMAT_MACROS', 1),
558+
])
592559

593560

594561
class LibAgg(SetupPackage):
@@ -771,7 +738,7 @@ def get_extension(self):
771738
]
772739
ext = Extension('matplotlib.ft2font', sources)
773740
FreeType().add_flags(ext)
774-
Numpy().add_flags(ext)
741+
add_numpy_flags(ext)
775742
LibAgg().add_flags(ext, add_sources=False)
776743
return ext
777744

@@ -799,7 +766,7 @@ def get_extension(self):
799766
atleast_version='1.2',
800767
alt_exec=['libpng-config', '--ldflags'],
801768
default_libraries=['png', 'z'])
802-
Numpy().add_flags(ext)
769+
add_numpy_flags(ext)
803770
return ext
804771

805772

@@ -827,7 +794,7 @@ def get_extension(self):
827794
'extern/ttconv/ttutil.cpp'
828795
]
829796
ext = Extension('matplotlib.ttconv', sources)
830-
Numpy().add_flags(ext)
797+
add_numpy_flags(ext)
831798
ext.include_dirs.insert(0, 'extern')
832799
return ext
833800

@@ -840,9 +807,8 @@ def get_extension(self):
840807
'src/py_converters.cpp',
841808
'src/_path_wrapper.cpp'
842809
]
843-
844810
ext = Extension('matplotlib._path', sources)
845-
Numpy().add_flags(ext)
811+
add_numpy_flags(ext)
846812
LibAgg().add_flags(ext)
847813
return ext
848814

@@ -858,7 +824,7 @@ def get_extension(self):
858824
'src/py_converters.cpp'
859825
]
860826
ext = Extension('matplotlib._image', sources)
861-
Numpy().add_flags(ext)
827+
add_numpy_flags(ext)
862828
LibAgg().add_flags(ext)
863829

864830
return ext
@@ -874,7 +840,7 @@ def get_extension(self):
874840
'src/py_converters.cpp',
875841
]
876842
ext = Extension('matplotlib._contour', sources)
877-
Numpy().add_flags(ext)
843+
add_numpy_flags(ext)
878844
LibAgg().add_flags(ext, add_sources=False)
879845
return ext
880846

@@ -886,7 +852,7 @@ def get_extension(self):
886852
sources = ['src/qhull_wrap.c']
887853
ext = Extension('matplotlib._qhull', sources,
888854
define_macros=[('MPL_DEVNULL', os.devnull)])
889-
Numpy().add_flags(ext)
855+
add_numpy_flags(ext)
890856
Qhull().add_flags(ext)
891857
return ext
892858

@@ -901,7 +867,7 @@ def get_extension(self):
901867
"src/mplutils.cpp"
902868
]
903869
ext = Extension('matplotlib._tri', sources)
904-
Numpy().add_flags(ext)
870+
add_numpy_flags(ext)
905871
return ext
906872

907873

@@ -917,7 +883,7 @@ def get_extension(self):
917883
"src/_backend_agg_wrapper.cpp"
918884
]
919885
ext = Extension('matplotlib.backends._backend_agg', sources)
920-
Numpy().add_flags(ext)
886+
add_numpy_flags(ext)
921887
LibAgg().add_flags(ext)
922888
FreeType().add_flags(ext)
923889
return ext
@@ -938,7 +904,7 @@ def get_extension(self):
938904

939905
ext = Extension('matplotlib.backends._tkagg', sources)
940906
self.add_flags(ext)
941-
Numpy().add_flags(ext)
907+
add_numpy_flags(ext)
942908
LibAgg().add_flags(ext, add_sources=False)
943909
return ext
944910

@@ -965,7 +931,6 @@ def get_extension(self):
965931
sources = [
966932
'src/_macosx.m'
967933
]
968-
969934
ext = Extension('matplotlib.backends._macosx', sources)
970935
ext.extra_link_args.extend(['-framework', 'Cocoa'])
971936
if platform.python_implementation().lower() == 'pypy':

0 commit comments

Comments
 (0)