As it stated in the documentation, pip-tools look for the configuration file “in the same directory as your requirements input files”. However, due to the way click works, it's not true:
--config (and --no-config) is declared as eager: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/scripts/options.py#L317-L333
--config's callback override_defaults_from_config_file tries to get the src_files param value to compute the config path relative to the source files: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/utils.py#L543
- But since callbacks of eager options are called before other options are processed,
src_files is always empty. From the click documentation: “All eager parameters are evaluated before all non-eager parameters, but again in the order as they were provided on the command line by the user.”
select_config_file falls back to the current working dir as a config file location: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/utils.py#L627-L630
Environment Versions
- Linux
- Python version:
Python 3.12.3
- pip version:
pip 24.0
- pip-tools version:
pip-compile, version 7.4.1
Steps to replicate
- Create the requirements directory
requirements/ with requirements.in.
- Create the configuration file
.pip-tools.toml or pyproject.toml with generate-hashes = true.
- Run
pip compile requirements/requirements.in.
Expected result
requirements/requirements.txt contains hashes.
Actual result
requirements/requirements.txt has no hashes; the configuration file is ignored.
As it stated in the documentation, pip-tools look for the configuration file “in the same directory as your requirements input files”. However, due to the way click works, it's not true:
--config(and--no-config) is declared as eager: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/scripts/options.py#L317-L333--config's callbackoverride_defaults_from_config_filetries to get thesrc_filesparam value to compute the config path relative to the source files: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/utils.py#L543src_filesis always empty. From the click documentation: “All eager parameters are evaluated before all non-eager parameters, but again in the order as they were provided on the command line by the user.”select_config_filefalls back to the current working dir as a config file location: https://github.com/jazzband/pip-tools/blob/7.4.1/piptools/utils.py#L627-L630Environment Versions
Python 3.12.3pip 24.0pip-compile, version 7.4.1Steps to replicate
requirements/withrequirements.in..pip-tools.tomlorpyproject.tomlwithgenerate-hashes = true.pip compile requirements/requirements.in.Expected result
requirements/requirements.txtcontains hashes.Actual result
requirements/requirements.txthas no hashes; the configuration file is ignored.