Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Errors with referential optional-dependencies on 7.5.0 #2233

@gordiig

Description

@gordiig

I'm getting ValueError: relative path can't be expressed as a file URI for one optional dependency referencing another after updating pip-tools from 7.4.0 to 7.5.0.

Environment Versions

  1. OS Type: Ubuntu 22.04
  2. Python version: 3.13.2
  3. pip version: 25.2
  4. pip-tools version: 7.5.0

Steps to replicate

My pyproject.toml looks somewhat like this:

[project]
name = "da"
# ...
dependencies = [
    # ...
]

[project.optional-dependencies]
utils = [
    # ...
]

test = [
    "da[utils]",
    # ...
]

Expected result

Compiled requirements.
I haven't altered my pyproject in any way after or before updating pip-tools.
Compile works after I comment out da[utils].

Actual result

$ pip-compile -o requirements.txt pyproject.toml
Using pip-tools configuration defaults found in 'pyproject.toml'.
Traceback (most recent call last):
  File "/some/path/da/venv/bin/pip-compile", line 7, in <module>
    sys.exit(cli())
             ~~~^^
  File "/some/path/da/venv/lib/python3.13/site-packages/click/core.py", line 1442, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/some/path/da/venv/lib/python3.13/site-packages/click/core.py", line 1363, in main
    rv = self.invoke(ctx)
  File "/some/path/da/venv/lib/python3.13/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/some/path/da/venv/lib/python3.13/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
  File "/some/path/da/venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/some/path/da/venv/lib/python3.13/site-packages/piptools/scripts/compile.py", line 371, in cli
    metadata = build_project_metadata(
        src_file=Path(src_file),
    ...<4 lines>...
        quiet=log.verbosity <= 0,
    )
  File "/some/path/da/venv/lib/python3.13/site-packages/piptools/build.py", line 159, in build_project_metadata
    project_metadata = maybe_statically_parse_project_metadata(src_file)
  File "/some/path/da/venv/lib/python3.13/site-packages/piptools/build.py", line 106, in maybe_statically_parse_project_metadata
    requirement.url = src_file.parent.as_uri()
                      ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/path/.pyenv/versions/3.13.2/lib/python3.13/pathlib/_local.py", line 431, in as_uri
    raise ValueError("relative path can't be expressed as a file URI")
ValueError: relative path can't be expressed as a file URI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions