Python project template
Project description
python-projector: A collection of simple scripts to manage Python projects
🛠️ Installation
# install with pip
pip install python-projector
# install with uv tool
uv tool install python-projector
🚀 Usage
Find nearest pyproject.toml file with projector find-pyproject-toml
It will find the nearest pyproject.toml file in the current directory or its parent directories.
Get src/ directory with projector get-src-dir
It will read the pyproject.toml's tool.setuptools.packages.find.where setting.
If the configuration is not found, it will assume src/ as the default value.
[tool.setuptools.packages.find]
where = ["src"]
Apply uv pip compile with projector pip-compile
Background:
uv pip compileis a command that generates arequirements.txtfile from arequirements.infile.requirements.infile should contain the direct dependencies of the project, with dynamic versions.requirements.txtfile contains all dependencies with pinned versions.- This is a thin wrapper around the command to generate
requirements.txtfiles per architecture. - There exists
--universalflag to generate a universalrequirements.txtfile, but we don't use it. Instead, we just separate the files per architecture.- This is because it makes the requirements overly complicated to read and parse.
- There exists a better format called
uv.lockbut this is also more complicated to read and parse. - For now, we stick to the
requirements.txtformat for the sake of simplicity.
Usage:
First, configure in the pyproject.toml file:
[tool.projector.pip_compile]
requirements_in_dir = "deps"
requirements_out_dir = "deps/lock"
python_platforms = ["x86_64-manylinux_2_28", "aarch64-apple-darwin", "x86_64-apple-darwin"]
Then, run the command:
projector pip-compile
It will make deps/lock/{platform}/requirements*.txt files based on the deps/requirements*.in files.
Get minimum Python version with projector get-min-python-version
Given the pyproject.toml file:
[tool.project]
requires-python = ">=3.10,<4"
It will output the minimum Python version:
$ projector get-min-python-version
3.10
This is useful in CI where you want to run unit test etc. with the minimum Python version.
For example, in GitHub Actions:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Get minimum Python version
run: |
uv tool install python-projector
echo "min_python_version=$(projector get-min-python-version)" >> "$GITHUB_OUTPUT"
id: parse-python-version
- uses: actions/setup-python@v5
with:
python-version: ${{ steps.parse-python-version.outputs.min_python_version }}
# ...
Generate __init__.py files with projector gen-init-py
Generate __init__.py files recursively in the src/ directory found like projector get-src-dir.
This is useful for mkdocs because it requires __init__.py in all modules.
Run doctest with projector run-doctest
Run doctest with all modules in the src/ directory found like projector get-src-dir.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file python_projector-0.1.5.tar.gz.
File metadata
- Download URL: python_projector-0.1.5.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49e156a15fe15d94a93c878442d7321d715615d7dc7a3a656de127dd50859fa5
|
|
| MD5 |
105453c91c36418ef5f7a2f2c6a98709
|
|
| BLAKE2b-256 |
492089071c453aefcfc7350be65cc2eddfee4c45c63bd3eec82fd8ed4118b2e1
|