Skip to main content

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

find_libpython-0.2.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

find_libpython-0.2.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file find_libpython-0.2.0.tar.gz.

File metadata

  • Download URL: find_libpython-0.2.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for find_libpython-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aba5d41aa4c3e245a536d397a5f0e0c12c20e7ab2ada398c4ab07ff685f91ff9
MD5 86a3ba96f84d4b70ce377dd8b9b1f3e9
BLAKE2b-256 3da51e2a3b154eb9b8218a6c865faac0dce21a61bddafc0eed76d8a0c9e0ade0

See more details on using hashes here.

File details

Details for the file find_libpython-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: find_libpython-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for find_libpython-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 857e7207d6b5aabd8e05419a67a2003efc43f2986fb02766932bd91a50a76ea8
MD5 268282bb112cffb8a154d4dcca380ac4
BLAKE2b-256 f7f2b3d9906fabf1498cb6901c92dbd87754a840eedd751888d12dc0d9e73282

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page