Skip to main content

Slap is a command-line utility for developing Python applications.

Project description

slap

Slap is a command-line tool for developing Python projects that provides a common interface for many tasks independent of the build system you use (currently supporting Setuptools via Pyproject, Poetry and Flit). It makes it easier to manage monorepositories of multiple projects which may even have inter-dependencies.

Developer's note: I personally use Poetry as the build system for some of its features, in particular because of its support for semantic version selectors which are not supported by Setuptools or Flit; but never actually use the Poetry CLI because I too often run into issues with it's dependency resolution and installation mechanism as well as its implicitly created virtual environments.

Slap provides a variety of features, including but not limited to

  • Sanity check your project configuration
  • Install your project and it's dependencies via Pip (in the right order in case of a monorepository)
  • Symlink your project (using Flit's symlinking function internally, independent of your actual build system; Poetry does not support editable installs so this is really convenient)
  • Build and publish your project (and all its individual packages in case of a monorepository) to Pypi using Twine
  • Release new versions (automatically update version numbers in code, create a Git tag and push)
  • Run tests configured in your Pyproject config under [tool.slap.test]
  • Manage local (~/.venvs) and global (~/.local/venvs) virtual environments (backed by Python's venv module)
  • Manage structured changelogs (TOML) via the CLI; easily inject PR URLs into changelog entries in pull requests via CI

Installation

It is recommended to install Slap via Pipx, but you can also install it with Pip directly.

$ pipx install slap-cli

Note: Currently, Slap relies on an alpha version of poetry-core (^1.1.0a6). If you install it into the same environment as Poetry itself, you may also need to use an alpha version of Poetry (e.g. 1.2.0a2).

Usage examples

Bootstrap a (opinionated) Poetry project using Slap.

$ slap init --name my.pkg
write my-pkg/pyproject.toml
write my-pkg/LICENSE
write my-pkg/readme.md
write my-pkg/.gitignore
write my-pkg/src/my/pkg/__init__.py
write my-pkg/test/test_import.py
write my-pkg/src/my/pkg/py.typed

Sanity check your project configuration

$ slap check
Checks for project slap-cli

  changelog:validate           OK             — All 74 changelogs are valid.
  general:packages             OK             — Detected /home/niklas/git/slap/src/slap
  general:typed                OK             — py.typed exists as expected
  poetry:classifiers           OK             — All classifiers are valid.
  poetry:license               OK             — License "MIT" is a valid SPDX identifier.
  poetry:readme                OK             — Poetry readme is configured correctly (path: readme.md)
  poetry:urls                  RECOMMENDATION — Please configure the following URLs: "Bug Tracker"
  release:source-code-version  OK             — Found __version__ in slap

Install and link your project (by default, the command protects you from accidentally installing the project; you can pass --no-venv-check to skip this safeguard).

$ slap install --link

Validate the version numbers in your project and release a new version.

$ slap release --validate
versions are ok
  pyproject.toml:          1.2.4 # version = "1.2.4"
  src/slap/__init__.py:    1.2.4 # __version__ = '1.2.4'
$ slap release --tag --push minor
bumping 3 version references to 1.3.0
  pyproject.toml:          1.2.4 → 1.3.0 # version = "1.2.4"
  src/slap/__init__.py:    1.2.4 → 1.3.0 # __version__ = '1.2.4'

releasing changelog
  .changelog/_unreleased.toml → .changelog/1.3.0.toml

tagging 1.3.0

pushing develop, 1.3.0 to origin

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

slap-cli-1.4.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

slap_cli-1.4.0-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

Details for the file slap-cli-1.4.0.tar.gz.

File metadata

  • Download URL: slap-cli-1.4.0.tar.gz
  • Upload date:
  • Size: 61.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for slap-cli-1.4.0.tar.gz
Algorithm Hash digest
SHA256 81d29cc17c7e835656712f02a5894275f52ff94dd5aac474ceea6ee8f5e63394
MD5 977f60c8ec50472c5081dbf5e56cf090
BLAKE2b-256 a36addd235b6cedcb17def0965d4be4784f01051c91d0cf13c1e992bd5f52b44

See more details on using hashes here.

File details

Details for the file slap_cli-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: slap_cli-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 79.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for slap_cli-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f51103b1cf8b8e16051d2875f6b386264a77dd5a1ef8f5ea512509259e0ec2a
MD5 3e8827678238a2c1072857681971d60d
BLAKE2b-256 fb324dab382146fbf91431eb6edde56e09e6a888a2f8b5c4adb83bd628c0254d

See more details on using hashes here.

Supported by

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