Skip to content

Commit

Permalink
fix: update pyenv installation script to use user-specific environmen…
Browse files Browse the repository at this point in the history
…t file

- Changed the installation script for pyenv to create a user-specific environment file at $HOME/.pyenv-env.sh instead of a system-wide file in /etc/profile.d/.
- Updated the script to source the new environment file, ensuring that the pyenv setup is applied correctly for the user.
- This change improves the flexibility and usability of the pyenv installation in Docker environments.
  • Loading branch information
Marvin Zhang committed Dec 25, 2024
1 parent 9db8193 commit c4c7d25
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docker/base-image/install/python/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ apt-get install -y \
# Install pyenv
curl https://pyenv.run | bash

# Create a file in /etc/profile.d/
cat > /etc/profile.d/pyenv.sh << 'EOF'
# Create a file in $HOME/.pyenv-env.sh
cat > $HOME/.pyenv-env.sh << 'EOF'
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
EOF

# Make the file executable
chmod +x /etc/profile.d/pyenv.sh
chmod +x $HOME/.pyenv-env.sh

# Source it immediately for the rest of the installation
source /etc/profile.d/pyenv.sh
source $HOME/.pyenv-env.sh

# Install python ${version} via pyenv
pyenv install ${version}
Expand Down

0 comments on commit c4c7d25

Please sign in to comment.