Skip to main content

Execute scripts from pyproject.toml, installing tools on-the-fly

Project description

pyprojectx

Pyprojectx: All-inclusive Python Projects

Execute scripts from pyproject.toml, installing tools on-the-fly

Full documentation

Introduction

Pyprojectx makes it easy to create all-inclusive Python projects; no need to install any tools upfront, not even Pyprojectx itself!

Tools that are specified within your pyproject.toml file will be installed on demand when invoked from Pyprojectx:

> ./pw ruff check src
Installed 1 package in 149ms
 + ruff==0.12.7

All checks passed!

Feature highlights

  • Reproducible builds by treating tools and utilities as (locked) dev-dependencies
  • No global installs, everything is stored inside your project directory (like npm's node_modules)
  • Bootstrap your entire build process with a small wrapper script (like Gradle's gradlew wrapper)
  • Configure shortcuts for routine tasks
  • Simple configuration in pyproject.toml

Projects can be build/tested/used immediately without explicit installation nor initialization:

git clone https://github.com/pyprojectx/px-demo.git
cd px-demo
./pw build

Clone and Build

Installation

One of the key features is that there is no need to install anything explicitly (except a Python 3.9+ interpreter).

cd into your project directory and download the wrapper scripts:

Linux/Mac

curl -LO https://github.com/pyprojectx/pyprojectx/releases/latest/download/wrappers.zip && unzip wrappers.zip && rm -f wrappers.zip

Windows

Invoke-WebRequest https://github.com/pyprojectx/pyprojectx/releases/latest/download/wrappers.zip -OutFile wrappers.zip; Expand-Archive -Path wrappers.zip -DestinationPath .; Remove-Item -Path wrappers.zip

Getting started

Initialize a new or existing project by adding tools (on Windows, replace ./pw with pw):

./pw --add uv,ruff,pre-commit,px-utils
./pw --install-context main
# invoke a tool via the wrapper script
./pw uv --version
./pw ruff check src
# or activate the tool context
source .pyprojectx/main/activate
uv --version
ruff check src

For reproducible builds and developer experience, it is recommended to lock the versions of the tools and add the generated pw.lock file to your repository:

./pw --lock

Create command shortcuts

The tool.pyprojectx.aliases section in pyproject.toml can contain commandline aliases:

[tool.pyprojectx.aliases]
# convenience shortcuts
run = "uv run"
test = "uv run pytest"
lint = ["ruff check"]
check = ["@lint", "@test"]

Usage

Instead of calling the CLI of a tool directly, prefix it with ./pw (pw on Windows).

Examples:

./pw uv add --dev pytest
cd src
../pw lint

Aliases can be invoked as is or with extra arguments:

./pw uv run my-script --foo bar
# same as above, but using the run alias
./pw run my-script --foo bar

Why yet another tool?

  • As Python noob I had hard times setting up a project and building existing projects
  • There is always someone in the team having issues with his setup, either with a specific tool, with Homebrew, pipx, ...
  • Using (uv, PDM or Poetry) dev-dependencies to install tools, impacts your production dependencies and can even lead to dependency conflicts
  • Different projects often require different versions of the same tool

Example projects

  • This project (using uv)
  • px-demo (using uv, PDM or Poetry)

Development

  • Build/test:
git clone https://github.com/pyprojectx/pyprojectx.git
cd pyprojectx
./pw build
  • Use your local pyprojectx copy in another project: set the path to pyprojectx in the PYPROJECTX_PACKAGE environment variable and create a symlink to the wrapper script.
# Linux, Mac
export PYPROJECTX_PACKAGE=path/to/pyprojectx
ln -s $PYPROJECTX_PACKAGE/src/pyprojectx/wrapper/pw.py pw
# windows
set PYPROJECTX_PACKAGE=path/to/pyprojectx
mklink pw %PYPROJECTX_PACKAGE%\src\pyprojectx\wrapper\pw.py
# or copy the wrapper script if you can't create a symlink on windows
copy %PYPROJECTX_PACKAGE%\src\pyprojectx\wrapper\pw.py pw

Project details


Release history Release notifications | RSS feed

This version

3.3.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyprojectx-3.3.2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyprojectx-3.3.2-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file pyprojectx-3.3.2.tar.gz.

File metadata

  • Download URL: pyprojectx-3.3.2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyprojectx-3.3.2.tar.gz
Algorithm Hash digest
SHA256 fca2bdf62461506e41049817a7bac7c9e14b7bd646a875edcefcab9c33fa0da3
MD5 4c37f593a5fb825f6dffd28fff5a3e45
BLAKE2b-256 300035afaee99d309c3f8abc6c1ec9c3c714f01e8c60f4be9bb616c390643f6e

See more details on using hashes here.

File details

Details for the file pyprojectx-3.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyprojectx-3.3.2-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyprojectx-3.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93395e732ca4ae97743c4a70dd16f156e2d0da133dba2d4c14e000dd0b618845
MD5 8da25a1869832d1dda9aa1bd6eade9cc
BLAKE2b-256 b8fc62bd93ac52306c5bbf2031fa7617c292add4e90879d3828b940cfa2667b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page