mireq / pip-compile-universal

Compile requirements.in using pip-tools for multiple python versions to single requirements.txt file
4 stars 0 forks source link

not handling requirements constraint files (-c) #1

Closed belm0 closed 2 months ago

belm0 commented 3 months ago

requirements.in:

-c base.txt
...

$ pip_compile_universal 3.8 requirements.in

Traceback (most recent call last):
  File "/.../.virtualenvs/py3.8/lib/python3.8/site-packages/pip/_internal/req/req_file.py", line 550, in get_file_content
    with open(url, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/ww/51xbs7nx6t16x7mh225q9x1h0000gn/T/tmp8eg97fzm/base.txt
mireq commented 3 months ago

@belm0 thanks for report, try it now with new version.

belm0 commented 3 months ago

Thank you. There seems to be a problem with parsing when there are comments on the same line.

$ cat requirements/dev.in
-c base.txt  # relative to this file
...
$ $ .venv/venv_python3.8/bin/pip_compile_universal 3.8,3.12 requirements/dev.in --output-file requirements/dev.txt
Traceback (most recent call last):
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 769, in <module>
    main()
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 765, in main
    pip_compile(args.versions, compile_args, Path(args.virtualenvs_dir))
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 688, in pip_compile
    first_input_data = copy_dependencies(first_input_data)
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 676, in copy_dependencies
    with open(filename) as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'base.txt  # relative to this file'
belm0 commented 3 months ago

With the comment removed, there is a 2nd bug about relative paths when the requirements files are not in the local directory (-c etc. are relative to the location of the containing requirements file):

$ .venv/venv_python3.8/bin/pip_compile_universal 3.8,3.12 requirements/dev.in --output-file requirements/dev.txt -q --no-emit-index-url
Traceback (most recent call last):
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 769, in <module>
    main()
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 765, in main
    pip_compile(args.versions, compile_args, Path(args.virtualenvs_dir))
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 688, in pip_compile
    first_input_data = copy_dependencies(first_input_data)
  File ".venv/venv_python3.8/bin/pip_compile_universal", line 676, in copy_dependencies
    with open(filename) as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'base.txt'
mireq commented 3 months ago

@belm0 i have updated package, please check if it's fixed. Thanks.

belm0 commented 3 months ago

Thank you.

It's minor, but I noticed the paths in the -c comments changed:

trio-typing[mypy]==0.9.0
    # via
    #   -c base.txt
    #   -r requirements/dev.in

It used to be # -c requirements/base.txt, so I wonder if the -c file is in a different relative location within the temp directory.

mireq commented 3 months ago

@belm0 thanks for report, it should be fixed now.

belm0 commented 2 months ago

looks good, thank you!