# find_libpython
A pypi project version of [this](https://gist.github.com/tkf/d980eee120611604c0b9b5fef5b8dae6) gist, which also appears
within the [PyCall](https://github.com/JuliaPy/PyCall.jl/blob/master/deps/find_libpython.py) 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] [-v] [--list-all | --candidate-names | --candidate-paths | --platform-info | --version]
Locate libpython associated with this Python executable.
options:
-h, --help show this help message and exit
-v, --verbose 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.
--platform-info Print information about the platform and exit.
--version show program's version number and exit
```
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.
```python
>>> from find_libpython import find_libpython
>>> find_libpython()
'/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ktbarrett/find_libpython",
"name": "find-libpython",
"maintainer": "Kaleb Barrett",
"docs_url": null,
"requires_python": "",
"maintainer_email": "dev.ktbarrett@gmail.com",
"keywords": "libpython",
"author": "Takafumi Arakaki",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/db/86/b1d3a9c49d907cac74f9d8bcead2c8e807a878c0e218d8ef1d38e6a4f59a/find_libpython-0.4.0.tar.gz",
"platform": null,
"description": "# find_libpython\n\nA pypi project version of [this](https://gist.github.com/tkf/d980eee120611604c0b9b5fef5b8dae6) gist, which also appears\nwithin the [PyCall](https://github.com/JuliaPy/PyCall.jl/blob/master/deps/find_libpython.py) library.\n\nThe library is designed to find the path to the libpython dynamic library for the current Python environment.\nIt should work with many types of installations, whether it be conda-managed, system-managed, or otherwise.\nAnd it should function on Windows, Mac OS/OS X, and any Linux distribution.\n\nThis code is useful in several contexts, including projects that embed a Python interpreter into another process,\nor Python library build systems.\n\n## Usage\n\n`find_libpython` is both a script and a Python package.\nUsage as a script is useful in contexts like obtaining the path to libpython for linking in makefile-based build systems.\nIt could also be used to determine the path to libpython for embedding a Python interpreter in a process written in another language.\nIn that case the recommended usage is to simply call the script in a subprocess with no arguments and parse the output.\n\n```\n> find_libpython\n/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0\n```\n\nThe full help message:\n```\n> find_libpython --help\nusage: find_libpython [-h] [-v] [--list-all | --candidate-names | --candidate-paths | --platform-info | --version]\n\nLocate libpython associated with this Python executable.\n\noptions:\n -h, --help show this help message and exit\n -v, --verbose Print debugging information.\n --list-all Print list of all paths found.\n --candidate-names Print list of candidate names of libpython.\n --candidate-paths Print list of candidate paths of libpython.\n --platform-info Print information about the platform and exit.\n --version show program's version number and exit\n```\n\nUsage as a library might occur when you need to obtain the path to the library in a Python-based build system like distutils.\nIt 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.\n\n```python\n>>> from find_libpython import find_libpython\n>>> find_libpython()\n'/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0'\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Finds the libpython associated with your environment, wherever it may be hiding",
"version": "0.4.0",
"project_urls": {
"Homepage": "https://github.com/ktbarrett/find_libpython"
},
"split_keywords": [
"libpython"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1d896b4624122d5c61a86e8aebcebd377866338b705ce4f115c45b046dc09b99",
"md5": "86e2ba64be1afcce6acf0162e36be42a",
"sha256": "034a4253bd57da3408aefc59aeac1650150f6c1f42e10fdd31615cf1df0842e3"
},
"downloads": -1,
"filename": "find_libpython-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "86e2ba64be1afcce6acf0162e36be42a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8670,
"upload_time": "2024-03-13T17:01:09",
"upload_time_iso_8601": "2024-03-13T17:01:09.712061Z",
"url": "https://files.pythonhosted.org/packages/1d/89/6b4624122d5c61a86e8aebcebd377866338b705ce4f115c45b046dc09b99/find_libpython-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "db86b1d3a9c49d907cac74f9d8bcead2c8e807a878c0e218d8ef1d38e6a4f59a",
"md5": "d3ec28ac310cdd53c6959b9663d26d27",
"sha256": "46f9cdcd397ddb563b2d7592ded3796a41c1df5222443bd9d981721c906c03e6"
},
"downloads": -1,
"filename": "find_libpython-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "d3ec28ac310cdd53c6959b9663d26d27",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8979,
"upload_time": "2024-03-13T17:01:10",
"upload_time_iso_8601": "2024-03-13T17:01:10.727108Z",
"url": "https://files.pythonhosted.org/packages/db/86/b1d3a9c49d907cac74f9d8bcead2c8e807a878c0e218d8ef1d38e6a4f59a/find_libpython-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-13 17:01:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ktbarrett",
"github_project": "find_libpython",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "find-libpython"
}