Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use build PEP 517 build frontend to build the package #1303

Merged
merged 6 commits into from
Feb 21, 2025

Conversation

edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Feb 19, 2025

Changes in this PR

  • Use pypa/build to create the wheel and sdist
  • Require/test Poetry 1.7+

Related

@edgarrmondragon edgarrmondragon self-assigned this Feb 19, 2025
@edgarrmondragon edgarrmondragon force-pushed the fix/use-build-frontend branch 4 times, most recently from 80a51b7 to 845ef26 Compare February 19, 2025 02:10
@edgarrmondragon edgarrmondragon marked this pull request as draft February 19, 2025 02:11
@edgarrmondragon edgarrmondragon force-pushed the fix/use-build-frontend branch 2 times, most recently from 05a6c32 to 85c5ab3 Compare February 19, 2025 02:37
@edgarrmondragon edgarrmondragon marked this pull request as ready for review February 19, 2025 03:00
@edgarrmondragon edgarrmondragon marked this pull request as draft February 19, 2025 04:34
@edgarrmondragon
Copy link
Collaborator Author

I'm curious what you think of this approach @henryiii, and whether this is something Nox should support upstream.

@henryiii
Copy link

This seems fine, and I've been considering the proper way to do this upstream; though what I want to do there is to integrate with needs, so sessions could request and install the produced files.

Not really related, but nox-poetry should be able to use the new plugin support, too, by adding this to the top of a user's noxfile:

/// script
dependencies = ["nox", "nox-poetry"]
///

@henryiii
Copy link

henryiii commented Feb 19, 2025

Oh, also, picking the output name out is potentially a bit fragile; wouldn't it be better to use build's API?

https://build.pypa.io/en/stable/api.html#build.ProjectBuilder.build

@edgarrmondragon edgarrmondragon mentioned this pull request Feb 19, 2025
@edgarrmondragon
Copy link
Collaborator Author

edgarrmondragon commented Feb 21, 2025

Oh, also, picking the output name out is potentially a bit fragile; wouldn't it be better to use build's API?

https://build.pypa.io/en/stable/api.html#build.ProjectBuilder.build

That was the initial approach (1dc3bb4) but there were some problems with it:

  1. There's no public wrapper around1

       if (
           self._runner.global_config.no_install
           and self._runner.venv is not None
           and self._runner.venv._reused
       ):
           return None

    that would allow us to skip building the package, so that seems even more fragile than relying on stable output from build.

  2. Because we install Poetry into the same venv as nox-poetry for testing, and because Poetry 1.6.1 depends on ^0.10.02, we end up with build being downgraded to a version with an incompatible API. We probably should be installing Poetry in an isolated venv anyway, so this is less of an issue than point 1.

Footnotes

  1. https://github.com/wntrblm/nox/blob/e24511de21dc454a32697ff99fe8b2f8ebb0edab/nox/sessions.py#L534-L539

  2. https://github.com/python-poetry/poetry/blob/719831a759e7e37e010b65ff7dad926977e27fd1/pyproject.toml#L37

@edgarrmondragon edgarrmondragon merged commit 46fb7b4 into main Feb 21, 2025
18 checks passed
@edgarrmondragon edgarrmondragon deleted the fix/use-build-frontend branch February 21, 2025 03:38
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Root package uninstallation breaks with Poetry 2.1.0
2 participants