8000 Retool the setup.py infrastructure by mdboom · Pull Request #1454 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Retool the setup.py infrastructure #1454

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 24 commits into from
Feb 26, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6aa7b29
First pass at making setup more sane.
mdboom Oct 8, 2012
4ae2fd2
Removing dateutils, pytz and six (external Python dependencies)
mdboom Oct 9, 2012
04a73b4
Fix a few bugs in the build.
mdboom Oct 9, 2012
bae0859
More fixes
mdboom Oct 9, 2012
9b408cd
setupegg.py is now redundant.
mdboom Nov 6, 2012
6f64971
Fix type in dates docs
mdboom Nov 6, 2012
088a267
Update INSTALL document to reflect new reality
mdboom Nov 6, 2012
7018842
Handle dateutil and pyparsing in the same manner as everything else.
mdboom Nov 6, 2012
49bd70a
Raise exception early if pyparsing and/or dateutil are not installed.
mdboom Nov 6, 2012
4d8c846
Fix pyparsing on python 3 check
mdboom Nov 6, 2012
7db8fe2
Fix build on Python 2.6
mdboom Nov 16, 2012
b81c917
Update Travis dependencies
mdboom Nov 16, 2012
4301543
Implement a better way to handle overflow in the Agg backend.
mdboom Nov 19, 2012
d93226e
Fix agg overflow test
mdboom Nov 19, 2012
5f41835
Make using an external PyCXX possible on != Python 2.7
mdboom Nov 19, 2012
ce1da9b
Fix infinite process recursion on Windows
mdboom Nov 20, 2012
e0735bf
Update to PyCXX 6.2.4
mdboom Nov 26, 2012
ee2f3f4
Update the CXX detection code to use the system PyCXX in more cases
mdboom Nov 26, 2012
8f95f1c
Fix compiler warnings about compare_handler
mdboom Nov 26, 2012
da76037
Attempting to fix Travis tests
mdboom Dec 7, 2012
b5443e2
Windows fixes from cgohlke
mdboom Dec 19, 2012
009b1a0
Fixups after rebase
mdboom Jan 16, 2013
0ed7228
multiprocessing doesn't work with Travis, so just skip the things tha…
mdboom Feb 25, 2013
5934e0e
Properly install the pylab module
mdboom Feb 25, 2013
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
Prev Previous commit
Next Next commit
Fix infinite process recursion on Windows
  • Loading branch information
mdboom committed Feb 25, 2013
commit ce1da9b07c9f89f76622a823d92f85bd00f7b172
270 changes: 137 additions & 133 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
except AttributeError:
pass

# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
# This 'if' statement is needed to prevent spawning infinite processes
# on Windows
if __name__ == '__main__':
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')

try:
from setuptools.core import setup
except ImportError:
from distutils.core import setup


import setupext
from setupext import print_line, print_raw, print_message, print_status

Expand All @@ -48,6 +50,7 @@
'Required dependencies and extensions',
setupext.Numpy(),
setupext.Dateutil(),
setupext.Tornado(),
setupext.Pyparsing(),
setupext.CXX(),
setupext.LibAgg(),
Expand Down Expand Up @@ -87,90 +90,6 @@
]


# These are distutils.setup parameters that the various packages add
# things to.
packages = []
py_modules = []
ext_modules = 8000 []
package_data = {}
package_dir = {'': 'lib'}
install_requires = []
default_backend = None


# Go through all of the packages and figure out which ones we are
# going to build/install.
print_line()
print_raw("Edit setup.cfg to change the build options")


required_failed = []
good_packages = []
for package in mpl_packages:
if isinstance(package, str):
print_raw('')
print_raw(package.upper())
else:
try:
result = package.check()
if result is not None:
message = 'yes [%s]' % result
print_status(package.name, message)
except setupext.CheckFailed as e:
print_status(package.name, 'no [%s]' % str(e))
if not package.optional:
required_failed.append(package)
else:
good_packages.append(package)
if isinstance(package, setupext.OptionalBackendPackage):
if default_backend is None:
default_backend = package.name
print_raw('')


# Abort if any of the required packages can not be built.
if required_failed:
print_line()
print_message(
"The following required packages can not "
"be built: %s" %
', '.join(x.name for x in required_failed))
sys.exit(1)


# Now collect all of the information we need to build all of the
# packages.
for package in good_packages:
if isinstance(package, str):
continue
packages.extend(package.get_packages())
py_modules.extend(package.get_py_modules())
ext = package.get_extension()
if ext is not None:
ext_modules.append(ext)
data = package.get_package_data()
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())

# Write the default matplotlibrc file
if default_backend is None:
default_backend = 'svg'
if setupext.options['backend']:
default_backend = setupext.options['backend']
with open('matplotlibrc.template') as fd:
template = fd.read()
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
fd.write(template % {'backend': default_backend})


# Build in verbose mode if requested
if setupext.options['verbose']:
for mod in ext_modules:
mod.extra_compile_args.append('-DVERBOSE')


classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
Expand All @@ -181,47 +100,132 @@
'Topic :: Scientific/Engineering :: Visualization',
]


# Finally, pass this all along to distutils to do the heavy lifting.
distrib = setup(name="matplotlib",
version=__version__,
description="Python plotting package",
author="John D. Hunter, Michael Droettboom",
author_email="mdroe@stsci.edu",
url="http://matplotlib.org",
long_description="""
matplotlib strives to produce publication quality 2D graphics
for interactive graphing, scientific publishing, user interface
development and web application servers targeting multiple user
interfaces and hardcopy output formats. There is a 'pylab' mode
which emulates matlab graphics.
""",
download_url="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-{0}/matplotlib-{0}.tar.gz".format(__version__),
install_requires=['dateutils', 'tornado'],
license="BSD",
packages=packages,
platforms='any',
py_modules=py_modules,
ext_modules=ext_modules,
package_dir=package_dir,
package_data=package_data,
classifiers=classifiers,

# List third-party Python packages that we require< 8000 /td>
install_requires=install_requires,

# Automatically 2to3 source on Python 3.x
use_2to3=True,

# matplotlib has C/C++ extensions, so it's not zip safe.
# Telling setuptools this prevents it from doing an automatic
# check for zip safety.
zip_safe=False,

# Install our nose plugin so it will always be found
entry_points={
'nose.plugins.0.10': [
'KnownFailure = matplotlib.testing.noseclasses:KnownFailure'
]
},
)
# One doesn't normally see `if __name__ == '__main__'` blocks in a setup.py,
# however, this is needed on Windows to avoid creating infinite subprocesses
# when using multiprocessing.
if __name__ == '__main__':
# These are distutils.setup parameters that the various packages add
# things to.
packages = []
py_modules = []
ext_modules = []
package_data = {}
package_dir = {'': 'lib'}
install_requires = []
default_backend = None


# Go through all of the packages and figure out which ones we are
# going to build/install.
print_line()
print_raw("Edit setup.cfg to change the build options")

required_failed = []
good_packages = []
for package in mpl_packages:
if isinstance(package, str):
print_raw('')
print_raw(package.upper())
else:
try:
result = package.check()
if result is not None:
message = 'yes [%s]' % result
print_status(package.name, message)
except setupext.CheckFailed as e:
print_status(package.name, 'no [%s]' % str(e))
if not package.optional:
required_failed.append(package)
else:
good_packages.append(package)
if isinstance(package, setupext.OptionalBackendPackage):
if default_backend is None:
default_backend = package.name
print_raw('')


# Abort if any of the required packages can not be built.
if required_failed:
print_line()
print_message(
"The following required packages can not "
"be built: %s" %
', '.join(x.name for x in required_failed))
sys.exit(1)


# Now collect all of the information we need to build all of the
# packages.
for package in good_packages:
if isinstance(package, str):
continue
packages.extend(package.get_packages())
py_modules.extend(package.get_py_modules())
ext = package.get_extension()
if ext is not None:
ext_modules.append(ext)
data = package.get_package_data()
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())

# Write the default matplotlibrc file
if default_backend is None:
default_backend = 'svg'
if setupext.options['backend']:
default_backend = setupext.options['backend']
with open('matplotlibrc.template') as fd:
template = fd.read()
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
fd.write(template % {'backend': default_backend})


# Build in verbose mode if requested
if setupext.options['verbose']:
for mod in ext_modules:
mod.extra_compile_args.append('-DVERBOSE')


# Finally, pass this all along to distutils to do the heavy lifting.
distrib = setup(name="matplotlib",
version=__version__,
description="Python plotting package",
author="John D. Hunter, Michael Droettboom",
author_email="mdroe@stsci.edu",
url="http://matplotlib.org",
long_description="""
matplotlib strives to produce publication quality 2D graphics
for interactive graphing, scientific publishing, user interface
development and web application servers targeting multiple user
interfaces and hardcopy output formats. There is a 'pylab' mode
which em 6D40 ulates matlab graphics.
""",
license="BSD",
packages=packages,
platforms='any',
py_modules=py_modules,
ext_modules=ext_modules,
package_dir=package_dir,
package_data=package_data,
classifiers=classifiers,
download_url="https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-{0}/matplotlib-{0}.tar.gz".format(__version__),

# List third-party Python packages that we require
install_requires=install_requires,

# Automatically 2to3 source on Python 3.x
use_2to3=True,

# matplotlib has C/C++ extensions, so it's not zip safe.
# Telling setuptools this prevents it from doing an automatic
# check for zip safety.
zip_safe=False,

# Install our nose plugin so it will always be found
entry_points={
'nose.plugins.0.10': [
'KnownFailure = matplotlib.testing.noseclasses:KnownFailure'
]
},
)
21 changes: 21 additions & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,9 @@ class FreeType(SetupPackage):
name = "freetype"

def check(self):
if sys.platform == 'win32':
return "Unknown version"

status, output = getstatusoutput("freetype-config --version")
if status == 0:
version = output
Expand Down Expand Up @@ -885,6 +888,24 @@ def get_install_requires(self):
return ['python_dateutil']


class Tornado(SetupPackage):
name = "tornado"

def check(self):
try:
import tornado
except ImportError:
return (
"tornado was not found. It is required for the WebAgg "
"backend. pip/easy_install may attempt to install it "
"after matplotlib.")

return "using tornado version %s" % tornado.__version__

def get_install_requires(self):
return ['tornado']


class Pyparsing(SetupPackage):
name = "pyparsing"

Expand Down
0