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

Add _supported_features() #133

Merged
merged 2 commits into from
Oct 18, 2021
Merged

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Oct 13, 2021

Pip needs a mechanism to detect if build_editable is supported, in order to properly support legacy editable installs for projects that also have a pyproject.toml.

We provide the information with a _supported_hooks hook.

Other frontends should normally not need this. Should it be the case, a proper mechanism to expose backend capabilities should standardized.

See pypa/pip#10577 (comment) for more information.

@sbidoul
Copy link
Member Author

sbidoul commented Oct 13, 2021

Not sure why this is red. Did I manage to unearth a flake8 bug ?

@takluyver
Copy link
Member

It looks like a flake8 update may have broken things:

PyCQA/flake8#1419
tholo/pytest-flake8#81

Comment on lines 114 to 115
for hook_name in sorted(HOOK_NAMES)
if hook_name != "_supported_hooks" and hasattr(backend, hook_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because HOOK_NAMES is a set, we could use set arithmetic HOOK_NAMES - {"_supported_hooks"} to exclude this name. Up to you - I find code using sets pretty clear, but I know it's not to everyone's taste.

@takluyver
Copy link
Member

I'm happy enough with this as a private fix for pip.

One minor concern if we're one day going to make it a public API: most of the optional hooks have a specified fallback behaviour, which this library provides, so a frontend can call them without needing to know whether they're implemented or not. I don't know whether leaving them off a list of 'supported' hooks is good communication. I might be inclined to do something specific for build_editable, unless someone has a use case where checking the other hooks this way is useful.

@sbidoul
Copy link
Member Author

sbidoul commented Oct 13, 2021

How about _supported_features() that returns a list of strings. The only possible one for now being "build_editable" ?

@sbidoul sbidoul changed the title Add _supported_hooks Add _supported_features() Oct 13, 2021
@sbidoul
Copy link
Member Author

sbidoul commented Oct 13, 2021

How about _supported_features() that returns a list of strings. The only possible one for now being "build_editable" ?

I did that and constrained the flake8 version to workaround the issue.

@sbidoul
Copy link
Member Author

sbidoul commented Oct 15, 2021

@takluyver let me know if this is now good for you.

Also as the next pip bugfix release will depend on a pep517 release, are there any pending blocker to such a release ?

@pradyunsg
Copy link
Member

@takluyver nudge.

@takluyver
Copy link
Member

That looks fine, thanks.

@takluyver takluyver merged commit 7452fa7 into pypa:main Oct 18, 2021
@sbidoul sbidoul deleted the add-supported-hooks-sbi branch October 18, 2021 09:14
@takluyver
Copy link
Member

Released as 0.12. Sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants