add egg_info command patch to fix pip building with setuptools==75.2.0#26
add egg_info command patch to fix pip building with setuptools==75.2.0#26
Conversation
There was a problem hiding this comment.
Wow! What a deep dive! setuptools achievement unlocked! 🥇
Really great description, really great comments on the code, super weird stuff that's happening there, and I'm glad the solution is actually clean and somewhat simple! 🦸🏽
Btw, the solution works perfectly fine for me. I used the reproducer described in #25, and I can verify that the issue is fixed with this PR.
| # this code path is for building wheels from source distributions via pip | ||
| i = sys.argv.index("--output-dir") |
There was a problem hiding this comment.
it's not great we're depending on assumptions how pip calls setuptools, but 🤷
plux/build/setuptools.py
Outdated
| LOG.debug("Locating plux.json from local build context %s", meta_dir) | ||
| plux_json = os.path.join(meta_dir, "plux.json") | ||
| if os.path.exists(plux_json): | ||
| self.mkpath(self.egg_info) # this is what egg_info.run() |
There was a problem hiding this comment.
nit: It seems like this comment didn't get to the end: "# this is what egg_info.run()"
I think you are referring to this line in setuptools, right?
https://github.com/pypa/setuptools/blob/e5f16a2a990ff18cdef27a22b742f97444867186/setuptools/command/egg_info.py#L297
Motivation
This PR addresses an issue that surfaced with setuptools 75.2.0, most likely this PR: pypa/setuptools#4647
When you
pip install <some-source-distribution>, the following things happen (among others):.tar.gzinto some temporary folder, say/tmp/pip-req-build-bwekzpi_, this directory will contain the.egg-infothat was packaged with the source distribution.dist-infodirectory)prepare_metadata_for_build_wheelon the build backend (an interface from PEP 517)prepare_metadata_for_build_wheelis just a wrapper around thedist_infocommand, which again first calls theegg_infocommand.dist-infodirectory from the newly created.egg-infodirectory (which are both in pip's temporary build context)Here's a an example where I run

pip install /path/to/test-library/dist/test_library-0.1.0.tar.gz:The issue is that this temporary
.egg-infodirectory is completely built from scratch from the python configuration files (pyproject.toml or setup.cfg). no previously generated metadata files from the original source distribution are copied.This PR adds a patch to
egg_infoto address this issue. when plux is part of the setup procedure, it detects a local pip build context and copies theplux.jsonfile from the extracted source distribution into the temporary build context. the remainingegg_infocommand proceeds normally and will then create theentry_points.txtcorrectly through theplux.jsonegg-info writer plugin.Changes
plux.jsonfile from the original source distribution into the temporary build context when building with pip