8000 This adds a workaround for https://github.com/matplotlib/matplotlib/p… · embray/astropy_helpers@642da87 · GitHub
[go: up one dir, main page]

Skip to content

Commit 642da87

Browse files
committed
This adds a workaround for matplotlib/matplotlib#4165 and also rearranged imports a little bit.
1 parent 0c2678a commit 642da87

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

ah_bootstrap.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
_text_type = str
5757
PY3 = True
5858

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+
5965
# Some pre-setuptools checks to ensure that either distribute or setuptools >=
6066
# 0.7 is used (over pre-distribute setuptools) if it is available on the path;
6167
# otherwise the latest setuptools will be downloaded and bootstrapped with
@@ -84,16 +90,6 @@
8490
from ez_setup import use_setuptools
8591
use_setuptools()
8692

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
9793

9894
# Note: The following import is required as a workaround to
9995
# https://github.com/astropy/astropy-helpers/issues/89; if we don't import this
@@ -105,6 +101,35 @@
105101
except ImportError:
106102
pass
107103

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+
108133
# TODO: Maybe enable checking for a specific version of astropy_helpers?
109134
DIST_NAME = 'astropy-helpers'
110135
PACKAGE_NAME = 'astropy_helpers'

0 commit comments

Comments
 (0)
0