pypa / setuptools

Official project repository for the Setuptools build system
https://pypi.org/project/setuptools/
MIT License
2.34k stars 1.14k forks source link

Ensure `*/extern/__init__.py` is in sync with `*/_vendor/vendored.txt` #4320

Closed abravalheri closed 3 weeks ago

abravalheri commented 3 weeks ago

Sometimes I have the feeling that the vendored packages, _vendor/vendored.txt and extern/__init__.py drift apart. This is an attempt to minimise that.

Please feel free to close if you don't think this is relevant.

Summary of changes

Closes

Pull Request Checklist

[PR docs]: https://setuptools.pypa.io/en/latest/development/developer-guide.html#making-a-pull-request

Avasam commented 3 weeks ago

I've been thinking we may be able to simplify it by merely adding _vendor to sys.path (and eliminating extern altogether)

@jaraco Eliminating extern in favor of importing from _vendor (or making it so import vendored_module imports _vendor.vendored_module) would also solve type imports issues (like #4242) for type-checkers.

abravalheri commented 3 weeks ago

I think we can go with this one for now and any improvements can follow up. I also opened other issues for the comments we left.

I've been thinking we may be able to simplify it by merely adding _vendor to sys.path (and eliminating extern altogether), but I haven't experimented with that and I'm unsure what dragons might lurk in that approach.

Yeah, that would be good. The obvious drawback is the dependency clash if other packages installed in the same environment require conflicting versions.

A different approach (as referred by @Avasam) would be to eliminate the MetaPathFinder (and therefore the extern), but still explicitly import from setuptools._vendor. That would simply a little while avoiding the version clash. We still would have to keep the patching for absolute imports of all modules installed inside of _vendor.