Create symlinks to python package directories
Project description
pkglink
Create symlinks to python package directories from PyPI packages or GitHub repos into your current working directory.
⚠️ Requirements
This tool requires uv to be installed on your system.
pkglink depends entirely on the uv package
manager for all installation and authentication tasks. uv handles:
- Package installation from PyPI
- GitHub repository handling
- Authentication for private repositories
- Dependency resolution and caching
- Environment isolation via
uvx
Install uv first:
# Install uv (see https://docs.astral.sh/uv/getting-started/installation/)
curl -LsSf https://astral.sh/uv/install.sh | sh
Overview
pkglink is a CLI tool designed for configuration sharing and quick access to
package resources. It allows you to symlink specific directories (like
resources, configs, templates) from Python packages directly into your
current directory without having to install them globally or manually download
files.
Installation
Using uvx (Recommended)
Once published, you can use pkglink directly with uvx without installation:
# Use a specific subdirectory from a package
uvx pkglink --from tbelt toolbelt resources
# Symlink with a custom name
uvx pkglink --symlink-name .codeguide tbelt resources
Local Installation
For development or repeated use:
pip install pkglink
Usage
Basic Examples
# Symlink the 'resources' directory from 'mypackage'
pkglink mypackage resources
# Use --from to install one package but link from another module
pkglink --from tbelt toolbelt resources
# Specify a custom symlink name
pkglink --symlink-name .configs mypackage configs
# Dry run to see what would happen
pkglink --dry-run mypackage templates
# Force overwrite existing symlinks
pkglink --force mypackage resources
Command Line Options
source: The package to install (can be PyPI package or GitHub repo)directory: The subdirectory within the package to symlink (default: "resources")--from PACKAGE: Install one package but look for the module in another (useful when the PyPI package name differs from the Python module name)--symlink-name NAME: Custom name for the symlink (default:.{source})--force: Overwrite existing symlinks/directories--dry-run: Show what would be done without making changes--verbose: Enable verbose logging
Note: If the target symlink already exists, pkglink will skip the
operation and exit successfully (unless --force is used). This makes it safe
to run in setup scripts multiple times.
Advanced Usage
# GitHub repositories
pkglink user/repo configs
# Specific versions
pkglink mypackage==1.2.0 resources
# With custom names and force overwrite
pkglink --symlink-name .my-configs --force mypackage configs
How It Works
pkglink leverages uv's powerful package management capabilities through its
uvx tool:
1. uvx Integration
- Package Installation: Uses
uvx(part ofuv) to install packages in isolated environments - Dependency Resolution: Leverages
uv's robust dependency handling and authentication - Environment Isolation: Each package gets proper isolation via
uvx - Authentication: Inherits all
uvauthentication for private repositories
2. Intelligent Caching
- Location:
~/.cache/pkglink/{package}_{hash}/ - Persistence: Survives
uvxcleanup operations - Performance: Subsequent runs are near-instantaneous
- Hash-based: Each unique package specification gets its own cache directory
3. Package Discovery
pkglink uses multiple strategies to find the correct package directory after
installation:
- Exact Match: Direct directory name matching
- Python Package Detection: Looks for directories with
__init__.py - Resource Directory Detection: Finds directories containing a
resourcesfolder - Prefix/Suffix Matching: Flexible name matching
- Similarity Matching: Fuzzy matching for close names
- Fallback: Uses the first suitable directory
Use Cases
Configuration Sharing
# Share configuration templates across projects
pkglink --symlink-name .eslintrc my-configs eslint
pkglink --symlink-name .github my-configs github-workflows
Resource Access
# Access package resources for development
pkglink --from data-science-toolkit datasets data
pkglink ml-models pretrained
Template Management
# Quick access to project templates
pkglink project-templates react
pkglink --symlink-name .templates cookiecutter-templates django
Benefits
- Fast: Leverages
uvxcaching + additional persistent caching - Reliable: Uses
uv's robust package installation with multiple fallback strategies for package discovery - Flexible: Supports PyPI packages, GitHub repos, and local paths
- Safe: Dry-run mode and intelligent conflict detection
- Convenient: Can be used with
uvxwithout installation - Authenticated: Inherits all
uvauthentication for private repositories
Requirements
uv(required) - Handles all package installation and authentication- Python 3.11+
uvx(part ofuv, used for package installation)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkglink-0.0.1.tar.gz.
File metadata
- Download URL: pkglink-0.0.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304bff9a9d1a765f5bb807faf0ae6e69013dec22ac7cb6ad775b1a4544a85b28
|
|
| MD5 |
71d6c894cd80706b1fafc7279d56d6e1
|
|
| BLAKE2b-256 |
73e1dd83a98ac32a7a3615bca4e25dabdab02fb478a71d36f52cabec9fc0d72f
|
File details
Details for the file pkglink-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pkglink-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16cbb84b4c0e70c00d303e4fd27e920729fc06d309c922747197fed70f51877a
|
|
| MD5 |
84d495615bbc6c02da541fb3977481de
|
|
| BLAKE2b-256 |
61973bd13120e8e0101eac22f29d055e3fa77b88030193e49f69804a6cfc6f65
|