Package Developer Experience (DX) Toolkit [Pkgdx]
I created pkgdx as a way to improve DX for my Python projects. The package is installed as
as a development dependency, providing a command-line interface (CLI) for canonical standards
configuration.
Overview
pkgdx centralises creation and implementation of coding standards across projects, providing a
single source of truth for toolchain configuration:
- Mypy (Python static type checking)
- Ruff (Python linting & formatting)
- PyMarkdown (Markdown linting)
- detect-secrets (secret detection)
- Prek (hook framework)
Quick start
- Run
uv add --dev pkgdxfor a consuming project - Run
uv run pkgdx initto configure hooks and install Git shims - Run
uv run pkgdx config --exportto export toolchain config files
The config files; hooks.toml, mypy.ini, pymarkdown.toml and ruff.toml are exported to
$PKGDX_CONFIG_DIR | %APPDATA%/pkgdx | $XDG_CONFIG_HOME/pkgdx | ~/.config/pkgdx.
- Modify these files to maintain a new global canonical standards config
- Delete a file to revert to the repsective, bundled config
- Run
uv run pkgdx configto check config detection and location
To quickly demo pkgdx, clone this repository, cd into ./pkgdx/ and run the command below:
just consumer-demo
Further installation and setup guidance is available below.
Why?
Other methods of maintaining standards include templating tools like Cookiecutter or Copier,
which inject configurations directly into the project pyproject.toml and/or root directory.
pkgdx automates the implementation of a common standard through pre-commit hooks and CI/CD,
removing the need for extensive pyproject.toml boilerplate.
How?
Configuration files and CLI are contained in the standards/ subpackage and developments tools
have console scripts ([project.scripts]) and pre-commit hooks (.pre-commit-hooks.yaml), which
are installed through the CLI via Prek.
When Prek runs a hook (e.g. pkgdx-lint), the CLI intercepts the command and executes the
corresponding tool with a bundled configuration.
As pkgdx is versioned and tagged, updates can be implemented across all projects via standard
dependency updates and prek update command.
Consuming projects can add project-specific requirements to the pyproject.toml, which can be
implemented through commands such as uv run mypy.
To apply the canonical standards to a project, run the init command:
uv run pkgdx init
To see verbose logging output, use the --debug or -d option, before or after the command:
uv run pkgdx init -d
To overwrite or reset an existing prek.toml in the project root, use the --reset option:
uv run pkgdx init --reset
Exit codes are 0 for success (with or without warnings), 1 for a failure, 2 for a usage error,
70 for an unexpected error - a bug, please report it - and 130 for Ctrl-C. The pre-commit hooks
exit with the wrapped tool's code, and print error: <message> for a pkgdx failure, such as a
wrapped tool not found on PATH.
To see which configuration file each hook uses, run the config command. See
Adopting your own standards.
uv run pkgdx config
Installation
This project is hosted on GitLab and each release is published to PyPI and the GitLab project Package Registry. The project is also mirrored on GitHub.
PyPI
uv add --dev pkgdx
Package registry
uv add pkgdx --dev --index gitlab=https://gitlab.com/api/v4/projects/82928123/packages/pypi/simple
Project URL
uv add --dev git+https://gitlab.com/andyrids/pkgdx.git
uv add --dev git+https://gitlab.com/andyrids/pkgdx.git@v0.7.0
CI/CD integration
Pkgdx can be included in GitLab/Github CI/CD pipelines to enforce centralised standards without heavy boilerplate across each CI/CD YAML config.
Excluding files and folders
The lint, format and typing hooks walk your project themselves, so they check and auto-fix
everything they find. To leave submodules, vendored code or generated files alone, list them in your
project's pyproject.toml:
[tool.pkgdx]
exclude = ["submodules", "vendor", "src/app/_gen.py"]
Entries are literal paths relative to that file, / separated and case-sensitive. A folder covers
everything below it, and vendor never matches src/vendor. Globs are rejected, and an invalid
list fails the hook before any tool runs.
The list is committed, so it applies in CI and survives pkgdx init --reset and hook updates. It
also applies to the markdown hook, but pkgdx-secrets keeps scanning listed paths, because a secret
in vendored code is still a leaked secret. Run uv run pkgdx config to see the list in effect.
Adopting your own standards (external users)
pkgdx ships bundled canonical standards. To change them without forking, place your own files in a
user config directory. Forking remains an option for teams that want versioned, tagged standards
(see Fork the repo).
(1) Know where the user config directory is
pkgdx looks for the user config directory in this order:
- The directory named by the
PKGDX_CONFIG_DIRenvironment variable, if it is set and non-empty. - The platform default:
- Windows:
%APPDATA%\pkgdx - Linux, macOS and other OSes:
$XDG_CONFIG_HOME/pkgdxifXDG_CONFIG_HOMEis an absolute path, otherwise~/.config/pkgdx
- Windows:
If PKGDX_CONFIG_DIR is set but is not an existing directory, the lint, format, typing and markdown
hooks, pkgdx init and pkgdx config fail with exit code 1 and a single error message without a
traceback. A missing platform directory is normal and is ignored.
(2) Add your configuration files
Place any of these files in the user config directory:
ruff.toml- Ruff linting & formatting rulesmypy.ini- Mypy static typing rulespymarkdown.toml- PyMarkdown linting ruleshooks.toml- Prek config template
Each file is chosen independently. If the user config directory holds a file with one of these
names, pkgdx uses it; otherwise it uses the bundled file. A directory holding only ruff.toml
overrides Ruff and nothing else.
detect-secrets has no configuration file, so it always uses its bundled settings.
(3) Check and seed with pkgdx config
uv run pkgdx config
This prints one row per file on standard output: its name, its source (user or bundled) and
its resolved path, then one row per excluded path. A summary line on
standard error names the user config directory and whether PKGDX_CONFIG_DIR set it.
To start from the bundled files, export them into the user config directory:
uv run pkgdx config --export
--export creates the platform directory if needed, copies each bundled file that is missing and
never overwrites an existing file. It prints one line per file, created or unchanged, in the
same format as pkgdx init.
(4) CI & team parity
The user config directory lives on your machine. Without further action, CI and collaborators fall back to the bundled config, so results can differ between local runs and pipelines.
Recommended pattern:
- Keep the four files in your own standards Git repository.
- Clone that repository locally and either use it as the user config directory or point
PKGDX_CONFIG_DIRat it. - In CI, clone the same repository and export
PKGDX_CONFIG_DIRto the clone.
lint-job:
variables:
PKGDX_CONFIG_DIR: $CI_PROJECT_DIR/.pkgdx-standards
before_script:
- git clone --depth 1 https://gitlab.com/your-group/your-standards.git "$PKGDX_CONFIG_DIR"
script:
- uv run pkgdx-lint-hook
Alternative: commit the four files to each project (for example in .pkgdx/) and set
PKGDX_CONFIG_DIR=.pkgdx. A relative path is resolved against the working directory.
Fork the repo (alternative for teams)
Use a fork when you want standards that are versioned and released with the package.
- Fork the repo to your own namespace.
- Modify the files in
src/pkgdx/standards/(mypy.ini,pymarkdown.toml,ruff.tomlandhooks.toml). - In
src/pkgdx/standards/hooks.toml, change therepovalue from"https://gitlab.com/andyrids/pkgdx"to your forked repo URL, and setrevto the tag you will create. - Tag a new release. The CI/CD pipeline builds and publishes the package to your Package Registry, which you can install as a dev dependency via the repo URL or Package Registry URL.
- The
publish-pypi-jobuploads to PyPI from protectedv*tags only. To publish your fork there, rename the package and register your own PyPI trusted publisher; otherwise delete the job.
Contribution
Contributions are welcome and these should be made through the GitLab repository.
Metadata
Release files for pkgdx 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pkgdx-0.7.0.tar.gz | 32.2 kB | Without provenance | Details for pkgdx-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pkgdx-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for pkgdx-0.7.0-py3-none-any.whl |
Total release size: 64.5 kB
Release files / pkgdx-0.7.0.tar.gz
| Download URL | pkgdx-0.7.0.tar.gz |
|---|---|
| Size | 32.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a60340709b4f963f050c87d272f8f6a50c80b1c1937b2656c4af719976a96e75
|
|
BLAKE2b-256 checksum How to use checksums |
f5e5bf63cba659c951b43929e015d0ac1eb51e053ce79b981942dd4673c65d78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pkgdx-0.7.0-py3-none-any.whl
| Download URL | pkgdx-0.7.0-py3-none-any.whl |
|---|---|
| Size | 32.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0486088c40ede7c5ee40c91bf673e0016ecaa48710b45370f74fa10078adf9d2
|
|
BLAKE2b-256 checksum How to use checksums |
810ac2815b6a481e29b798a80cb0c465213ca7542b30da093ef099db7fde4a40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pkgdx 0.7.0
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.