Skip to main content

pyhere

Build Status Latest pypi version

A Python 2.x / 3.x equivalent of R's here package, drawing inspiration from chendaniely's pyprojroot package, but more closely mirroring the functionality within R's here. Relative file referencing has never been easier!

For complete information, check out the docs.

Installation

pip

You can install the latest stable version with pip via:

pip install pyhere

And if you want to be on the bleeding edge of development, get the latest version from github:

pip install --editable=git+https://github.com/wildland-creative/pyhere.git#egg=pyhere

conda

Not in conda - just install it from pip in your environment.

Usage

from pyhere import here

relative_dirA = here("your", "relative", "directory", "file.txt")
relative_dirB = here("your/relative/directory/file.txt")

pyhere uses simple heuristics to find a project's root directory. From Path.cwd(), it traverses upwards, looking for a possible root_indicator:

root_indicators = [
    ".here",
    "requirements.txt",
    "setup.py",
    ".vscode", # vscode project
    ".idea", # pycharm project
    ".git",
    ".spyderproject", # spyder
    ".spyproject", # spyder
    ".ropeproject" # rope
]

When found, it joins the arguments passed to here() to the rootpath and returns as a Path object. If it reaches the system root, it returns the system root and throws a warning.

For a concrete example, imagine the following directory structure:

\project\src\script.py
\project\data\data1.csv
\project\.here

If you call

data = here("data", "data1.csv")

from script.py, you'll get a Path object representing \project\data\data1.csv.

Changelog

Changelog is over here.

Metadata

Release files for pyhere 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhere 1.0.3
File Size Uploaded Provenance Actions
pyhere-1.0.3.tar.gz 4.3 kB Without provenance Details for pyhere-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyhere 1.0.3
File Interpreter ABI Platform Actions
pyhere-1.0.3-py3-none-any.whl Python 3 none any Details for pyhere-1.0.3-py3-none-any.whl

Total release size: 8.7 kB

Release files / pyhere-1.0.3.tar.gz

Download URL pyhere-1.0.3.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dbea60e83cbcaef41c4da429c1372b7780c580bc0714801c6c5957df06208cdf
BLAKE2b-256 checksum
How to use checksums
34e279dca2aa113e3be3bac013ec3c6d21fde79783f62866312012d787026e0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.3

Release files / pyhere-1.0.3-py3-none-any.whl

Download URL pyhere-1.0.3-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c39f5ab806d332ce9812b74e4486c0753e2c5416265758c7251f1bbe0946f69
BLAKE2b-256 checksum
How to use checksums
04e680f613b0f6d5079950083f274f2f19a2bf2870c0376ccd4a63851ef53f43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.3

Security for pyhere 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page