Skip to main content

Tox plugin to help working with Poetry-based projects

Project description

Introduction

Tox plugin to help working with Poetry-based projects.

Repositories

Distributions:

Source code:

Usage

By default the plugin does not do anything. Use one of the following settings to activate the corresponding features.

poetry_experimental_add_locked_dependencies

Set the testenv setting poetry_experimental_add_locked_dependencies to True to let Tox add Poetry’s locked dependencies from the lockfile to the deps list in the test environment.

[testenv:example]
# ...
poetry_experimental_add_locked_dependencies = True

poetry_add_dev_dependencies

Set the testenv setting poetry_add_dev_dependencies to True to let Tox add Poetry’s development dependencies to the deps list in the test environment.

[testenv:example]
# ...
poetry_add_dev_dependencies = True

Dependency settings combination

The settings poetry_experimental_add_locked_dependencies and poetry_add_dev_dependencies are independent and can be used in combination. The following table shows the expected result for each possible combination of these two settings.

The source file column shows which file is used as source for the dependencies. The deps column shows an example of what dependencies are expected to be added to deps for that test environment. In that example Lib = '~1.0' is a mandatory dependency locking to Lib==1.2.3 and Dev = '~3.0' is a development dependency locking to Dev==3.2.1.

*_locked_dependencies

False

True

False

True

*_dev_dependencies

False

False

True

True

read from file

none

poetry.lock

pyproject.toml

poetry.lock

add to deps

nothing

Lib==1.2.3

Dev~=3.0

Lib==1.2.3, Dev==3.2.1

poetry_use_source_repos

Set the testenv setting poetry_use_source_repos to pip_env_vars to let Tox set the PIP_EXTRA_URL and PIP_EXTRA_INDEX_URL environment variables accordingly.

[testenv:example]
# ...
poetry_use_source_repos = pip_env_vars

This will read sections such as the following from the pyproject.toml file:

[[tool.poetry.source]]
name = "project-alpha"
url = "https://alpha.example/simple"
secondary = true

[[tool.poetry.source]]
name = "project-bravo"
url = "https://bravo.example/simple"

[[tool.poetry.source]]
name = "project-charlie"
url = "https://charlie.example/simple"
default = true

and set the environment variables:

PIP_INDEX_URL=https://charlie.example/simple
PIP_EXTRA_INDEX_URL=https://bravo.example/simple https://pypi.org/simple https://alpha.example/simple

If there is at least one non secondary source repository defined, then pip’s default index server (PyPI https://pypi.org/simple) is placed in PIP_EXTRA_INDEX_URL right before any secondary respository.

If pip’s environment variables are already defined then they are not overwritten. For example in a command like the following, the plugin does not overwrite the environment variable.

PIP_INDEX_URL=https://delta.example/simple tox

poetry_experimental_no_virtual_env

Experimental feature

Set the testenv setting poetry_experimental_no_virtual_env to True to skip the creation of a virtual environment for this test environment.

[testenv:real]
deps =
poetry_experimental_no_virtual_env = True
skip_install = True

This might be useful in cases where all the required dependencies and tools are already available, i.e. they are already installed in global or user site packages directory, or maybe they are already installed directly in the system (via apt, yum, pacman, etc.).

For such environments it might be best to skip the installation of the project (skip_install) as well as keeping the list of dependencies empty (deps).

Appendix

Installation

It is a plugin for Tox and it is available on PyPI, install it however best fits the workflow. A useful thing to know though, is that starting with Tox version 3.8 it is possible to enforce the installation (in an isolated environment) of the plugin directly from within the tox.ini file, thanks to the requires setting (Tox 3.2) and the auto-provisioning feature (Tox 3.8):

[tox]
requires =
    tox-poetry-dev-dependencies

Similar projects

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-poetry-dev-dependencies-0.0.6.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

tox_poetry_dev_dependencies-0.0.6-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file tox-poetry-dev-dependencies-0.0.6.tar.gz.

File metadata

  • Download URL: tox-poetry-dev-dependencies-0.0.6.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for tox-poetry-dev-dependencies-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1fdfd84c0d9ef828af51cb82b437d62128a290e3f4fca57ccf759de1165c511c
MD5 72849a41ec20be25f80159492b392c45
BLAKE2b-256 ea639140f6d1b4de05ff071bde0f03c953b4e7ba2db8f413964444a328f4d2b4

See more details on using hashes here.

File details

Details for the file tox_poetry_dev_dependencies-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: tox_poetry_dev_dependencies-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for tox_poetry_dev_dependencies-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3ada299a92a763ec733ccf304b1d2920df5a88dc98232d0a4f0d717a118b8fd3
MD5 7f3ad14998efa29998cb59d44203c3af
BLAKE2b-256 053697aeb1cd532e1a0205813762ac5edff91f7f271ac5932fcc8bff73a68d04

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