Skip to content

Commit

Permalink
Generate optimized python binaries with pyenv (#1900)
Browse files Browse the repository at this point in the history
* Follow the pyenv guide for producing optimised
python binaries for better performance.
  • Loading branch information
8W9aG authored Aug 23, 2024
1 parent 21ad75c commit 52c8768
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/dockerfile/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update -qq &
&& rm -rf /var/lib/apt/lists/*
` + fmt.Sprintf(`RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash && \
git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest && \
export PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto' && \
export PYTHON_CFLAGS='-march=native -mtune=native -O3' && \
pyenv install-latest "%s" && \
pyenv global $(pyenv install-latest --print "%s") && \
pip install "wheel<1"`, py, py), nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/dockerfile/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update -qq &
&& rm -rf /var/lib/apt/lists/*
RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash && \
git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest && \
export PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto' && \
export PYTHON_CFLAGS='-march=native -mtune=native -O3' && \
pyenv install-latest "%s" && \
pyenv global $(pyenv install-latest --print "%s") && \
pip install "wheel<1"
Expand Down

0 comments on commit 52c8768

Please sign in to comment.