Is it possible to pass variables to requirements.txt files used by Conda?

Viewed 23

I need to install Conda packages from several requirements.txt files (as specified in Conda documentation), and have the versions of the packages be read from environment variables or from another file.

This is an example of how such requirements.txt file could look like:

# requirements.txt
pandas=$pandas_version

So that export pandas_version=1.4.3 will trigger $pandas_version to be replaced by 1.4.3 when running conda install --file requirements.txt.

Is there any way to accomplish this?

1 Answers

Not directly, no. Consider using a templating system that would generate files with explicit values using environment variables.

For example, Jinja can do that.

Related