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

Skip to content

Move {setup,install}_requires from setupext.py to setup.py. #13542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
setupext.Matplotlib(),
setupext.Python(),
setupext.Platform(),
setupext.Numpy(),
setupext.LibAgg(),
setupext.FreeType(),
setupext.FT2Font(),
Expand Down Expand Up @@ -178,21 +177,13 @@ def run(self):
packages = []
namespace_packages = []
py_modules = []
# Dummy extension to trigger build_ext, which will swap it out with real
# extensions that can depend on numpy for the build.
ext_modules = [Extension('', [])]
package_data = {}
package_dir = {'': 'lib'}
install_requires = []
setup_requires = []

# If the user just queries for information, don't bother figuring out which
# packages to build or install.
if (any('--' + opt in sys.argv for opt in
Distribution.display_option_names + ['help']) or
'clean' in sys.argv):
setup_requires = []
else:
if not (any('--' + opt in sys.argv
for opt in [*Distribution.display_option_names, 'help'])
or 'clean' in sys.argv):
# Go through all of the packages and figure out which ones we are
# going to build/install.
print_line()
Expand Down Expand Up @@ -245,8 +236,6 @@ def run(self):
for key, val in data.items():
package_data.setdefault(key, [])
package_data[key] = list(set(val + package_data[key]))
install_requires.extend(package.get_install_requires())
setup_requires.extend(package.get_setup_requires())

# Write the default matplotlibrc file
with open('matplotlibrc.template') as fd:
Expand All @@ -268,6 +257,12 @@ def run(self):
author="John D. Hunter, Michael Droettboom",
author_email="[email protected]",
url="https://matplotlib.org",
download_url="https://matplotlib.org/users/installing.html",
project_urls={
'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues',
'Documentation': 'https://matplotlib.org/contents.html',
'Source Code': 'https://github.com/matplotlib/matplotlib'
},
long_description="""
Matplotlib strives to produce publication quality 2D graphics
for interactive graphing, scientific publishing, user interface
Expand All @@ -279,21 +274,24 @@ def run(self):
namespace_packages=namespace_packages,
platforms='any',
py_modules=py_modules,
ext_modules=ext_modules,
package_dir=package_dir,
# Dummy extension to trigger build_ext, which will swap it out with
# real extensions that can depend on numpy for the build.
ext_modules=[Extension("", [])],
package_dir={"": "lib"},
package_data=package_data,
classifiers=classifiers,
download_url="https://matplotlib.org/users/installing.html",
project_urls={
'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues',
'Documentation': 'https://matplotlib.org/contents.html',
'Source Code': 'https://github.com/matplotlib/matplotlib'
},

python_requires='>={}'.format('.'.join(str(n) for n in min_version)),
# List third-party Python packages that we require
install_requires=install_requires,
setup_requires=setup_requires,
setup_requires=[
"numpy>=1.11",
],
install_requires=[
"cycler>=0.10",
"kiwisolver>=1.0.1",
"numpy>=1.11",
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
"python-dateutil>=2.1",
],

# matplotlib has C/C++ extensions, so it's not zip safe.
# Telling setuptools this prevents it from doing an automatic
Expand Down
79 changes: 22 additions & 57 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,6 @@ def get_extension(self):
"""
return None

def get_install_requires(self):
"""
Get a list of Python packages that we require.
pip/easy_install will attempt to download and install this
package if it is not installed.
"""
return []

def get_setup_requires(self):
"""
Get a list of Python packages that we require at build time.
pip/easy_install will attempt to download and install this
package if it is not installed.
"""
return []

def do_custom_build(self):
"""
If a package needs to do extra custom things, such as building a
Expand Down Expand Up @@ -544,14 +528,6 @@ def get_package_data(self):
],
}

def get_install_requires(self):
return [
"cycler>=0.10",
"kiwisolver>=1.0.1",
"pyparsing>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6",
"python-dateutil>=2.1",
]


class SampleData(OptionalPackage):
"""
Expand Down Expand Up @@ -591,27 +567,18 @@ def get_package_data(self):
}


