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

Fallback to pep517 if setup.py is present and setuptools cannot be imported #10717

Merged
merged 5 commits into from
Apr 23, 2022

Conversation

hrnciar
Copy link
Contributor

@hrnciar hrnciar commented Dec 8, 2021

This is WIP PR without any documentation or tests. I'd like to first know your opinion whether the idea is acceptable. Thank you.

@pfmoore
Copy link
Member

pfmoore commented Dec 8, 2021

I'm inclined to agree with the suggestion @uranusjr made on Discourse - if there's no setup.py and setuptools cannot be imported, the only possible thing that will work is to use PEP 517, so why not do that? Which means this PR can simply be "use PEP 517 if setuptools cannot be imported".

@hroncok
Copy link
Contributor

hroncok commented Dec 9, 2021

I'd argue that when the user explicitly used --no-pep517 and setuptools is not installed, that deserves an error.

@hroncok
Copy link
Contributor

hroncok commented Dec 9, 2021

That combined basically means something like:

    ... elif not has_setuptools:
        if use_pep517 is not None and not use_pep517:
            raise InstallationError(
                "Disabling PEP 517 processing is invalid: "
                "setuptools not installed"
            )
        use_pep517 = True

@uranusjr
Copy link
Member

uranusjr commented Dec 9, 2021

The “can’t do --no-use-pep517 because setuptools is not found” error can even be raised as early as command argument parsing, instead of half-way into package installation.

@hrnciar hrnciar force-pushed the fallback-to-pep517 branch 3 times, most recently from 2af305c to 7fb607b Compare December 10, 2021 14:54
elif use_pep517 is None:
use_pep517 = has_pyproject
use_pep517 = has_pyproject or not importlib.util.find_spec("setuptools")
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that the setuptools check can be technically made much sooner in this function, but this way, it is avoided when not necessary. Not sure which approach is better.

@pradyunsg
Copy link
Member

pradyunsg commented Dec 10, 2021

FWIW, I was hoping to go down a different avenue here: dc217bb

That presents a clearer error message instead of opting these projects into PEP 517.

@hroncok
Copy link
Contributor

hroncok commented Dec 10, 2021

At least to me, opting to PEP 517 when setuptools is not installed sounds like a more user-friendly thing to do than erroring out (and gradually downloading a lesser and lesser version of the package only to error again and again).

@pradyunsg
Copy link
Member

Yea... #10655 is annoying.

It seems to me that there's reasonable agreement that we should stop backtracking on build failures, which combined with better presentation of build failures (I'll file this as a PR once #10703 merges) could be a more "complete" solution here; rather than needing to change this one special case?

@hroncok
Copy link
Contributor

hroncok commented Dec 10, 2021

Even without backtracking, I still think that using PEP 517 when setuptools is not present is the nicer thing to do, but I won't fight you on that. A better error report and no backtracking makes this good enough for me.

@pradyunsg
Copy link
Member

Thinking about this a bit more, I think we should do all three things: this PR, #10722 and #10723. They're all better behaviours, and I think it's totally reasonable for us to do all of them.

@hrnciar hrnciar force-pushed the fallback-to-pep517 branch 3 times, most recently from 7fb607b to eb1c8f3 Compare January 3, 2022 12:27
@hrnciar
Copy link
Contributor Author

hrnciar commented Jan 4, 2022

I was trying to solve the CI issues, but I ran into some test failures. I don't think they are caused by this PR, because I am getting the same failures when I run the tests on the main branch locally. If that's the case, I think PR is ready for review.

@hrnciar hrnciar marked this pull request as ready for review January 4, 2022 12:09
@uranusjr
Copy link
Member

uranusjr commented Jan 4, 2022

Those are caused by #10742, don’t mind them.

@hroncok
Copy link
Contributor

hroncok commented Jan 18, 2022

Is this ready to be merged, or do we need to change something?

@github-actions github-actions bot added the needs rebase or merge PR has conflicts with current master label Jan 27, 2022
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Mar 2, 2022
@hroncok
Copy link
Contributor

hroncok commented Mar 30, 2022

What si the next step here?

@uranusjr
Copy link
Member

Anyone else wants to take a look? If not I’m inclined to include this in the 22.1 release.

@uranusjr uranusjr added this to the 22.1 milestone Mar 30, 2022
Copy link
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

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

One minor point, but otherwise LGTM

src/pip/_internal/cli/cmdoptions.py Outdated Show resolved Hide resolved
@hroncok
Copy link
Contributor

hroncok commented Mar 30, 2022

I would still prefer this not be wrapped.

So, use a long line or split the string literal?

@pfmoore
Copy link
Member

pfmoore commented Mar 30, 2022

use a long line or split the string literal?

Ultimately whatever stops black whining about the layout, I don't really care 🙂 If I were writing this without regard for black, I'd use a long line.

@uranusjr
Copy link
Member

I added a commit to split the literal.

@hroncok

This comment was marked as resolved.

@uranusjr

This comment was marked as resolved.

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

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

Ok with the concept and implementation LGTM. Does our test suite lend itself to adding a test case for this ?

news/10717.bugfix.rst Outdated Show resolved Hide resolved
@uranusjr
Copy link
Member

This needs a rebase to fix CI.

news/10717.bugfix.rst Outdated Show resolved Hide resolved
@pradyunsg pradyunsg merged commit 452d7da into pypa:main Apr 23, 2022
@pradyunsg
Copy link
Member

Thanks @hrnciar! Hopefully me short-circuiting the CI because of my lack of patience won't bite me (eg: because the linters were updated). :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
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.

7 participants