mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 19:48:43 +08:00
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:
@@ -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:
|
||||
|
||||
+17
-1
@@ -56,6 +56,7 @@ img_as_ubyte
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os.path as osp
|
||||
import imp
|
||||
import functools
|
||||
@@ -111,4 +112,19 @@ doctest_verbose.__doc__ = doctest.__doc__
|
||||
|
||||
del warnings, functools, osp, imp
|
||||
|
||||
from . import __check_build
|
||||
try:
|
||||
# This variable is injected in the __builtins__ by the build
|
||||
# process. It used to enable importing subpackages of skimage when
|
||||
# the binaries are not built
|
||||
__SKIMAGE_SETUP__
|
||||
except NameError:
|
||||
__SKIMAGE_SETUP__ = False
|
||||
|
||||
if __SKIMAGE_SETUP__:
|
||||
sys.stderr.write('Partial import of skimage during the build process.\n')
|
||||
# We are not importing the rest of the scikit during the build
|
||||
# process, as it may not be compiled yet
|
||||
else:
|
||||
from . import __check_build
|
||||
from .util.dtype import *
|
||||
__check_build # avoid flakes unused varaible error
|
||||
|
||||
Reference in New Issue
Block a user