-
Notifications
You must be signed in to change notification settings - Fork 52
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 simple, explicit CLI to install a .whl file #92
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6599a8c
Add simple, explicit CLI to install a .whl file
takluyver 6eaf6e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1cffdcd
Add mising docstrings
takluyver bc84d6a
Add periods to docstrings
takluyver 4a23b5e
Make --platlib optional
takluyver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"""CLI - run as python -m installer.""" | ||
import argparse | ||
|
||
from . import install | ||
from .destinations import SchemeDictionaryDestination | ||
from .sources import WheelFile | ||
|
||
|
||
def main(): | ||
"""Entry point for CLI.""" | ||
ap = argparse.ArgumentParser("python -m installer") | ||
ap.add_argument("wheel_file", help="Path to a .whl file to install") | ||
|
||
ap.add_argument( | ||
"--interpreter", required=True, help="Interpreter path to be used in scripts" | ||
) | ||
ap.add_argument( | ||
"--script-kind", | ||
required=True, | ||
choices=["posix", "win-ia32", "win-amd64", "win-arm", "win-arm64"], | ||
help="Kind of launcher to create for each script", | ||
) | ||
|
||
dest_args = ap.add_argument_group("Destination directories") | ||
dest_args.add_argument( | ||
"--purelib", | ||
required=True, | ||
help="Directory for platform-independent Python modules", | ||
) | ||
dest_args.add_argument( | ||
"--platlib", | ||
required=True, | ||
help="Directory for platform-dependent Python modules", | ||
) | ||
dest_args.add_argument( | ||
"--headers", required=True, help="Directory for C header files" | ||
) | ||
dest_args.add_argument( | ||
"--scripts", required=True, help="Directory for executable scripts" | ||
) | ||
dest_args.add_argument( | ||
"--data", required=True, help="Directory for external data files" | ||
) | ||
args = ap.parse_args() | ||
|
||
destination = SchemeDictionaryDestination( | ||
{ | ||
"purelib": args.purelib, | ||
"platlib": args.platlib, | ||
takluyver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"headers": args.headers, | ||
"scripts": args.scripts, | ||
"data": args.data, | ||
}, | ||
interpreter=args.interpreter, | ||
script_kind=args.script_kind, | ||
) | ||
|
||
with WheelFile.open(args.wheel_file) as source: | ||
install( | ||
source=source, | ||
destination=destination, | ||
additional_metadata={}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this support installing the wheel file if passed as a glob, like
dist/*.whl
?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.
No, it won't be unglobbed in Python, but why would it not be unglobbed in the shell?
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.
Currently we invoke
python setup.py install
while in the package directory, maybe we should make thewheel_file
argument optional and autodetect the dist folder and install from there if present and a.whl
file is there.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 will work if the shell expands the glob to a single wheel. At present, it won't accept multiple wheels to install - that's easy enough to do if necessary, but I wanted to start with the simplest thing.
I think the crucial 'what to install' input should be 100% explicit. That's in keeping with the general pattern of this library. If you know there's a single wheel under
dist
, and you're running it from a shell, you can passdist/*.whl
and let the shell expand it.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.
Oh, not wanting it to do that, just pick up a single wheel from dist actually.
Yeah, was going to do something like that otherwise, figured would be kinda nice to have similar semantics to existing install methods. Maybe have it use only the newest file in
dist/*.whl
would make sense or something if a glob is passed?