-
Notifications
You must be signed in to change notification settings - Fork 5
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
Proof of concept: Add --pip-platform
flag.
#246
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import logging | ||
import subprocess | ||
import os | ||
|
||
|
||
_log = logging.getLogger(__name__) | ||
|
@@ -25,13 +26,33 @@ def usable_in(ctx): | |
) | ||
|
||
def __call__(self, ctx, dsp): | ||
python_path = str(ctx.python_runtime_dir / ctx.python_rel_exe) | ||
|
||
platform_flags = [] | ||
if ctx.pip_platform: | ||
platform_flags.append('--platform={}'.format(ctx.pip_platform)) | ||
platform_flags.append('--only-binary=:all:') | ||
# TODO: This should probably be done with the spawn helpers, but | ||
# done this way as a proof of concept | ||
site_packages_path = subprocess.check_output([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this check: what's the objective? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not specifically a check, but it is trying to retrieve the "site_packages" path, this path is needed to use the |
||
python_path, | ||
'-c', | ||
'import site; print(site.getsitepackages()[0], end="")' | ||
]) | ||
site_packages_path = site_packages_path.decode("utf-8") | ||
if os.path.isdir(site_packages_path): | ||
platform_flags.append('--target') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which cases is this needed? AFAICT, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to use |
||
platform_flags.append('{}'.format(site_packages_path)) | ||
else: | ||
raise Exception("Invalid site-packages directory: {}".format(site_packages_path)) | ||
|
||
cmd = [ | ||
str(ctx.python_runtime_dir / ctx.python_rel_exe), | ||
python_path, | ||
'-m', | ||
'pip', | ||
'install', | ||
'--no-warn-script-location', | ||
*platform_flags, | ||
ctx.src_wheel, | ||
] | ||
|
||
|
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.
Hey @carlosperate, picking this up quite a while later... What about having a variation of the
launch_pyflags
that could be passed zero/one/more times to havepup
use those flags withpip
? That's basically the behaviour oflaunch_pyflags
.Might make the implementation simpler and more versatile at the same time.
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.
Yeah, that's fine with me, feel free to refactor this PR as you see fit 👍