Open
Description
pip-tools 6.14.0 adds --config annotation even there is no configuration.
Environment Versions
- OS Type: Linux
- Python version:
$ python -V
: 3.11.3 - pip version:
$ pip --version
: 22.3.1 - pip-tools version:
$ pip-compile --version
: 6.14.0
Steps to replicate
mkdir requirements
touch pyproject.toml
echo astpretty > requirements/test.in
pip-compile --allow-unsafe --generate-hashes --output-file=requirements/test.txt --resolver=backtracking --strip-extras requirements/test.in
Expected result
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements/test.txt --resolver=backtracking --strip-extras requirements/test.in
#
astpretty==3.0.0 \
--hash=sha256:15bfd47593667169485a1fa7938b8de9445b11057d6f2b6e214b2f70667f94b6 \
--hash=sha256:b08c95f32e5994454ea99882ff3c4a0afc8254c38998a0ed4b479dba448dc581
# via -r requirements/test.in
Actual result
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --config=pyproject.toml --generate-hashes --output-file=requirements/test.txt --resolver=backtracking --strip-extras requirements/test.in
#
astpretty==3.0.0 \
--hash=sha256:15bfd47593667169485a1fa7938b8de9445b11057d6f2b6e214b2f70667f94b6 \
--hash=sha256:b08c95f32e5994454ea99882ff3c4a0afc8254c38998a0ed4b479dba448dc581
# via -r requirements/test.in
Activity
q0w commentedon Jul 6, 2023
--config=pyproject.toml
option in header #1903atugushev commentedon Jul 6, 2023
Perhaps,
src_files
should be eager instead ofconfig
. Which makes sense, because--config
depends onsrc_files
inoverride_defaults_from_config_file
.q0w commentedon Jul 6, 2023
oh maybe in
override_defaults_from_config_file
it should return None if there is no config in the file.So config should be None, if pyproject.toml is empty
It seems this is an another bug
atugushev commentedon Jul 6, 2023
Arguably empty config is still a config.
q0w commentedon Jul 6, 2023
But why does not it found configuration in this case:
pyproject.toml is not empty
with src_files = ('requirements/test.in',) config_file is None
.pip-tools.toml
orpyproject.toml
#1863atugushev commentedon Jul 9, 2023
@q0w I'm not following. Could you please elaborate?
q0w commentedon Jul 9, 2023
When src_files is ('requirements/test.in',) it does not find a config file from pyproject.toml. Use an example from this issue and add a pip-tools configuration in pyproject.toml to reproduce.
atugushev commentedon Jul 9, 2023
select_config_file(('requirements/test.in',))
isNone
because it searches config inrequirements/pyproject.toml
.atugushev commentedon Jul 9, 2023
select_config_file
called twice, when parsing args and inget_compile_command()
and gives different results, because:Which is why
is_eager=True
flag onsrc_files
fixes the issue.q0w commentedon Jul 9, 2023
Yes, but I think it should find pyproject.toml because pip-tools is called in PWD=., not requirements dir
atugushev commentedon Jul 9, 2023
@q0w agreed 👍🏻 select_config_file should search for configs in PWD and in src_files dirs. Currently, it searches in PWD or src_files dirs.