Skip to content

Substitute variables into requirements #129

@lordmauve

Description

@lordmauve

Description

I am using pip-tools to compile requirements from pyproject.toml and write to requirements.txt files.

A once task to pip-compile the requirements, e.g.

[tool.thx.jobs.pip-compile]
run = "pip-compile -o requirements/dev.txt --extra dev --generate-hashes pyproject.toml"
once = true

has the drawback that some requirements are specified as

exceptiongroup; python_version<3.11

and these requirements will only be pinned if this task is run on an interpreter older than 3.11. once = true runs on the highest version, so will typically fail to pin things.

once = true might be better to run on the lowest version, but really, the only correct solution is to pin dependencies for each interpreter. However this will require being able to substitute the python_version into the requirements:

[tool.thx]
python_versions = ["3.12", "3.11", "3.10"]

# Requirements to use for all jobs
requirements = ["requirements/dev-{python_version}.txt"]

[tool.thx.jobs.pip-compile]
run = "pip-compile -o requirements/dev-{python_version}.txt --extra dev --generate-hashes pyproject.toml"

Details

  • OS: Linux
  • Python version: 3.12
  • thx version: 0.6.0
  • Can you repro on main? Yes
  • Can you repro in a clean virtualenv? Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions