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
Setuptools should always use its own implementation when upgrading #315
Comments
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): Committed technique has other issues:
|
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): That error emerged in this Travis-CI run. I believe what's happening is that by removing the setuptools modules from sys.modules (and re-importing it in a different context), the monkey-patched version in distutils no longer reflects the Distribution used by the current context. |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): I tried also removing distutils from |
Original comment by pje (Bitbucket: pje, GitHub: pje): Per your request for comment on the other issue, the way I handled these kinds of issues was to avoid them occurring in the first place, or, failing that, have installation fail with a message indicating a requirement to install setuptools in a separate process. i.e., this is why ez_setup always refused to update an existing version of setuptools. IOW, I never had any reasonably straightforward solutions for this problem, and so designed around it. Good luck. ;-) |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): The two tests that are failing with the use of
Interestingly, TestSetupRequires.test_setup_requires_overrides_version_conflict also calls reset_start_stop_context, but that test doesn't appear to be affected by hide_modules. |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): On further examination, I think my last comment was wrong. The use of hide_modules should not break reset_start_stop_context, but would actually obviate it. For TestUserInstallTest.test_setup_requires, I now think the issue is the patching of |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): The issue with the second failure in setup_test_requires_honors_fetch_params appears to be that the |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): The fact that invocations of |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): I've pushed a couple of fixes and now tests are passing again. I'm not particularly happy with the fixes. They seemed very heavy-handed and somewhat convoluted. I wouldn't expect myself to understand them in a few months, much less anybody else. For now, these changes are in the issue-315 bookmark. |
Original comment by embray (Bitbucket: embray, GitHub: embray): Is there some way you could summarize what finally actually changed here? This broke a lot of stuff for me. Lots of |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): The main change is that in sandbox.py in setup_context, hide_setuptools is invoked and in save_modules, exceptions are serialized (if possible) to transform any exceptions from the sandboxed versions to their natural form. The intention here is that anything invoked in a 'setup_context' will re-import setuptools and distutils for the duration of that context, allowing the latest setuptools call to be used during an upgrade of setuptools. It's meant to provide subprocess-like isolation without actually invoking the command in a separate process. |
Original comment by embray (Bitbucket: embray, GitHub: embray): Thanks Jason, I think that explains what's happening then. This seems to only be a problem in my tests, where I'm testing setuptools plugins using |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):
That's the intention, but it also attempts to serialize and re-hydrate (using pickle) any exceptions so that those exceptions can be trapped by services outside of the context. I'm surprised the re-hydration doesn't allow your tests to run as expected. Can you point me to a use case that fails, because setuptools uses run_setup in its own unit tests (and in upgrades) with success. |
Original comment by richardipsum (Bitbucket: richardipsum, GitHub: richardipsum): Thanks for fixing this! With this issue resolved would a pull request to add the setup_requires metadata back be welcome? |
Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco): @richardipsum That was my intention after it stabilized. A PR isn't necessary but would help serve as a reminder. Thanks. |
Original comment by embray (Bitbucket: embray, GitHub: embray):
This came up specifically in the test suite for astropy-helpers (I suspect it might also affect the d2to1 tests but I haven't checked yet. I won't send you digging around, but this test should give the basic idea of the kind of tests we're talking about. The reason this broke for me is that the astropy-helpers test suite goes through loops to test In any case, I have a workaround for now that I'm pretty okay with. Having an option in |
Original comment by stefanholek (Bitbucket: stefanholek, GitHub: stefanholek): Since hide_setuptools has gone in, I have tests that hang the interpreter instead of raising setuptools.sandbox.SandboxViolation. This is presumably because the necessary stack frames have disappeared. Once I remove hide_setuptools, SandboxViolations are propagated again. To reproduce with the setuptools test suite, I looked at TestUserInstallTest.test_setup_requires in test_easy_install.py. First I needed to make sure user installs are enabled for the test. Then I removed the fix for 318 to see the SandboxViolation triggered. Instead I got a hang. Without hide_setuptools the exception is raised as expected. Apply the patch below to try for yourself:
I'd prefer to continue without hide_setuptools as it seems brittle and prone to causing hard to debug problems. Especially in tests that themselves use fixtures and mocks I can see it wreaking all kinds of havoc. Thank you. |
Original comment by vaab (Bitbucket: vaab, GitHub: vaab): d2to1 appears to be broken by this. It nailed down to:: https://bitbucket.org/pypa/setuptools/commits/f29ad5f78ef72f1712e29acfea92a6f5ca47b428 Which brings me here. The case is that
Travis just changed their VM and upgraded setuptools to version >= 10, and I have 10+ project that relies on On Travis, I'm forcing now to downgrade |
Original comment by embray (Bitbucket: embray, GitHub: embray): Ah, I hadn't even tried it with d2to1 yet since where we use it locally we haven't upgraded setuptools to >= 8.0 yet for our clients. I wonder if OpenStack has encountered this though, since pbr is more or less a fork of d2to1. I think probably worse comes to worse the workaround I used in astropy-helpers to just monkey-patch hide_setuptools to be a no-op should work for now. |
Originally reported by: jaraco (Bitbucket: jaraco, GitHub: jaraco)
In #314, Tres reported that Setuptools cannot upgrade itself if new metadata is present which references functionality not available in the version being upgraded. It should be possible and straightforward to always use the code from the version being installed to install that version.
The text was updated successfully, but these errors were encountered: