Add option for inhibiting the core build while installing the python components. Add option for loading the core from a custom path. (#1089)
This commit is contained in:
parent
0f3dc67430
commit
3eed64c219
|
@ -8,10 +8,18 @@ compile C code. On Linux, this is usually easy, but on Windows, this involves
|
||||||
installing Visual Studio and using the "Developer Command Prompt" to perform the
|
installing Visual Studio and using the "Developer Command Prompt" to perform the
|
||||||
installation. See BUILDING.txt for more information.
|
installation. See BUILDING.txt for more information.
|
||||||
|
|
||||||
|
By default, attempting to install the python bindings will trigger a build of
|
||||||
|
the capstone native core. If this is undesirable for whatever reason, for
|
||||||
|
instance, you already have a globally installed copy of libcapstone, you may
|
||||||
|
inhibit the build by setting the environment variable LIBCAPSTONE_PATH. The
|
||||||
|
exact value is not checked, just setting it will inhibit the build. During
|
||||||
|
execution, this variable may be set to the path of a directory containing a
|
||||||
|
specific version of libcapstone you would like to use.
|
||||||
|
|
||||||
If you don't want to build your own copy of Capstone, you can use a precompiled
|
If you don't want to build your own copy of Capstone, you can use a precompiled
|
||||||
binary distribution from PyPI. Saying `pip install capstone` should
|
binary distribution from PyPI. Saying `pip install capstone` should
|
||||||
automatically obtain an appropriate copy for your system. If it does not, please
|
automatically obtain an appropriate copy for your system. If it does not, please
|
||||||
open an issue at https://github.com/aquynh/capstone and tag @rhelmot - they
|
open an issue at https://github.com/aquynh/capstone and tag @rhelmot - she
|
||||||
will fix this, probably!
|
will fix this, probably!
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -293,19 +293,22 @@ def _load_lib(path):
|
||||||
_cs = None
|
_cs = None
|
||||||
|
|
||||||
# Loading attempts, in order
|
# Loading attempts, in order
|
||||||
|
# - user-provided environment variable
|
||||||
# - pkg_resources can get us the path to the local libraries
|
# - pkg_resources can get us the path to the local libraries
|
||||||
# - we can get the path to the local libraries by parsing our filename
|
# - we can get the path to the local libraries by parsing our filename
|
||||||
# - global load
|
# - global load
|
||||||
# - python's lib directory
|
# - python's lib directory
|
||||||
# - last-gasp attempt at some hardcoded paths on darwin and linux
|
# - last-gasp attempt at some hardcoded paths on darwin and linux
|
||||||
|
|
||||||
_path_list = [pkg_resources.resource_filename(__name__, 'lib'),
|
_path_list = [os.getenv('LIBCAPSTONE_PATH', None),
|
||||||
|
pkg_resources.resource_filename(__name__, 'lib'),
|
||||||
join(split(__file__)[0], 'lib'),
|
join(split(__file__)[0], 'lib'),
|
||||||
'',
|
'',
|
||||||
distutils.sysconfig.get_python_lib(),
|
distutils.sysconfig.get_python_lib(),
|
||||||
"/usr/local/lib/" if sys.platform == 'darwin' else '/usr/lib64']
|
"/usr/local/lib/" if sys.platform == 'darwin' else '/usr/lib64']
|
||||||
|
|
||||||
for _path in _path_list:
|
for _path in _path_list:
|
||||||
|
if _path is None: continue
|
||||||
_cs = _load_lib(_path)
|
_cs = _load_lib(_path)
|
||||||
if _cs is not None: break
|
if _cs is not None: break
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -159,8 +159,11 @@ class custom_sdist(sdist):
|
||||||
|
|
||||||
class custom_build(build):
|
class custom_build(build):
|
||||||
def run(self):
|
def run(self):
|
||||||
log.info('Building C extensions')
|
if 'LIBCAPSTONE_PATH' in os.environ:
|
||||||
build_libraries()
|
log.info('Skipping building C extensions since LIBCAPSTONE_PATH is set')
|
||||||
|
else:
|
||||||
|
log.info('Building C extensions')
|
||||||
|
build_libraries()
|
||||||
return build.run(self)
|
return build.run(self)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue