-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
use poetry to manage deps for isolated build envs #9168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial points
c2c6a97
to
6b2c664
Compare
@Secrus @radoering let me know if functionally anything needs to change. If not, I can tidy the commit up and make the PR ready once #9132 is merged - it should have an impact on the test cases. |
I guess it's a replacement for #5650? |
Oh hey, past me had the same idea. Few things I might actually borrow from that one. Thanks for pointing that out. |
6b2c664
to
68690fe
Compare
68690fe
to
6bfe7dc
Compare
35aef86
to
5cb5668
Compare
@abn did you maybe check the performance of this? In your previous attempt at #5650 you mentioned there was some performance regression |
It does still incur the solving penalty. But overall the test suite is faster by a little bit for the following reason.
Overall I think this improves our posture. The next step for this would be to optimize cached build environments or removing the solver penalty. We can basically allow for the latest matching versions to be installed fairly confidently. |
The test suite is one thing, but did you check what the actual perf regression is? Is it within ~10% or more? |
The reason I am asking is that I would like us to know how serious we should be about improving the performace. Should that be next PR, but before next version release or can it be something down the line because the ecosystem is now in a better place and this path won't be hit that often? |
The test suite is a good indicator for any major hits. Since we do not really have empirical data for the old build mechanism, we will have to try doing some experiments. I'll see what I can do. Finger in the air, I'd say for majority cases (simple/common build require combinations) we would be quicker than subprocess pip install. And for the other cases, it will depend on the build requires constraints. This change also brings with it some additional benefits that offset performance impact.
|
Did a quick hacky evaluation using the following snippet. from pathlib import Path
from poetry.inspection.info import get_pep517_metadata
if __name__ == '__main__':
_ = get_pep517_metadata(Path("tests/fixtures/project_with_setup")) I ran this script 100 times and timed it. Poetry 1.8.2
PR 9168
On average the performance hit is 0.02 seconds per run. |
Our nemesis of build requirements is probably In a quick real-world test, I could not observe a regression either. |
Previously, isolated build environments needed for both package installation from sdist and for fallback package metadata inspection used to rely on inline scripts and delegated management of build requirements to the build package. With this change, Poetry manages the build requirements. This enables the use of build requirements from the current projects source, Poetry's configurations and also cache. We also, reduce the use of subprocesses and thereby increasing speeds of such builds.
5cb5668
to
364d16e
Compare
@abn merging this into the "remove the setup reader" pull request causes quite a lot of test failures with stacks ending like
have not yet dug into this but suspect a bug in this one? will make similar comment in that MR for visibility, apologies if you see both! |
@dimbleby the build is expected to run within a project context. You can add something like this to the suite. @pytest.fixture(autouse=True)
def use_project_context(set_project_context: SetProjectContext) -> Iterator[None]:
with set_project_context("sample_project"):
yield Alternatively, if the assumption that the isolated builder is only ever setup within a project context is wrong we might need to handle this in the isolated builder context. This is the relevant line in the isolated builder. 364d16e#diff-0194c9a7c832a9f4c5679a65bd325520b6bab0c2fde3e3152c38f2aa7b64f49dR121 |
oh awkward. we probably ought to have been passing the |
Yeah, ideally it would have been nice to have the poetry instance during inspection too, but that would require some additional work I reckon. For now, I have raised #9180 to soften the issue. |
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. |
Previously, isolated build environments needed for both package installation from sdist and for fallback package metadata inspection used to rely on inline scripts and delegated management of build requirements to the build package.
With this change, Poetry manages the build requirements. This enables the use of build requirements from the current projects source, Poetry's configurations and also cache. We also, reduce the use of subprocesses and thereby increasing speeds of such builds.
Closes: #5650