Removes private packages from a general requirements.txt file.
An example of usage is installing private packages. My usual workflow consists of
- changes in the source code,
pip freeze > requirements.txt- and
git add .andgit commit -m "commit massage". However, my private packages were included and the CI build would fail because of the peculiar syntax required to install private packages. - The private package was manually removed from the
requirements.txtand anothercommitwas executed.
This package was created to avoid this situation. Storing the private packages
in a different file (e.g., requirements-private.txt), it removes the
packages already presented inside requirements-private.txt from the requirements.txt
avoiding the manual deletion and the commit correcting the change.
The recommended use is adding in the .pre-commit-config.yaml file
- repo: https://github.com/mashi/requirements-filter
rev: v0.0.0 # replace by desired tag version
hooks:
- id: rqf
args: [--filename1, requirements.txt, --filename2, requirements-private.txt] # example with arguments
In this way, the packages are checked before the commit and prevents the inclusion in the version control.
Create a virtual environment and install the required packages with
python3 -m venv .venv
source .venv/bin/activate
pip install wheel
pip install -r requirements.txt
pre-commit install