python.star¶
Bump pinned Python requirements and the supported Python version.
Edits are line-based, so comments, ordering and markers in requirements files and pyproject.toml stay as they were.
load("@fleet//python.star", "requirements_files", "set_requirement", "requires_python", "set_requires_python")
| Function | What it does |
|---|---|
requirements_files |
Lists the repo's requirements files. |
set_requirement |
Sets a package's version specifier wherever it is already required. |
requires_python |
Reads the requires-python of a pyproject.toml. |
set_requires_python |
Sets requires-python in a pyproject.toml that already has it. |
requirements_files¶
Lists the repo's requirements files.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The sorted paths of every requirements*.txt, and every .txt in a requirements directory, outside virtualenvs and node_modules.
Example
set_requirement¶
Sets a package's version specifier wherever it is already required.
A newer version already there is kept, so a campaign never lowers one.
Changes requirements*.txt lines and the quoted entries of pyproject.toml
dependency lists, keeping extras such as [socks], environment markers
and comments. Names match the way pip matches them: Django, django
and DJANGO are the same package. Files that do not mention the package
are left alone.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
name |
The package name. |
spec |
A full PEP 440 specifier, such as ==4.2.16 or >=2.32,<3. |
Returns: The list of paths that changed.
Example
Used in: python-requirement-bump
requires_python¶
Reads the requires-python of a pyproject.toml.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
path |
The pyproject.toml to read. |
Returns: The specifier, such as >=3.9, or None.
Example
set_requires_python¶
Sets requires-python in a pyproject.toml that already has it.
A newer version already there is kept, so a campaign never lowers one.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
spec |
The new specifier, such as >=3.12. |
path |
The pyproject.toml to edit. |
Returns: True when the file changed.
Example
Used in: python-version