|
56 | 56 | _text_type = str
|
57 | 57 | PY3 = True
|
58 | 58 |
|
| 59 | + |
| 60 | +# What follows are several import statements meant to deal with install-time |
| 61 | +# issues with either missing or misbehaving pacakges (including making sure |
| 62 | +# setuptools itself is installed): |
| 63 | + |
| 64 | + |
59 | 65 | # Some pre-setuptools checks to ensure that either distribute or setuptools >=
|
60 | 66 | # 0.7 is used (over pre-distribute setuptools) if it is available on the path;
|
61 | 67 | # otherwise the latest setuptools will be downloaded and bootstrapped with
|
|
84 | 90 | from ez_setup import use_setuptools
|
85 | 91 | use_setuptools()
|
86 | 92 |
|
87 |
| -from distutils import log |
88 |
| -from distutils.debug import DEBUG |
89 |
| - |
90 |
| - |
91 |
| -# In case it didn't successfully import before the ez_setup checks |
92 |
| -import pkg_resources |
93 |
| - |
94 |
| -from setuptools import Distribution |
95 |
| -from setuptools.package_index import PackageIndex |
96 |
| -from setuptools.sandbox import run_setup |
97 | 93 |
|
98 | 94 | # Note: The following import is required as a workaround to
|
99 | 95 | # https://github.com/astropy/astropy-helpers/issues/89; if we don't import this
|
|
105 | 101 | except ImportError:
|
106 | 102 | pass
|
107 | 103 |
|
| 104 | + |
| 105 | +# matplotlib can cause problems if it is imported from within a call of |
| 106 | +# run_setup(), because in some circumstances it will try to write to the user's |
| 107 | +# home directory, resulting in a SandboxViolation. See |
| 108 | +# https://github.com/matplotlib/matplotlib/pull/4165 |
| 109 | +# Making sure matplotlib, if it is available, is imported early in the setup |
| 110 | +# process can mitigate this (note importing matplotlib.pyplot has the same |
| 111 | +# issue) |
| 112 | +try: |
| 113 | + import matplotlib.pyplot |
| 114 | +except: |
| 115 | + # Ignore if this fails for *any* reason* |
| 116 | + pass |
| 117 | + |
| 118 | + |
| 119 | +# End compatibility imports... |
| 120 | + |
| 121 | + |
| 122 | +# In case it didn't successfully import before the ez_setup checks |
| 123 | +import pkg_resources |
| 124 | + |
| 125 | +from setuptools import Distribution |
| 126 | +from setuptools.package_index import PackageIndex |
| 127 | +from setuptools.sandbox import run_setup |
| 128 | + |
| 129 | +from distutils import log |
| 130 | +from distutils.debug import DEBUG |
| 131 | + |
| 132 | + |
108 | 133 | # TODO: Maybe enable checking for a specific version of astropy_helpers?
|
109 | 134 | DIST_NAME = 'astropy-helpers'
|
110 | 135 | PACKAGE_NAME = 'astropy_helpers'
|
|
0 commit comments