pyenv / pyenv

Simple Python version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support mainland-china network env

kirkzhangtech opened this issue · comments

in china , pyenv downloading python interpreter is too slow , if pyenv could support setup mirror link ,so that pyenv could download python interpreter from mirror link.

Pyenv does support downloading from a mirror by setting the PYTHON_BUILD_MIRROR_URL envvar.

It however needs to be organized like our mirror at https://pyenv.github.io/pythons : the path to a package is $PYTHON_BUILD_MIRROR_URL/<checksum from URL in installation script (the text after the # in the URL argument to "install_*" )>.

$ export PYTHON_BUILD_MIRROR_URL="http://yoursite.example.com/pythons"
$ pyenv install 2.7.7

if above two lines are enough ?

$ export PYTHON_BUILD_MIRROR_URL="http://yoursite.example.com/pythons" $ pyenv install 2.7.7

if above two lines are enough ?

Yes. Provided that you actually put the file to the mirror 🙂

image

i put mirror site into environment variable, but still not work , pyenv still download interpreter from original site

Did you put the file to the mirror under the correct name? See updated info above and see https://pyenv.github.io/pythons for URL examples.

ah~
you mean that

  1. i need to manually download tar from mirror site
  2. put tar into ~/.pyenv/cache folder
  3. run pyenv install tar

is it right ?

You need to put the Python package that you'll be downloading onto the mirror that you've specified.

In your case,the file https://www.python.org/ftp/python/3.7.17/Python-3.7.17.tar.xz needs to be available as https://mirrors.huaweicloud.com/python/7911051ed0422fd54b8f59ffc030f7cf2ae30e0f61bda191800bb040dce4f9d2 . "7911051ed0422fd54b8f59ffc030f7cf2ae30e0f61bda191800bb040dce4f9d2" should be the actual file name, and the URL needs to lead directly to the file.

I see that you've replicated the official site's structure. In this case, the easiest would probably be to create symlinks if the mirror allows that. E.g.:

https://mirrors.huaweicloud.com/python/ :

7911051ed0422fd54b8f59ffc030f7cf2ae30e0f61bda191800bb040dce4f9d2 -> 3.7.17/Python-3.7.17.tar.xz

to be honestly , i could not do that https://mirrors.huaweicloud.com/python is public site which i do not own it .
how about https://pyenv.github.io/pythons/ link ?

how about https://pyenv.github.io/pythons/ link ?

It's outside Mainland China, so I don't think that'll help you.

https://mirrors.huaweicloud.com/python is public site which i do not own it

You can ask them to add the symlinks. Pyenv is an industry standard so they might be willing to accomodate us.

Should they have any questons, you can direct them here.
The current scheme was created by @yyuu , the creator of Pyenv. I think the rationale was to abstract away differences between official sites for different Python flavors and their occasional changes. And also possibly to accomodate private mirror owners who may not wish to replicate full directory structure of an official site.

E.g. if we were to simply replace a part of an official URL -- which part should we replace? How many levels has the mirror's owner replicated?

commented

ah~ you mean that

  1. i need to manually download tar from mirror site
  2. put tar into ~/.pyenv/cache folder
  3. run pyenv install tar

is it right ?

this works for me

commented

ah~ you mean that

  1. i need to manually download tar from mirror site
  2. put tar into ~/.pyenv/cache folder
  3. run pyenv install tar

is it right ?

this works for me

step 3 : run pyenv install ${python version code} will be ok