class Numpy(SetupPackage):
name = "numpy"

def add_flags(self, ext):
import numpy as np
ext.include_dirs.append(np.get_include())
ext.define_macros.extend([
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each
# extension.
('PY_ARRAY_UNIQUE_SYMBOL',
'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'),
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
# Allow NumPy's printf format specifiers in C++.
('__STDC_FORMAT_MACROS', 1),
])

def get_setup_requires(self):
return ['numpy>=1.11']

def get_install_requires(self):
return ['numpy>=1.11']
def add_numpy_flags(ext):
import numpy as np
ext.include_dirs.append(np.get_include())
ext.define_macros.extend([
# Ensure that PY_ARRAY_UNIQUE_SYMBOL is uniquely defined for each
# extension.
('PY_ARRAY_UNIQUE_SYMBOL',
'MPL_' + ext.name.replace('.', '_') + '_ARRAY_API'),
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
# Allow NumPy's printf format specifiers in C++.
('__STDC_FORMAT_MACROS', 1),
])


class LibAgg(SetupPackage):
Expand Down Expand Up @@ -794,7 +761,7 @@ def get_extension(self):
]
ext = Extension('matplotlib.ft2font', sources)
FreeType().add_flags(ext)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext, add_sources=False)
return ext

Expand Down Expand Up @@ -822,7 +789,7 @@ def get_extension(self):
atleast_version='1.2',
alt_exec=['libpng-config', '--ldflags'],
default_libraries=['png', 'z'])
Numpy().add_flags(ext)
add_numpy_flags(ext)
return ext


Expand Down Expand Up @@ -850,7 +817,7 @@ def get_extension(self):
'extern/ttconv/ttutil.cpp'
]
ext = Extension('matplotlib.ttconv', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
ext.include_dirs.insert(0, 'extern')
return ext

Expand All @@ -863,9 +830,8 @@ def get_extension(self):
'src/py_converters.cpp',
'src/_path_wrapper.cpp'
]

ext = Extension('matplotlib._path', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext)
return ext

Expand All @@ -881,7 +847,7 @@ def get_extension(self):
'src/py_converters.cpp'
]
ext = Extension('matplotlib._image', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext)

return ext
Expand All @@ -897,7 +863,7 @@ def get_extension(self):
'src/py_converters.cpp',
]
ext = Extension('matplotlib._contour', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext, add_sources=False)
return ext

Expand All @@ -909,7 +875,7 @@ def get_extension(self):
sources = ['src/qhull_wrap.c']
ext = Extension('matplotlib._qhull', sources,
define_macros=[('MPL_DEVNULL', os.devnull)])
Numpy().add_flags(ext)
add_numpy_flags(ext)
Qhull().add_flags(ext)
return ext

Expand All @@ -924,7 +890,7 @@ def get_extension(self):
"src/mplutils.cpp"
]
ext = Extension('matplotlib._tri', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
return ext


Expand All @@ -940,7 +906,7 @@ def get_extension(self):
"src/_backend_agg_wrapper.cpp"
]
ext = Extension('matplotlib.backends._backend_agg', sources)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext)
FreeType().add_flags(ext)
return ext
Expand All @@ -961,7 +927,7 @@ def get_extension(self):

ext = Extension('matplotlib.backends._tkagg', sources)
self.add_flags(ext)
Numpy().add_flags(ext)
add_numpy_flags(ext)
LibAgg().add_flags(ext, add_sources=False)
return ext

Expand Down Expand Up @@ -989,7 +955,6 @@ def get_extension(self):
sources = [
'src/_macosx.m'
]

ext = Extension('matplotlib.backends._macosx', sources)
ext.extra_link_args.extend(['-framework', 'Cocoa'])
if platform.python_implementation().lower() == 'pypy':
Expand Down