Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Package Developer Experience (DX) Toolkit [Pkgdx]

I created pkgdx as a way to improve DX for Python projects. The package is intended for installation as a development dependency, providing a main command-line interface (CLI) and a nested CLI commands and options for common development tasks.

Current features

(1) Canonical standards maintenance

pkgdx centralises creation and implementation of coding standards across projects, providing a single source of truth for toolchain configuration:

  1. Mypy (Python static type checking)
  2. Ruff (Python linting & formatting)
  3. PyMarkdown (Markdown linting)
  4. detect-secrets (secret detection)
  5. Prek (hook framework)

Demo Preview

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:

uv run pkgdx -d init

To overwrite or reset an existing prek.toml in the project root, use the --reset option:

uv run pkgdx init --reset

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.4.1

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.

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:

  1. The directory named by the PKGDX_CONFIG_DIR environment variable, if it is set and non-empty.
  2. The platform default:
    • Windows: %APPDATA%\pkgdx
    • Linux, macOS and other OSes: $XDG_CONFIG_HOME/pkgdx if XDG_CONFIG_HOME is an absolute path, otherwise ~/.config/pkgdx

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 rules
  • mypy.ini - Mypy static typing rules
  • pymarkdown.toml - PyMarkdown linting rules
  • hooks.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 the user config directory, the environment variable that can override it, and, for each file, its source (user or bundled) and resolved path. Output goes to standard output.

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 reports which files were written and which were skipped.

(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:

  1. Keep the four files in your own standards Git repository.
  2. Clone that repository locally and either use it as the user config directory or point PKGDX_CONFIG_DIR at it.
  3. In CI, clone the same repository and export PKGDX_CONFIG_DIR to 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.

  1. Fork the repo to your own namespace.
  2. Modify the files in src/pkgdx/standards/ (mypy.ini, pymarkdown.toml, ruff.toml and hooks.toml).
  3. In src/pkgdx/standards/hooks.toml, change the repo value from "https://gitlab.com/andyrids/pkgdx" to your forked repo URL, and set rev to the tag you will create.
  4. 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.
  5. The publish-pypi-job uploads to PyPI from protected v* 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.5.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pkgdx 0.5.0rc1
File Size Uploaded Provenance Actions
pkgdx-0.5.0rc1.tar.gz 25.4 kB Without provenance Details for pkgdx-0.5.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pkgdx 0.5.0rc1
File Interpreter ABI Platform Actions
pkgdx-0.5.0rc1-py3-none-any.whl Python 3 none any Details for pkgdx-0.5.0rc1-py3-none-any.whl

Total release size: 53.1 kB

Release files / pkgdx-0.5.0rc1.tar.gz

Download URL pkgdx-0.5.0rc1.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eb64205a57f813d7aedc4e160cfa7ad3747cc2d72cbab9b85b1c186e2f7fa1ec
BLAKE2b-256 checksum
How to use checksums
67bfaebbf4583419af2852b224716d01f3f826b5bd7ae83f0cf65766fb8ce703
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.5.0rc1-py3-none-any.whl

Download URL pkgdx-0.5.0rc1-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2559696bc274753207109fd85d921436bd0e3b3da3118e69aa57cc7be13853a3
BLAKE2b-256 checksum
How to use checksums
1941a5561b8da09c98f9f0f6782377b884a52ad8288edeb734183d9b75e3ffea
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.5.0rc1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page