pyproject-hooks icon indicating copy to clipboard operation
pyproject-hooks copied to clipboard

Release 1.1: Regression breaks setuptools builds

Open jaraco opened this issue 1 year ago • 14 comments

In https://github.com/pypa/setuptools/issues/4333, setuptools reports some emergent failures implicating the recent pyproject-hooks 1.1 release.

jaraco avatar Apr 29 '24 19:04 jaraco

I suspect this change is relevant.

  • More careful handling of the backend-path key from pyproject.toml. Previous versions would load the backend and then check that it was loaded from the specified path; the new version only loads it from the specified path. The BackendInvalid exception is now a synonym for :exc:BackendUnavailable, and code should move to using the latter name.

jaraco avatar Apr 29 '24 19:04 jaraco

https://github.com/pypa/pyproject-hooks/pull/165 is the relevant PR -- /cc @abravalheri for awareness.

It's unclear to me what exactly is happening here from the setuptools failure, so not quite sure what the fix should/would be?

pradyunsg avatar Apr 29 '24 19:04 pradyunsg

My initial thought is that setuptools' builds were previously relying on metadata from an existing installation... and this change keeps that metadata hidden so that all that's around is the bootstrap metadata, which isn't sufficient to build setuptools (maybe?).

jaraco avatar Apr 29 '24 19:04 jaraco

Or, maybe the changes to avoid altering sys.path cause the metadata to be missing altogether.

jaraco avatar Apr 29 '24 19:04 jaraco

The sys.path with 1.0.0:

['/Users/pradyunsg/Developer/github/setuptools', '/Users/pradyunsg/Developer/github/setuptools/.venv/lib/python3.12/site-packages/pyproject_hooks/_in_process', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python312.zip', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python3.12', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python3.12/lib-dynload', '/Users/pradyunsg/Developer/github/setuptools/.venv/lib/python3.12/site-packages']

The sys.path with 1.1.0:

['/Users/pradyunsg/Developer/github/setuptools/.venv/lib/python3.12/site-packages/pyproject_hooks/_in_process', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python312.zip', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python3.12', '/Users/pradyunsg/.asdf/installs/python/3.12.0/lib/python3.12/lib-dynload', '/Users/pradyunsg/Developer/github/setuptools/.venv/lib/python3.12/site-packages']

It's... suboptimal... that _in_process is on sys.path with this setup.

pradyunsg avatar Apr 29 '24 19:04 pradyunsg

Yup, it's the changeover to using sys.meta_path rather than sys.path for loading the backend that's affected things here.

pradyunsg avatar Apr 29 '24 20:04 pradyunsg

I suspect adding a find_distributions (i.e. making it an importlib.metadata.DistributionFinder) will allow it to find the metadata for a backend and will likely address the concern.

jaraco avatar Apr 29 '24 21:04 jaraco

I also suspect this is the root cause of this issue: https://github.com/python-poetry/poetry/issues/9351

mdagost avatar Apr 29 '24 23:04 mdagost

@mdagost No. See #191.

pradyunsg avatar Apr 30 '24 00:04 pradyunsg

Yes. Simply downgrading pyproject-hooks from 1.1.0 to 1.0.0 with no other changes fixes poetry install for all our projects.

mdagost avatar Apr 30 '24 00:04 mdagost

Sorry--update. I believe the root cause is that 1.0.0 was locked in the poetry.lock file, but then poetry itself pulled in 1.1.0 when it was pip installed. So there was a conflict. Either downgrading to 1.0.0 after pip installing, or upgrading to 1.1.0 in the lock file fixes things for me.

mdagost avatar Apr 30 '24 01:04 mdagost

@mdagost That sounds unrelated to this project, and specific to how Poetry is handling its environment and lockfile.

Please, let's keep any further Poetry-specific discussion in the Poetry issue tracker or the other issue in this repo.

pradyunsg avatar Apr 30 '24 08:04 pradyunsg

Correct. The root root cause was managing poetry with the lockfile, which is no bueno.

mdagost avatar Apr 30 '24 18:04 mdagost

CPython should stop shipping with prebuilt pip and invoking an install of prebuilt setuptools. Even Fedora has a problem with this.

jacobfriedman avatar Jun 19 '24 05:06 jacobfriedman

@jacobfriedman CPython shipping pip has absolutely nothing to do with this problem, this same issue happens with pyproject stack with no pip and only build+installer.

nanonyme avatar Jul 18 '24 16:07 nanonyme