Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

build.script: use build environment for execution #5401

Merged
merged 1 commit into from
May 11, 2022

Conversation

abn
Copy link
Member

@abn abn commented Apr 2, 2022

With this change, Poetry now creates an ephemeral build environment
with all requirements specified under build-system.requires when a
build script is specified. Otherwise, project environment is reused.

Resolves: #2789
Supercedes: python-poetry/poetry-core#58

Decided to solve this at the poetry level as we do not yet have consensus on if the build-system requirements should be considered as a project's development dependendency.

Alternative approaches

  • build-system.requires is loaded into a new implicit dependency group callded build-system, this will mean that these will affect dependency resolution. However, this will also allow for the easier development of build scripts.

Future Enhancements

  • The build environment is cached within the project's virtual environment. This will require Poetry to handle entire life-cycle if the dependencies change etc. This might also cause issues with system environments. However, this will also provide speedups.
  • Reuse Poetry's internal wheel fetch logic instead of relying on pip.

@yajo
Copy link

yajo commented May 2, 2022

This doesn't solve the problem of buidl-system.requires not being locked in poetry.lock, does it?

IMHO they should be locked there too, or we can't really have reproducible builds.

@abn
Copy link
Member Author

abn commented May 2, 2022

@yajo unfortunately this PR is not intended to solve that.

Additionally, there is also the added issue that the build time dependency is managed by the PEP 517 frontends. The short version is, even if the lockfile contained your build system depdnencies your builds will not be reproducible across all cases. The only case it covers if you used poetry build. The only way to achieve reproducible builds is to lock the version in your pyproject.toml build-system.requires. Obviously, this will have to be manually managed.

@abn abn force-pushed the build-script-environment branch from 003f55d to bc49f54 Compare May 7, 2022 17:48
@abn abn mentioned this pull request May 10, 2022
@abn abn force-pushed the build-script-environment branch from bc49f54 to ca73fa5 Compare May 10, 2022 23:00
src/poetry/console/commands/build.py Outdated Show resolved Hide resolved
src/poetry/utils/env.py Show resolved Hide resolved
@abn abn force-pushed the build-script-environment branch from ca73fa5 to 466b15e Compare May 11, 2022 12:23
@abn abn requested a review from neersighted May 11, 2022 12:24
src/poetry/utils/env.py Show resolved Hide resolved
src/poetry/utils/env.py Outdated Show resolved Hide resolved
src/poetry/utils/env.py Show resolved Hide resolved
With this change, Poetry now creates an ephemeral build environment
with all requirements specified under `build-system.requires` when a
build script is specified. Otherwise, project environment is reused.
@abn abn force-pushed the build-script-environment branch from 466b15e to 9ba9845 Compare May 11, 2022 14:09
@ghost
Copy link

ghost commented Sep 2, 2022

note for future searchers: poetry 1.2.0 broke our previously successful builds (where we use a custom build = 'script.py' setting) until we added setuptools manually as:

[build-system]
requires = ["poetry-core", "setuptools"]

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poetry build does not install build dependencies (affects both install and build)
3 participants