--- id: locate version: "1.1.1" license: unclear license_treatment: unclear maintenance: abandoned --- # locate — Locate the file location of your current running script. License: unclear · Maintenance: abandoned · Downloads: 2.3M/mo ## What it is and what it does Locate is a small utility library that solves the problem of finding the directory of the currently running Python script and dynamically modifying the import search path relative to that location. It provides three main functions: `this_dir()` returns the directory of the executing script (or the current working directory in interactive sessions), while `append_sys_path()` and `prepend_sys_path()` allow you to add directories relative to the script location to Python's import path, either permanently or temporarily via context manager. The context manager implementation uses a tagged string subclass to safely track and remove insertions, so nested context managers won't corrupt the restoration. The package targets developers who organize their projects with custom modules stored alongside scripts and want those imports to work consistently whether the script runs directly, from a notebook, or from a REPL. It's inspired by Julia's approach to directory resolution. Since the package has no runtime dependencies and installs as a pure Python wheel, it has minimal friction—but it has been abandoned since mid-2023, so no further updates or fixes should be expected. Use it for: - Load custom modules stored in a sibling directory without modifying PYTHONPATH or installing them as packages - Write scripts that work identically whether run from the command line, Jupyter notebook, or interactive shell - Temporarily import from a local directory within a specific code block using a context manager ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides utilities to locate the current Python file's directory and modify sys.path relative to that location for importing from nearby modules. Yes, if you need a lightweight way to locate your script and manage relative imports without external dependencies. No, if you require ongoing maintenance or active support—the package is abandoned and will not receive updates. The unclear license is a secondary concern but worth clarifying before use in proprietary code. ## Install pip install locate uv add locate poetry add locate ## Installing locate Before you install: Low friction install with no runtime dependencies. However, the package is abandoned—last release was 2022-12-15 and last commit 2023-06-01—so it will not receive bug fixes or maintenance. License in practice: License treatment is unclear; the classifier lists 'Other/Proprietary License' but no SPDX identifier or raw license text is provided, making the actual terms of use ambiguous. Quickstart: import locate # Get the directory of the current script script_dir = locate.this_dir() # Temporarily add a relative path to sys.path with locate.prepend_sys_path("../modules"): pass Verify before relying: - Whether the 'Other/Proprietary License' classifier reflects actual licensing terms or is a placeholder - Whether the package works correctly with Python versions beyond 3.4 despite being abandoned since mid-2023 ## Package facts - License: not declared (unclear) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 2.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags get current script directory, relative path imports, sys.path manipulation, find running file location, dynamic module loading, import-management, path-utilities [View on SkillFed](https://skillfed.io/packages/locate) · [View on PyPI](https://pypi.org/project/locate/)