A cross-platform python discovery tool to help locate python on any system.
Project description
Installation
Install from PyPI:
$ pipenv install --pre pythonfinder
Install from Github:
$ pipenv install -e git+https://github.com/sarugaku/pythonfinder.git#egg=pythonfinder
Usage
Using PythonFinder is easy. Simply import it and ask for a python:
>>> from pythonfinder.pythonfinder import PythonFinder >>> PythonFinder.from_line('python3') '/home/techalchemy/.pyenv/versions/3.6.5/python3' >>> from pythonfinder import Finder >>> f = Finder() >>> f.find_python_version(3, minor=6) PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.6.5/bin/python'), _children={}, is_root=False, only_python=False, py_version=PythonVersion(major=3, minor=6, patch=5, is_prerelease=False, is_postrelease=False, is_devrelease=False, version=<Version('3.6.5')>, architecture='64bit', comes_from=PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.6.5/bin/python'), _children={}, is_root=True, only_python=False, py_version=None, pythons=None), executable=None), pythons=None) >>> f.find_python_version(2) PathEntry(path=PosixPath('/home/hawk/.pyenv/shims/python2'), _children={}, is_root=False, only_python=False, py_version=PythonVersion(major=2, minor=7, patch=15, is_prerelease=False, is_postrelease=False, is_devrelease=False, version=<Version('2.7.15')>, architecture='64bit', comes_from=PathEntry(path=PosixPath('/home/hawk/.pyenv/shims/python2'), _children={}, is_root=True, only_python=False, py_version=None, pythons=None), executable=None), pythons=None)
PythonFinder can even find beta releases!
>>> f.find_python_version(3, minor=7) PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.7.0b1/bin/python'), _children={}, is_root=False, only_python=False, py_version=PythonVersion(major=3, minor=7, patch=0, is_prerelease=True, is_postrelease=False, is_devrelease=False, version=<Version('3.7.0b1')>, architecture='64bit', comes_from=PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.7.0b1/bin/python'), _children={}, is_root=True, only_python=False, py_version=None, pythons=None), executable=None), pythons=None) >>> f.which('python') PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.6.5/bin/python'), _children={}, is_root=False, only_python=False, py_version=PythonVersion(major=3, minor=6, patch=5, is_prerelease=False, is_postrelease=False, is_devrelease=False, version=<Version('3.6.5')>, architecture='64bit', comes_from=PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.6.5/bin/python'), _children={}, is_root=True, only_python=False, py_version=None, pythons=None), executable=None), pythons=None)
Windows Support
PythonFinder natively supports windows via both the PATH environment variable and PEP-514 compliant finder which comes by default with python 3. Usage on windows becomes:
>>> from pythonfinder import Finder >>> f = Finder() >>> f.find_python_version(3, minor=6) PythonVersion(major=3, minor=6, patch=4, is_prerelease=False, is_postrelease=False, is_devrelease=False, version=<Version('3.6.4')>, architecture='64bit', comes_from=PathEntry(path=WindowsPath('C:/Program Files/Python36/python.exe'), _children={}, is_root=False, only_python=True, py_version=None, pythons=None), executable=WindowsPath('C:/Program Files/Python36/python.exe')) >>> f.find_python_version(3, minor=7, pre=True) PythonVersion(major=3, minor=7, patch=0, is_prerelease=True, is_postrelease=False, is_devrelease=False, version=<Version('3.7.0b5')>, architecture='64bit', comes_from=PathEntry(path=WindowsPath('C:/Program Files/Python37/python.exe'), _children={}, is_root=False, only_python=True, py_version=None, pythons=None), executable=WindowsPath('C:/Program Files/Python37/python.exe')) >>> f.which('python') PathEntry(path=WindowsPath('C:/Python27/python.exe'), _children={}, is_root=False, only_python=False, py_version=None, pythons=None)
Finding Executables
PythonFinder also provides which functionality across platforms, and it uses lazy loading and fast-returns to be performant at this task.
>>> f.which('cmd') PathEntry(path=WindowsPath('C:/windows/system32/cmd.exe'), _children={}, is_root=False, only_python=False, py_version=None, pythons=None) >>> f.which('code') PathEntry(path=WindowsPath('C:/Program Files/Microsoft VS Code/bin/code'), _children={}, is_root=False, only_python=False, py_version=None, pythons=None) >>> f.which('vim') PathEntry(path=PosixPath('/usr/bin/vim'), _children={}, is_root=False, only_python=False, py_version=None, pythons=None) >>> f.which('inv') PathEntry(path=PosixPath('/home/hawk/.pyenv/versions/3.6.5/bin/inv'), _children={}, is_root=False, only_python=False, py_version=None, pythons=None)
Architecture support
PythonFinder supports architecture specific lookups on all platforms (coming soon):
Integrations
Project details
Release history Release notifications | RSS feed
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 pythonfinder-1.1.3.tar.gz
.
File metadata
- Download URL: pythonfinder-1.1.3.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46e55a692cf0bae30bcf35a89acaf667efda5b2280f2cc364e484633c93b4e06 |
|
MD5 | 9782831aa420f5eba6a94b2f05b76baf |
|
BLAKE2b-256 | a9d308a41d7615f19be5e2aca78f39827d5e71db95be9995e158766808634df5 |
Provenance
File details
Details for the file pythonfinder-1.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: pythonfinder-1.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99d8a136d7f3568842099811ddd73d04a735ffa9a3ee73a3bde6d965d370e396 |
|
MD5 | 02b4f30e7c504e3ed616a8ca51a2434f |
|
BLAKE2b-256 | 9033985dc61afd9ea8afb63968f911c6d5d8e9d3c44522874abd8dbe2eafdb50 |