Skip to content

Requirements

Check and update the Python requirements.

Modules:

Name Description
check

Check the differences between the existing requirements and the expected ones.

update

Update the requirements file of the project depending on the python dependencies found in the project.


How it works

Both commands scan every addon manifest at the project root and collect external_dependencies["python"] entries. The collected names are normalized to their pip equivalents, deduplicated, and version-merged before being compared to (or used to rewrite) the current requirements.txt.

Merging rules

When multiple addons declare constraints for the same package, they are merged before comparison:

# Case Behaviour
1 Bare name (no operator) Kept as-is, deduplicated across addons
2 Single floor (>= / >) Kept as-is
3 Single ceil (<= / <) Kept as-is
4 Multiple floors Highest version wins (most restrictive)
5 Multiple ceils Lowest version wins (most restrictive)
6 Floor + ceil Merged as pkg>=floor,<ceil
7 > vs >= at same version Strict operator wins (> beats >=, < beats <=)
8 == pin Kept as-is; if a version range also exists for the same package, both are emitted — human arbitration required
9 Git dep (e.g. pkg@git+…) No operator detected → treated as bare name, passed through unchanged
10 Name mapping Import names are normalized to pip names before version processing (see below)
11 Final output Alphabetically sorted

Name mapping

Import names are mapped to their canonical pip package names before any version processing. The built-in defaults are:

Import name pip name
dateutil python-dateutil
jours-feries-france jours_feries_france
PIL Pillow
shopify ShopifyAPI
stdnum python-stdnum

Additional mappings can be declared in .oops.yaml:

requirements:
  python_requirements_mapping:
    mylib: my-lib-on-pypi

oops requirements check

Check the differences between the existing requirements and the expected ones.

The expected requirements are computed by scanning every root addon manifest and collecting their external_dependencies["python"] entries.

In case of changes, it will be displayed like this:

Changes for requirements.txt:

- astor
+ pandas
+ python-stdnum
- pytz
+ pytz==2023.3

See the requirements documentation for merging rules and name-mapping details.

Usage:

oops requirements check [OPTIONS]

Options:

Name Type Description Default
--no-fail boolean Exit 0 even when changes are detected. False
--help boolean Show this message and exit. False

Examples:

Update the addons table and commit if changed:

oops requirements update

Update without committing:

oops requirements update --no-commit

oops requirements update

Update the requirements file of the project depending on the python dependencies found in the project. It checks the python dependencies in each manifest of the root addons.

The whole content of the requirements file is replaced by the python dependencies found in the project.

By default, a commit is automatically done to push the changes. Use --no-commit to avoid this behaviour.

See the requirements documentation for merging rules and name-mapping details.

Usage:

oops requirements update [OPTIONS]

Options:

Name Type Description Default
--dry-run boolean Show what would happen, do nothing. False
--no-commit boolean Do not commit changes. False
--help boolean Show this message and exit. False

Examples:

Update the addons table and commit if changed:

oops requirements update

Update without committing:

oops requirements update --no-commit