BLD: __SKIMAGE_SETUP__ global variable for detecting build

The __SKIMAGE_SETUP__ global variable is set to True if skimage is being build
from the main setup.py file, False if not.  This behavior is modeled after a
similar setup in scikit-learn
This commit is contained in:
Jonathan Helmus
2015-07-21 13:06:33 -05:00
parent edc16c6b75
commit 64c4252eab
2 changed files with 30 additions and 1 deletions
+13
View File
@@ -24,6 +24,19 @@ import sys
import setuptools
from distutils.command.build_py import build_py
if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins
# This is a bit (!) hackish: we are setting a global variable so that the main
# skimage __init__ can detect if it is being loaded by the setup routine, to
# avoid attempting to load components that aren't built yet:
# the numpy distutils extensions that are used by scikit-image to recursively
# build the compiled extensions in sub-packages is based on the Python import
# machinery.
builtins.__SKIMAGE_SETUP__ = True
with open('skimage/__init__.py') as fid:
for line in fid: