Skip to content

[BUG] ImportError running entrypoint in setuptools 64.0.0+ when PYTHONPATH defined #3535

@edmorley

Description

@edmorley

setuptools version

setuptools==64.0.0

Python version

Python 3.10

OS

Debian (official Python docker images)

Additional environment information

Last known good version: setuptools v63.4.3
First failing version: setuptools v64.0.0 (also confirmed failing with setuptools v65.0.2)

Description

Installing a local package (which has an entrypoint) as editable, now results in an ImportError when that entrypoint is run with PYTHONPATH set, when it worked before.

Example project repo:
https://github.com/edmorley/testcase-setuptools-pep660-pythonpath

Expected behavior

Either:

  1. Existing package continues to work with setuptools v64's new PEP660 editable mode (if what the package is doing is reasonable)
  2. Or, if a certain workflow/scenario is no longer supported, then ideally for setuptools to output an error or warning at build/install time, rather than there being a hard to diagnose ImportError at runtime.

How to Reproduce

  1. git clone https://github.com/edmorley/testcase-setuptools-pep660-pythonpath && cd testcase-setuptools-pep660-pythonpath
  2. docker build -t testcase . && docker run --rm -it -e PYTHONPATH=/src testcase hello

Notes:

  • This testcase uses Python 3.10.6, pip 22.2.2, setuptools 65.0.2, wheel 0.37.1.
  • Any of the following prevents the issue from occurring:
    • Downgrading to setuptools <64 (eg: 63.4.3) in the [build-system] requires of pyproject.toml.
    • Removing the -e PYTHONPATH=/src from the docker run command.
  • However using SETUPTOOLS_ENABLE_FEATURE=legacy-editable doesn't seem to help (uncomment in Dockerfile to try it).

Output

Traceback (most recent call last):
  File "/usr/local/bin/hello", line 5, in <module>
    from my_package import hello
ImportError: cannot import name 'hello' from 'my_package' (unknown location)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions