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

Provide a `get-pip.py`-like script for virtualenv #1

Open
asottile opened this Issue Oct 13, 2017 · 28 comments

Comments

Projects
None yet
5 participants
@asottile
Copy link

asottile commented Oct 13, 2017

I often find myself on a machine with near-zero permissions (or a chroot / docker container) and have used this script: https://github.com/asottile/asottile.github.io#bootstrap-a-virtualenv-from-nothing

Would love to get this or something like this hosted similar to get-pip.py

@stale

This comment has been minimized.

Copy link

stale bot commented Jan 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 14, 2019

I still think this is a good idea

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 14, 2019

@asottile make a PR with tests, add it to the documentation and we're ready then 👍

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 14, 2019

sounds good! as for design there's kind of two options -- which would you prefer:

  1. like get-pip.py: bundle the actual bits in the file itself
  2. like my script I linked above, reach out to pypi to download the tgz / wheel

(1) seems like a better idea but would like to get your opinion before working on it

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 14, 2019

I would prefer the second, cleaner. Note we might need to call a wheel build though, going ahead we no longer support sdist evaluation (as I'd like the horrible one file we have now split up and concatenated during build rather than on the repo, this would drop need of doing current embedded hack). That being said would it be possible to use pypi wheel as download as opposed to a GitHub file?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 14, 2019

option 1 is nice though if you don't have a network connection (think: vendor file in repo, able to create venvs without dependencies) -- doing the wheel would be fine as well (I was just using the sdist in my script for no good reason at the time)

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

I would still go down the path of wheel extract, python can natively unzip it. I mean the user will have to get the repo in some way or another, so some network must exist, not?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

Unless you're on macos :( it's crippled ssl implementation can't talk to pypi by default with just stdlib

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

isn't github also https?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

Yes but (for now) doesn't require tls 1.2 or whatever

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

And curl can take advantage of the other ssl implementation available on macos (pip does this) but urllib hasn't figured that out yet

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

Oh I see, in that case we just need to use either pip or curl, not?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

Then it fails the "bootstrap from just python" aspect :S

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

Somehow you need to get the bootstrapper on the machine though, not?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

yeah, but once you have the bootstrapper it should be able to do everything itself -- even my script above fails that category until you've got a decently-compiled python on macos (brew for instance)

this is why I'm leaning towards option 1

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

Isn't the wheel (perhaps wrapped beside a simple python script) able to do everything?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

yes, that's what I'm proposing :)

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

I'm on board with that. It could be another artefact we build upon release? Should we publish it on PyPi, or Github?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

I was hoping it could end up on https://bootstrap.pypa.io/get-virtualenv.py (similar to https://bootstrap.pypa.io/get-pip.py)

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 15, 2019

Let's have it ready then, and we'll try to get it up there. That being said from what we talked wouldn't it be https://bootstrap.pypa.io/get-virtualenv.zip?

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 15, 2019

could either be .py or .zip -- though I haven't done anything with PEP 441 yet (and from cursory glance it doesn't support py2). I was more thinking the same approach that get-pip.py uses -- it embeds the .whl in a string literal

@ncoghlan

This comment has been minimized.

Copy link
Member

ncoghlan commented Jan 17, 2019

The zipapp format has been supported since Python 2.6 - the only new parts in PEP 441 were the zipapp helper library for creating them, and the pyz file association on Windows.

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 17, 2019

oh perfect, that makes this even easier I think

@ncoghlan

This comment has been minimized.

Copy link
Member

ncoghlan commented Jan 17, 2019

Yeah, I think Py2.4 was still in broad use back when get-pip.py was designed, so you have nicer options available to you now :)

@pradyunsg

This comment has been minimized.

Copy link
Member

pradyunsg commented Jan 17, 2019

If someone does the work for packaging virtualenv in a zipapp for installation, it might be useful to consider adopting the same approach for pip too. Though, I'm not sure how the transition would be done.

"Modernize get-pip.py" has been in my mental TODO list since pip 10.0, but I never got to it because of the effort-reward ratio (low reward, high effort "fun" task).

@pfmoore

This comment has been minimized.

Copy link
Member

pfmoore commented Jan 17, 2019

For information, it's possible to bundle virtualenv up using the shiv tool. I use this for a number of applications (virtualenv, tox, pytest, pipenv, ...) and it works really well.

I've not tried it for pip, but it may well work there - either for a standalone pip, or as a get-pip equivalent...

@asottile

This comment has been minimized.

Copy link
Author

asottile commented Jan 20, 2019

got it working, would like some feedback before I write up news entries / decide further on the approach: pypa/virtualenv#1287

@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 25, 2019

We now have https://github.com/pypa/get-virtualenv, we just need to follow the logic from https://github.com/pypa/get-pip and deploy the zipapp generated from here 👍

@gaborbernat gaborbernat transferred this issue from pypa/virtualenv Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment