Skip to content

Python 3.15: os.path.commonprefix() deprecated in norm_and_check #223

@gaborbernat

Description

@gaborbernat

Python 3.15 deprecated os.path.commonprefix() (cpython#74453). pyproject_hooks/_impl.py:120 uses it in norm_and_check():

if os.path.commonprefix([norm_source, norm_requested]) != norm_source:

On Python 3.15, this raises a DeprecationWarning. For any project running tests with filterwarnings = "error", this causes test failures:

E       DeprecationWarning: os.path.commonprefix() is deprecated. Use os.path.commonpath() for longest path prefix.

pyproject_hooks/_impl.py:120: DeprecationWarning

Note the code comment says "We have to use commonprefix for Python 2.7 compatibility" — Python 2.7 is long EOL so this can be replaced. However os.path.commonpath() is not a drop-in replacement (different semantics). A simple string comparison would work here since norm_source is already normalized:

if not abs_requested.startswith(abs_source):

Environment: Python 3.15.0a6, pyproject-hooks 1.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions