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

Handle setup.py possibly using sys.exit #3975

Merged
merged 5 commits into from
Aug 15, 2023
Merged

Conversation

arcivanov
Copy link
Contributor

Summary of changes

Since setup.py is an arbitrary Python script legacy scripts my be complex and may use sys.exit.
To adhere to PEP 517 handle SystemExit exception by ignoring it with exit code 0 and converting it to CalledProcessError(exit_code, 'setup.py') in case of non-zero exit code.

fixes #3973

Pull Request Checklist

  • Changes have tests
  • News fragment added in [newsfragments/].
    (See [documentation][PR docs] for details)

@arcivanov arcivanov marked this pull request as draft July 7, 2023 20:17
@arcivanov arcivanov marked this pull request as ready for review July 7, 2023 20:20
@abravalheri
Copy link
Contributor

Thank you very much for the PR @arcivanov. I rebased the code on top of the main branch which should have fixed all pre-existing test errors.

@arcivanov arcivanov force-pushed the issue_3973 branch 4 times, most recently from 2894deb to e3131c9 Compare August 5, 2023 05:17
arcivanov and others added 2 commits August 7, 2023 17:20
Since `setup.py` is an arbitrary Python script legacy
scripts may be complex and may use `sys.exit`.
To adhere to PEP 517 handle `SystemExit` exception
by ignoring it with exit code `0` and converting it to
`CalledProcessError(exit_code, 'setup.py')` in case of
non-zero exit code.

fixes pypa#3973
In the case `SystemExit(0)` is generated to indicate success,
we just emit a deprecation error (the dev is writing `setup.py`
as if it was a CLI script, instead of a configuration-only file).
@abravalheri
Copy link
Contributor

Hi @arcivanov, to avoid back and forth in the review I added a commit implementing the outcome of the issue discussion and I tried to reduce the number of tests being executed (test_build_meta has a few cartesian products).

I hope that is OK with you (otherwise, please feel free to revert the commits and do something different).

@abravalheri abravalheri merged commit 3418d5d into pypa:main Aug 15, 2023
21 checks passed
@arcivanov arcivanov deleted the issue_3973 branch August 15, 2023 18:37
@arcivanov
Copy link
Contributor Author

Thank you!

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.

[BUG] sys.exit(0) in setup.py breaks PEP 517 hooks API
2 participants