-
Notifications
You must be signed in to change notification settings - Fork 4
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
install-wheel: add support for specifying python startup flags #13
base: master
Are you sure you want to change the base?
Conversation
2d14514
to
8c7405b
Compare
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.
Please don't forget to handle updates to your "prerequirement" upstream PR and finally file this as a PR for upstream.
@@ -240,14 +240,17 @@ def install_wheel_impl(args, wheel: Path): | |||
from installer.sources import WheelFile | |||
from installer.utils import get_launcher_kind | |||
|
|||
from .scheme import Gpep517WheelDestination |
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.
I don't use relative imports. Be consistent.
gpep517/scheme.py
Outdated
# SPDX-FileCopyrightText: | ||
# SPDX-License-Identifier: MIT | ||
|
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.
While these headers are all fun, they're inconsistent with the rest of the codebase.
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.
I see I forgot to update the first line to include the pypa/installer copyright line.
I don't care what format the headers are in, and I'm not trying to be "fun". I do, however, think that it is important when you are copying code from another project to state where you got it, who wrote it, and what it's licensed under. That is the purpose of having a separate copyright declaration that is not part of "the rest of the codebase".
gpep517/scheme.py
Outdated
|
||
from __future__ import annotations | ||
|
||
import contextlib, io, os, shlex, zipfile |
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.
Split imports.
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.
Bit disappointing tbh... all it does is make files longer and more annoying to scroll down to the actual content, but so be it.
from __future__ import annotations | ||
|
||
import contextlib, io, os, shlex, zipfile | ||
import typing as T |
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.
Inconsistent.
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.
Again, all this does is make files longer and more annoying to read, since most type annotations suddenly gain an additional 5 characters of overhead towards the max line length.
Either that or you spend more time managing individual from typing import Foo, Bar, Baz
imports than you spend coding.
# with minor tweaks where classes don't have hooks to control their | ||
# internals. | ||
|
||
from __future__ import annotations |
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.
Is this really needed?
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.
It is required to make if T.TYPE_CHECKING
imports not be runtime errors. It is also a small performance improvement for all code that has type annotations, period.
Type annotations are not needed at runtime unless you're using something like beartype or pydantic. Building them into code objects and discarding them is a bit wasteful.
The import is equivalent to surrounding all type annotations with quotes. I find the future import to be more ergonomic, and could add it to other files if you like... ?
3e79825
to
2b65308
Compare
``` gpep517 install-wheel --shebang-flags='-s' ``` will cause all /usr/bin scripts to pass `-s` to the interpreter in its shebang. Useful for ensuring that system commands do not import mismatched modules from `pip install --user`. Also useful in theory to produce programs that run via -OO, something the python ecosystem rarely remembers is possible because scripts cannot be easily fine-tuned and short of changing the entrypoint script you cannot activate -O. Perhaps we could change that.
2b65308
to
07241af
Compare
Updated. |
Any update on what I should do here? Upstream PyPA/installer hasn't merged any PRs in months other than pre-commit.ci spam and isn't responsive to requests for review. Are we still waiting on them or is it fine to reimplement functionality locally? Are there any responses to the answers I gave on review comments where I disagreed with the review? |
will cause all /usr/bin scripts to pass
-s
to the interpreter in its shebang. Useful for ensuring that system commands do not import mismatched modules frompip install --user
.Also useful in theory to produce programs that run via -OO, something the python ecosystem rarely remembers is possible because scripts cannot be easily fine-tuned and short of changing the entrypoint script you cannot activate -O. Perhaps we could change that.