Skip to content

Define a set of named features and logic to manage their dependencies.#480

Draft
albu-diku wants to merge 2 commits intonextfrom
add/requirements-per-feature
Draft

Define a set of named features and logic to manage their dependencies.#480
albu-diku wants to merge 2 commits intonextfrom
add/requirements-per-feature

Conversation

@albu-diku
Copy link
Contributor

@albu-diku albu-diku commented Mar 9, 2026

Summary:

This work povides a way to make use of per-feature requirements files while maintaining the ability to have certain requirements overridden during build and other be met by system packages. This would make it suitable for immediate use in docker-migrid where it would replace the series of hand rolled pip install lines gated by feature checks and the package installation lines those checks contain.

Detail:

The codebase has a number of features that, when selected, require certain dependencies. Thus far the handling for this has been split between this repository and the docker-migrid, which encodes a large amount of version information for the various features and in addition allows overriding these at build time.

There is a desire to see these become per-feature requirements files expressed in this repository - that would mean the dependencies are captured alongside the code that depends upon them. However, the ability to override the versions being used and, more critically, to make use of packages provided by the distribution must remain possible.

This PR introduces work that will allow that. The features are explicitly defined by name in a static file that describes them. The added features tool reads this file and, after consulting a source for what is enabled (this can be the environment but also a .env file, as used within the docker builds, directly) will output the lines needed to install the packages.

This simple conceptual design allows us to handle package overrides and distribution packages. We maintain a list of environmental keys to be consulted for certain package versions and if present expand the packages we must install from the requirements file and make use of the an applicable override instead. In the situation of distribution packages, we perform the same requirements expansion but check whether the dependency is already met in the python environment and skip its installation if so.

Review

To anyone taking a look: not all the features are fully defined here as a way to first share the approach. The tests coves all installation cases, but when run directly the repository level notion of defined features are used. Two named features re currently defined, CLOUD and MIGUX (which likely gives you an idea of what I was working on). I would recommend comparing the output from the following commands:

./envhelp/lpython ./mig/install/features.py install --env --check
ENABLE_CLOUD=true ./envhelp/lpython ./mig/install/features.py install --env --check
ENABLE_CLOUD=true OPENSTACKSDK_VERSION_OVERRIDE=1.2.3 ./envhelp/lpython ./mig/install/features.py install --env --check

@albu-diku albu-diku force-pushed the add/requirements-per-feature branch from 259c67a to 1c523ba Compare March 9, 2026 15:07
The codebase has a number of features that, when selected, require
certain dependencies. Thus far the handling for this hsa been split
between this repository and the docker-migrid, which encodes a large
amount of version information for the various features and in addition
allows overriding these at build time.

There is a desire to see these become per-feature requirements files
expresed in this repository, but then to also retain the ability to
override the package versions at the time of build.

This commit introduces work that will allow that. The features are
explicitly defined by name in a ini file that describes them. The
added features tool reads this file and, after consulting a source
for what is enabled (this can be the environment but also a .env
file, as used within the docker builds, directly) will output the
lines needed to install the packages.

Any complexity here stems from the requirement to be able to override
certain packages. Since a requirements file can easily contain more
than one package, we must be able to override one of the set of
specified dependencies.
@albu-diku albu-diku force-pushed the add/requirements-per-feature branch from 1c523ba to 6b810ce Compare March 14, 2026 19:07
This mode can be enabled by a command line flag which, when set, causes
the dependencies for each feature to be checked for presence within the
active python environment and their installation skipped if present.

In practice this means the requirements files can list dependencies
exhaustively but still allow the host environment arranged by a build
process to provision packages in the host environment and have these
respected during installation. Further, if such a package is only one
of many requirements then it alone will be skipped while all other
dependencies will be correctly installed.
@albu-diku albu-diku force-pushed the add/requirements-per-feature branch from 6b810ce to 6597a2a Compare March 14, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant