Skip to content

Commit

Permalink
move pyenv to /usr/local/share/pyenv
Browse files Browse the repository at this point in the history
  • Loading branch information
julienp committed Aug 20, 2024
1 parent c9a1f82 commit 706a68c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
12 changes: 6 additions & 6 deletions docker/pulumi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RUN \
google-cloud-sdk-gke-gcloud-auth-plugin \
kubectl && \
rm -rf /var/lib/apt/lists/*

# Install nodejs and associated tools
RUN \
# Add yarn repo
Expand Down Expand Up @@ -116,18 +116,18 @@ RUN curl -L https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-

# Python
# Install Pyenv and preinstall supported Python versions
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git /pyenv
ENV PYENV_ROOT /pyenv
RUN git clone --depth=1 https://github.com/pyenv/pyenv.git /usr/local/share/pyenv
ENV PYENV_ROOT /usr/local/share/pyenv
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
RUN pyenv install 3.12
RUN pyenv install 3.11
RUN pyenv install 3.10
RUN pyenv install 3.9
RUN pyenv global 3.9 # Default version
# Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:${PATH}"
# Set poetry to prefer the active python version so it interacts nicely with pyenv, otherwise
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/share/pypoetry python3 -
RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/
# Set poetry to prefer the active python version so it interacts nicely with pyenv, otherwise
# poetry will create virtual environments using the python version used by poetry itself.
RUN poetry config virtualenvs.prefer-active-python true

Expand Down
22 changes: 9 additions & 13 deletions tests/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestEnvironment(t *testing.T) {
t.Parallel()
expected := "/usr/local/bin/python"
if isKitchenSink(t) {
expected = "/pyenv/shims/python"
expected = "/usr/local/share/pyenv/shims/python"
}
if isUBI(t) {
expected = "/usr/bin/python"
Expand All @@ -225,17 +225,13 @@ func TestEnvironment(t *testing.T) {
// Use bash `command` builtin to lookup the path to python
requireOutputWithBash(t, expected, "command", "-v", "python")

// TODO: enable test for kitchen sink after https://github.com/pulumi/pulumi-docker-containers/pull/232
// is merged. https://github.com/pulumi/pulumi-docker-containers/issues/239
if !isKitchenSink(t) {
// Poetry should be available
expectedPoetryPath := "/usr/local/bin/poetry"
poetryPath, err := exec.LookPath("poetry")
require.NoError(t, err)
require.Equal(t, expectedPoetryPath, poetryPath)
// Use bash `command` builtin to lookup the path to python
requireOutputWithBash(t, expectedPoetryPath, "command", "-v", "poetry")
}
// Poetry should be available
expectedPoetryPath := "/usr/local/bin/poetry"
poetryPath, err := exec.LookPath("poetry")
require.NoError(t, err)
require.Equal(t, expectedPoetryPath, poetryPath)
// Use bash `command` builtin to lookup the path to python
requireOutputWithBash(t, expectedPoetryPath, "command", "-v", "poetry")
})

t.Run("Node", func(t *testing.T) {
Expand Down Expand Up @@ -299,7 +295,7 @@ func TestEnvironment(t *testing.T) {
// Install scripts for various tools can sometimes modify PATH, usually by adding entries
// to ~/.bashrc. This test ensures that we notice such modifications.
expectedPaths := map[string]string{
"pulumi": "/root/.local/bin:/pyenv/shims:/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"pulumi": "/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"pulumi-debian-dotnet": "/root/.dotnet:/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"pulumi-debian-go": "/pulumi/bin:/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"pulumi-debian-java": "/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
Expand Down

0 comments on commit 706a68c

Please sign in to comment.