Fix CI failures
1 | 20 |
try: |
2 | 20 |
from .version import version as __version__ |
3 | 20 |
from .version import githash as __githash__ |
4 |
except ImportError: |
|
5 |
__version__ = '' |
|
6 |
__githash__ = '' |
|
7 |
|
|
8 |
|
|
9 |
# If we've made it as far as importing astropy_helpers, we don't need
|
|
10 |
# ah_bootstrap in sys.modules anymore. Getting rid of it is actually necessary
|
|
11 |
# if the package we're installing has a setup_requires of another package that
|
|
12 |
# uses astropy_helpers (and possibly a different version at that)
|
|
13 |
# See https://github.com/astropy/astropy/issues/3541
|
|
14 | 20 |
import sys |
15 | 20 |
if 'ah_bootstrap' in sys.modules: |
16 |
del sys.modules['ah_bootstrap'] |
|
17 |
|
|
18 |
|
|
19 |
# Note, this is repeated from ah_bootstrap.py, but is here too in case this
|
|
20 |
# astropy-helpers was upgraded to from an older version that did not have this
|
|
21 |
# check in its ah_bootstrap.
|
|
22 |
# matplotlib can cause problems if it is imported from within a call of
|
|
23 |
# run_setup(), because in some circumstances it will try to write to the user's
|
|
24 |
# home directory, resulting in a SandboxViolation. See
|
|
25 |
# https://github.com/matplotlib/matplotlib/pull/4165
|
|
26 |
# Making sure matplotlib, if it is available, is imported early in the setup
|
|
27 |
# process can mitigate this (note importing matplotlib.pyplot has the same
|
|
28 |
# issue)
|
|
29 | 20 |
try: |
30 | 20 |
import matplotlib |
31 | 11 |
matplotlib.use('Agg') |
32 | 11 |
import matplotlib.pyplot |
33 | 9 |
except: |
34 |
# Ignore if this fails for *any* reason*
|
|
35 | 9 |
pass
|
36 |
|
|
37 |
|
|
38 | 20 |
import os |
39 |
# Ensure that all module-level code in astropy or other packages know that
|
|
40 |
# we're in setup mode:
|
|
41 | 20 |
if ('__main__' in sys.modules and |
42 |
hasattr(sys.modules['__main__'], '__file__')): |
|
43 | 20 |
filename = os.path.basename(sys.modules['__main__'].__file__) |
44 |
|
|
45 | 20 |
if filename.rstrip('co') == 'setup.py': |
46 | 20 |
import builtins |
47 | 20 |
builtins._ASTROPY_SETUP_ = True |
48 |
|
|
49 | 20 |
del filename |
Read our documentation on viewing source code .