-
Notifications
You must be signed in to change notification settings - Fork 0
[PEP 771] Experimental implementation of supporting [] disabling default extras #1
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
base: pep_771
Are you sure you want to change the base?
Conversation
In theory the idea is good - I was thinking about playing with I would agree with you that the magic value is near impossible to collide. I don't know how "excited" Paul will be about this idea ... In general "magic values" are not regarded as "best practice". Though I agree with the objective, I really believe |
I needed more time to investigate @astrofrog if you could choose, which one you think is a better design:
If we are honest with ourselves, even the second approach is a "magic value", we just give different meanings to |
I don't have strong feelings about the approach but agree an approach without a magic value would be preferable - I wanted to check that at least there is at least one solution, which I think there is, so now we can just try and find a better one 😄 . We could indeed try internally to distinguish between extras being set to |
I agree that it looks better than I initially thought - but until we manage to get a full implementation that passes the PIP unittests, we probably shouldn't claim it works. I still have problems with |
FYI I've pushed a quick fix for |
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.
Inside src/pip/_internal/resolution/resolvelib/factory.py
you're missing an import:
from pip._internal.req.constructors import MAGIC_EXPLICIT_EMPTY_EXTRAS
I'm getting the following error: pip install pep-771-demo-a[]
Looking in indexes: https://pypi.org/simple, https://mockhouse.wheelnext.dev/pep-771/
Collecting pep-771-demo-a
Using cached https://mockhouse.wheelnext.dev/pep-771/pep-771-demo-a/pep_771_demo_a-1.0.0-py3-none-any.whl (1.1 kB)
WARNING: pep-771-demo-a 1.0.0 does not provide the extra '8c950990-39f5-4fe5-920f-0981cbcb3236'
Ignoring flask: markers 'extra == "flask"' don't match your environment
[notice] A new release of pip is available: 25.0.dev0+pep.771 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
ERROR: Exception:
Traceback (most recent call last):
File "/workspace/pip/src/pip/_internal/cli/base_command.py", line 106, in _run_wrapper
status = _inner_run()
File "/workspace/pip/src/pip/_internal/cli/base_command.py", line 97, in _inner_run
return self.run(options, args)
~~~~~~~~^^^^^^^^^^^^^^^
File "/workspace/pip/src/pip/_internal/cli/req_command.py", line 67, in wrapper
return func(self, options, args)
File "/workspace/pip/src/pip/_internal/commands/install.py", line 386, in run
requirement_set = resolver.resolve(
reqs, check_supported_wheels=not options.target_dir
)
File "/workspace/pip/src/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
result = self._result = resolver.resolve(
~~~~~~~~~~~~~~~~^
collected.requirements, max_rounds=limit_how_complex_resolution_can_be
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/workspace/pip/src/pip/_vendor/resolvelib/resolvers.py", line 551, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/workspace/pip/src/pip/_vendor/resolvelib/resolvers.py", line 432, in resolve
failure_causes = self._attempt_to_pin_criterion(name)
File "/workspace/pip/src/pip/_vendor/resolvelib/resolvers.py", line 254, in _attempt_to_pin_criterion
satisfied = all(
self._p.is_satisfied_by(requirement=r, candidate=candidate)
for r in criterion.iter_requirement()
)
File "/workspace/pip/src/pip/_vendor/resolvelib/resolvers.py", line 255, in <genexpr>
self._p.is_satisfied_by(requirement=r, candidate=candidate)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/pip/src/pip/_internal/resolution/resolvelib/provider.py", line 243, in is_satisfied_by
return requirement.is_satisfied_by(candidate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/workspace/pip/src/pip/_internal/resolution/resolvelib/requirements.py", line 110, in is_satisfied_by
assert candidate.name == self.name, (
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Internal issue: Candidate is not for this requirement pep-771-demo-a[8c950990-39f5-4fe5-920f-0981cbcb3236] vs pep-771-demo-a Welcome to the PIP debugging headache :D There's multiple
And then you have the very obvious fatal crash at the end (which is most likely unrelated to the two above). That's what I meant on DPO, it's very "delicate" to get the recipe working, the I recommend using a debugger, if you're familiar with VSCode I included some debugger configs here: https://github.com/wheelnext/pep_771/blob/main/.vscode/launch.json Feel free to use and customize as you need |
@DEKHTIARJonathan - I'll investigate! In the mean time, I was wondering whether it would be possible for you to enable the CI on this repo for this branch? (it might be we need to edit the actions workflow to not restrict the CI to the main branch?) |
While investigating this, I noticed that we need to update the implementation - in the PEP we now explicitly say that if none of the supplied extras are recognized, we should install the defaults. So |
Do you really think it's a good idea though ? I didn't want to shake to much on that on DPO. I think this can create confusion because it may "hide problems", instead of getting a "broken install" that forces you to look and check what's wrong (something is obviously wrong given you passed an extra that doesn't exist). Now you're getting a sort of "hot patch" that the user doesn't ask for, and potentially is unaware about... I have a feeling this is not so much of a good "user experience" behavior to have |
|
Sorry misclicked (I didn't want to close the PR) |
I think the The |
I agree that if we do indeed consider |
f661e7c
to
89abbd3
Compare
@DEKHTIARJonathan @henryiii - I've pushed a simplified implementation that should now work for the demo package with Of course this feels a little hacky but at the same time it is the easiest way to deal with the fact that pip has a complex stack, and I think it might be quite a bit more complex to use |
@astrofrog I'll give it a shot :) For me - so long as it "works" I'm happy with it. We can discuss "elegance and design preferences" all night long once the PEP is accepted ahaha. Let's just focus on "proving the point". @astrofrog since you prove that |
@astrofrog btw you have been given access to the WheelNext github org on Thursday. Feel free to push directly on the branch. If you just adapt the CI - you really don't need me to review that :) And since you modify that part, do you think you can bring back these externally defined jobs: https://github.com/wheelnext/pep_771/blob/main/.github/workflows/main.yml jobs:
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
envs: |
- linux: demoa-noextra
- linux: demoa-explicit
- linux: demoa-extra
- linux: demoa-minimal
- linux: demob-noextra
- linux: demob-explicit
- linux: demob-extra
- linux: demob-minimal That way we can have everything self-contained |
Yes I can do that, in fact I also need to make changes to reflect the use of [] for minimal installs in the first place. |
I'm mostly off work this week though, so it will probably be next week, let's see |
@DEKHTIARJonathan before making any updates I will wait for you to confirm whether the new [] implementation works though - just let me know! |
This works well
This doesn't work well
Ironically it's a problem I also have in my implementation - |
Thanks for the report! Will see if I can look into it soon. |
@DEKHTIARJonathan - apologies for the long delay in getting back to this. I can try and dive into it again, but wanted to check if you have made any progress in the meantime to avoid duplication of effort? |
Just for ease of testing, I adjusted the tox file from the pep_771 repo to test all the different cases you mentioned above (and more), and using the wheel from the wheelhouse - I've put this tox file here for now: https://github.com/astrofrog/tmp-pep771-pip-tests/blob/main/tox.ini This is separate from the pep_771 tox config we have for now since that builds the wheels on-the-fly for an end-to-end test - but because we install the wheels directly from the repos, we can't use the Running it on the current PR, I get:
which means that as you pointed out, the following don't work:
Now that I have an easy testing mechanism in place, it will be 'easier' to start trying to go through a solution that doesn't break other use cases. |
@henryiii @DEKHTIARJonathan - see astrofrog/peps#2 for a draft PR to track changes to the PEP |
@DEKHTIARJonathan - would it make sense to merge this so that at least some of the |
@DEKHTIARJonathan - I was playing around with finding a way to have
package[]
disable default extras as it seems to be something people are generally in favor of, and I found a way to make it work with minimal changes (though obviously this is not necessarily a complete implementation, it is just a proof of concept). The idea is that as as soon as a requirement is parsed, we insert a sentinel value which is a default extras name but unlikely to collide with a real extras name, and we later use that to determine if defaults should be ignored. We shouldn't merge this at this point because this is not what the PEP specifies yet, but just wanted to share it with you in case you had thoughts about it.