# Overview Experimental packaging for the pyenv https://github.com/pyenv/pyenv Ideas for RPM packaging: https://github.com/niligulmohar/pyenv-rpm # Usage Use pyenv: ```bash # show installed versions pyenv versions # show current python version pyenv version # show possible python versions to install pyenv install --list # install a python version pyenv install # activate python version for current shell: pyenv shell # uninstall python version pyenv uninstall # create a python environment pyenv virtualenv # activate virtual environment in current shell pyenv shell # remove virtualenv pyenv virtualenv-delete ``` Tutorial: https://realpython.com/intro-to-pyenv # Installation Install the rpm to get pyenv on the system. Afterwards you can bring/initialize pyenv into your shell via: ```bash # temporary export PYENV_ROOT="$HOME/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init - bash)" # or permanent echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc ``` To initialize for all users you might want to add a bash profile file to `/etc/profile.d` like this one: [pyenv.sh](pyenv.sh) # Development # Manual Build ``` docker run --platform linux/amd64 -it --rm -v $(pwd):/data --workdir /data gitea.psi.ch/images/rhel9-developer rpmbuild -ba pyenv.spec ``` # Manual Installation See: https://gitea.psi.ch/linux/issues/issues/327#issuecomment-22876 and https://github.com/pyenv/pyenv Installing pyenv dependencies (https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with-framework-support-on-os-x): ```bash dnf install gcc make patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel ``` Install/clone pyenv: ```bash [root@lxdev04 ~]# mkdir /opt/pyenv [root@lxdev04 ~]# git clone https://github.com/pyenv/pyenv.git /opt/pyenv Cloning into '/opt/pyenv'... remote: Enumerating objects: 24035, done. remote: Counting objects: 100% (100/100), done. remote: Compressing objects: 100% (44/44), done. remote: Total 24035 (delta 42), reused 89 (delta 38), pack-reused 23935 Receiving objects: 100% (24035/24035), 4.91 MiB | 23.30 MiB/s, done. Resolving deltas: 100% (16199/16199), done. [root@lxdev04 ~]# ln -s /opt/pyenv/bin/pyenv /usr/bin/pyenv ``` Create profile script: ```bash [root@lxdev04 bin]# cat /etc/profile.d/pyenv.sh if [[ ${UID} -ge 1000 && ! ${USER} =~ -adm$ ]]; then export PYENV_ROOT="$HOME/.pyenv" # export PYENV_ROOT="/tmp/$USER/.pyenv" [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" fi ``` Installation virtualenv plugin (https://github.com/pyenv/pyenv-virtualenv): ```bash git clone https://github.com/pyenv/pyenv-virtualenv.git /opt/pyenv/plugins/pyenv-virtualenv ``` # TODO - Maybe we need a `eval "$(pyenv virtualenv-init -)"'` - yes we need that- see : https://github.com/pyenv/pyenv-virtualenv - Somehow the detection of the system pythons (if multiple versions are installed) does not work (see also https://github.com/pyenv/pyenv/issues/1628). This plugin might help: https://github.com/doloopwhile/pyenv-register