Skip to content

How to read --python-version from file with pip-compile hook #34

@ollie-bell

Description

@ollie-bell

uv pip compile doesn't read pyproject.toml or .python-version to default the --python-version flag (astral-sh/uv#9581). Running uv pip compile --python-version=$(cat .python-version) is an acceptable workaround, but this doesn't work using the pip-compile pre-commit hook because pre-commit just passes the arguments as literal strings and uv pip compile can't do the variable expansion dynamically.

Are there any recommended ways to not have to hardcode --python-version here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions