Finds the libpython associated with your environment, wherever it may be hiding
Project description
find_libpython
A pypi project version of this gist, which also appears within the PyCall library.
The library is designed to find the path to the libpython dynamic library for the current Python environment. It should work with many types of installations, whether it be conda-managed, system-managed, or otherwise. And it should function on Windows, Mac OS/OS X, and any Linux distribution.
This code is useful in several contexts, including projects that embed a Python interpreter into another process, or Python library build systems.
Usage
find_libpython
is both a script and a Python package.
Usage as a script is useful in contexts like obtaining the path to libpython for linking in makefile-based build systems.
It could also be used to determine the path to libpython for embedding a Python interpreter in a process written in another language.
In that case the recommended usage is to simply call the script in a subprocess with no arguments and parse the output.
> find_libpython
/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0
The full help message:
> find_libpython --help
usage: find_libpython [-h] [--verbose] [--list-all | --candidate-names | --candidate-paths]
Locate libpython associated with this Python executable.
optional arguments:
-h, --help show this help message and exit
--verbose, -v Print debugging information.
--list-all Print list of all paths found.
--candidate-names Print list of candidate names of libpython.
--candidate-paths Print list of candidate paths of libpython.
Usage as a library might occur when you need to obtain the path to the library in a Python-based build system like distutils.
It is recommended to use the find_libpython
method which will return the path to libpython as a string, or None
if it cannot be found.
>>> from find_libpython import find_libpython
>>> find_libpython()
'/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file find_libpython-0.1.1.tar.gz
.
File metadata
- Download URL: find_libpython-0.1.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc8cb7c332f9beb84b193dcb0c3f1b8ce47bf713c04ae49d0ae009b9a39cd4dc |
|
MD5 | b3364dcedc7301a9a070428295852a2a |
|
BLAKE2b-256 | 161705b4eef982cb9231ff26a8b27c7cccb412a8d7cab24aaa64b82e0b169c3b |
File details
Details for the file find_libpython-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: find_libpython-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d89e0af368ead1115b3ee7dc1832b3e6947a7e422be475bc0f1a31eb279c7214 |
|
MD5 | 84ff668e7cb33ef08917df7f819bc01c |
|
BLAKE2b-256 | 4c4b0a6d499fe09d1fb159dcec023ae6f0f217fdafffd15ab47ee1d2cb2ab78c |