Skip to main content

A tox plugin for pinning dependencies.

Project description

tox-pin-deps

main branch test status Coverage Status PyPI version tox v3 + v4 support

Run tox environments with strictly pinned dependencies using simple, well-maintained tools (you're probably using already) with no project or code changes.

This plugin uses jazzband/pip-tools' pip-compile to freeze test and project dependencies, save a lock file per-testenv, and have the locked deps installed, in the usual way via pip, on subsequent invocations.

This plugin supports both tox 3 and tox 4.

Usage

  1. Install tox-pin-deps in the same environment as tox.
  2. Run tox --pip-compile to pin deps for the default envlist.
  3. Commit files under {toxinidir}/requirements/*.txt to version control.
  4. Subsequent runs of tox will install from the lock file.
  • Run tox --pip-compile --pip-compile-opts \ --upgrade at any time to lock updated dependencies based on:
    • deps named in tox.ini for the environment
    • Project ("dist") dependencies named in pyproject.toml, setup.cfg, or setup.py.
      • Unless skip_install or skipsdist is true
  • Run tox --ignore-pins to use the dependencies named in deps without any special behavior.
  • Set pip_compile_opts = --generate-hashes in the testenv config to enable hash-checking mode.
  • To always use this plugin, specify requires = tox-pin-deps in the [tox] section of tox.ini

Motivation

This project is designed to enable reproducible test (and runtime) environments without changing project structure or requiring the use of non-standard tools.

  • Use the deps and install_requires/[project.dependencies] that the project already specifies
  • Only need pip-compile at lock time, not at runtime
  • Uses standard, well-supported tooling: pip and virtualenv

Why not...?

tox-constraints

  • Requires the user to bring their own constraints.txt
  • constraints.txt is a newer concept in the python packaging, which may be unfamiliar.
  • constraints.txt with hash checking has had serveral issues since the 2020 pip resolver which make it unsuitable for this use.
  • tox-constraints does not support tox 4

poetry / tox-poetry

  • poetry is a newer tool that most python programmers haven't worked with.
  • poetry is a runtime dependency for developing/testing projects.
  • Requirements are specified in non-standard [tool.poetry] section of pyproject.toml.
  • If a project isn't already using poetry, adopting it for the sole purpose of controlling and pinning dependencies constitutes a significant change to development and packaging workflows.
  • tox-poetry does not support tox 4

pipenv / tox-pipenv

  • pipenv is slow, non-standard, and does NOT work for dist projects
  • pipenv is older, but still a tool that most python programmers haven't worked with.
  • pipenv is a runtime dependency for developing/testing projects.
  • Requirements are specified in a non-standard Pipfile and Pipfile.lock.
  • If a project isn't already using pipenv, adopting it for the sole purpose of controlling and pinning dependencies constitutes a significant change to development and packaging workflows.
  • tox-pipenv has behavioral edge cases that make it uncomfortable to work with.
  • tox-pipenv does not support tox 4

pip-compile (directly)

  • Need scripts to handle updating / re-locking deps for multiple python versions
  • Missing tox deps integration for locking test environments

pip-compile-multi

tox-pin-deps does essentially the same thing as pip-compile-multi, except using the environment deps section as the layer on top of the project's setup.py or pyproject.toml, instead of a separate text file.

If a project didn't want to use tox for managing test environments, then pip-compile-multi is a great choice for achieving similar ends.

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

tox-pin-deps-0.2.2.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

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

tox_pin_deps-0.2.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file tox-pin-deps-0.2.2.tar.gz.

File metadata

  • Download URL: tox-pin-deps-0.2.2.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tox-pin-deps-0.2.2.tar.gz
Algorithm Hash digest
SHA256 12b6c0b3bbf67cd6f34a448e5c6aedfff103496b23c0549f23d6bc45ecb90154
MD5 cd5eac8f18899fd775cac87a0e8a4968
BLAKE2b-256 1a209328da9d53da40e1517cdf19d07aae9d04bde5d334b87f356df5b90664be

See more details on using hashes here.

File details

Details for the file tox_pin_deps-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tox_pin_deps-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for tox_pin_deps-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c7de4ea6533b0f75c2f80b7ec037f3986c6995c43e777caade32d1042c9ecb9d
MD5 224d79684be7a6a04e55f2fa521973a4
BLAKE2b-256 a16ea01f9f4b7ec38ef7e4ca1723a4d1c9c54d31d7f39df4782ff1c4d4bc9bdc

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