-
Notifications
You must be signed in to change notification settings - Fork 149
Add bootstrap install script for flit_core #481
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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
This file contains hidden or 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,37 @@ | ||
| """Install flit_core without using any other tools. | ||
|
|
||
| Normally, you would install flit_core with pip like any other Python package. | ||
| This script is meant to help with 'bootstrapping' other packaging | ||
| systems, where you may need flit_core to build other packaging tools. | ||
|
|
||
| Pass a path to the site-packages directory or equivalent where the package | ||
| should be placed. If omitted, this defaults to the site-packages directory | ||
| of the Python running the script. | ||
| """ | ||
| import os | ||
| import sys | ||
| import sysconfig | ||
| from tempfile import TemporaryDirectory | ||
| from zipfile import ZipFile | ||
|
|
||
| from flit_core import build_thyself | ||
|
|
||
| os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
|
|
||
| if len(sys.argv) == 2: | ||
| dest = sys.argv[1] | ||
| if not os.path.isdir(dest): | ||
| sys.exit("Destination path must already be a directory") | ||
| elif len(sys.argv) == 1: | ||
| dest = sysconfig.get_path('purelib') | ||
| else: | ||
| sys.exit("Specify 0 or 1 arguments (destination directory)") | ||
|
|
||
| with TemporaryDirectory(prefix='flit_core-bootstrap-') as td: | ||
| print("Building wheel") | ||
| whl_fname = build_thyself.build_wheel(td) | ||
| whl_path = os.path.join(td, whl_fname) | ||
|
|
||
| print("Installing to", dest) | ||
| with ZipFile(whl_path) as zf: | ||
| zf.extractall(dest) | ||
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.
Can we have argparse arguments that split the build and install stages up? It would also be handy to have a
--rootflag along the lines of ensurepip/distutils/setuptools since we need to redirect the install location when cross compiling.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.
There's nothing to actually do with
--roothere - that only matters if you install scripts, which this doesn't. For this scenario, you'd just prefix it to the target path, e.g.${ROOT}/usr/lib/pythonX.Y/site-packages.The commands to do this in separate build & install steps already exist 😉 :
The only real difference in this new script is that it skips building the sdist. The Python zipfile module also has a CLI if that's easier than using the unzip command.