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.3.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

find_libpython-0.3.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: find_libpython-0.3.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for find_libpython-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4dd75e54c0828cfa8e97287565d2499a6bd6216140afdf251c87a456e8e52cd3
MD5 a30529e495a5509599459f51872ff0bb
BLAKE2b-256 7bdc31cc806e2a8843323cdff03329de66f990e4e6715781605ba14311a27a5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for find_libpython-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f63c2c05b9c6077bfafa5c7b283547b918a54c17fd930ceead487d1f220ff9cb
MD5 bdb951d0352f27552836287f568582fa
BLAKE2b-256 98e3db6c6be0863e0e81c7596f47b5f41449b78d7285de6f17bd8c5f40b6de37

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