Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0

- name: Install ubuntu dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y libarchive-tools

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3.5.1
with:
Expand Down
6 changes: 1 addition & 5 deletions src/usr/local/bin/install-pip
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ require_tool "$@"
check_command pip

echo "Installing pip tool ${TOOL_NAME} v${TOOL_VERSION}"
pip install \
python -W ignore -m pip install \
--upgrade \
--use-pep517 \
--no-cache-dir \
--disable-pip-version-check \
--quiet \
"${TOOL_NAME}==${TOOL_VERSION}"

# clean cache https://pip.pypa.io/en/stable/reference/pip_cache/#pip-cache
pip cache purge
9 changes: 9 additions & 0 deletions src/usr/local/buildpack/tools/v2/hashin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# shellcheck source=/dev/null
. "$(get_buildpack_path)/utils/python.sh"

function link_tool () {
post_install
hashin --version
}
13 changes: 13 additions & 0 deletions src/usr/local/buildpack/tools/v2/pip-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# shellcheck source=/dev/null
. "$(get_buildpack_path)/utils/python.sh"

function link_tool () {
post_install
pip-compile --version
}

function post_install () {
python_shell_wrapper pip-compile
}
9 changes: 9 additions & 0 deletions src/usr/local/buildpack/tools/v2/pipenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# shellcheck source=/dev/null
. "$(get_buildpack_path)/utils/python.sh"

function link_tool () {
post_install
pipenv --version
}
38 changes: 21 additions & 17 deletions src/usr/local/buildpack/tools/v2/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ fix_python_shebangs() {
}

function prepare_tool() {
create_tool_path > /dev/null
local tool_path
tool_path=$(create_tool_path)

# Workaround for compatibillity for Python hardcoded paths
if [ "${tool_path}" != "${ROOT_DIR_LEGACY}/python" ]; then
ln -sf "${tool_path}" /usr/local/python
fi
export_path "${USER_HOME}/.local/bin"
export_env PIP_DISABLE_PIP_VERSION_CHECK 1
}

function install_tool () {
Expand Down Expand Up @@ -49,30 +56,28 @@ function install_tool () {
file=$(get_from_url "${url}/${TOOL_VERSION}/python-${TOOL_VERSION}-${version_codename}-${arch}.tar.xz")

if [[ -f ${file} ]]; then
echo 'Using prebuild python'
tar -C "${versioned_tool_path}" --strip 1 -xf "${file}"
bsdtar -C "${versioned_tool_path}" --strip 1 -xf "${file}"
else
echo 'No prebuild python found' >&2
exit 1
fi

fix_python_shebangs

# install latest pip
PIP_ROOT_USER_ACTION=ignore "${versioned_tool_path}/bin/python" -m pip install \
# install latest pip and virtualenv
PIP_ROOT_USER_ACTION=ignore "${versioned_tool_path}/bin/python" \
-W ignore \
-m pip \
install \
--compile \
--use-pep517 \
--no-warn-script-location \
--no-cache-dir \
--disable-pip-version-check \
--quiet \
--upgrade \
pip \
virtualenv \
;

# clean cache https://pip.pypa.io/en/stable/reference/pip_cache/#pip-cache
"${versioned_tool_path}/bin/python" -m pip cache purge
}

function link_tool () {
Expand All @@ -84,14 +89,13 @@ function link_tool () {
# export python vars
export_tool_path "${versioned_tool_path}/bin"

# TODO: fix me, currently required for global pip
shell_wrapper "${TOOL_NAME}" "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper "${TOOL_NAME}${MAJOR}" "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper "${TOOL_NAME}${MAJOR}.${MINOR}" "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper pip "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper "pip${MAJOR}" "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper "pip${MAJOR}.${MINOR}" "${versioned_tool_path}/bin" "PYTHONHOME=${versioned_tool_path}"
shell_wrapper "${TOOL_NAME}" "${versioned_tool_path}/bin"
shell_wrapper "${TOOL_NAME}${MAJOR}" "${versioned_tool_path}/bin"
shell_wrapper "${TOOL_NAME}${MAJOR}.${MINOR}" "${versioned_tool_path}/bin"
shell_wrapper pip "${versioned_tool_path}/bin"
shell_wrapper "pip${MAJOR}" "${versioned_tool_path}/bin"
shell_wrapper "pip${MAJOR}.${MINOR}" "${versioned_tool_path}/bin"

python --version
pip --version
PYTHONWARNINGS=ignore pip --version
}
21 changes: 10 additions & 11 deletions src/usr/local/buildpack/utils/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ function install_tool() {
--quiet \
"${tool_path}"

"${tool_path}/bin/python" -m pip install \
--compile \
--use-pep517 \
--no-warn-script-location \
--no-cache-dir \
--disable-pip-version-check \
--quiet \
"${TOOL_NAME}==${TOOL_VERSION}"

# clean cache https://pip.pypa.io/en/stable/reference/pip_cache/#pip-cache
python -m pip cache purge
"${tool_path}/bin/python" \
-W ignore \
-m pip \
install \
--compile \
--use-pep517 \
--no-warn-script-location \
--no-cache-dir \
--quiet \
"${TOOL_NAME}==${TOOL_VERSION}"

# remove virtualenv app-data
rm -rf ~/.local/share/virtualenv
Expand Down
21 changes: 10 additions & 11 deletions test/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ FROM build as pipenv
ARG BUILDPACK_DEBUG

# renovate: datasource=pypi
RUN install-pip pipenv 2022.12.19
RUN install-tool pipenv 2022.12.19


USER 1000
Expand Down Expand Up @@ -114,7 +114,6 @@ ARG BUILDPACK_DEBUG

RUN install-tool poetry 0.12.17
RUN install-tool poetry 1.1.15
# // Fails tests now

#--------------------------------------
# test a: pip_requirements
Expand Down Expand Up @@ -152,7 +151,7 @@ RUN set -ex \
;

# renovate: datasource=pypi
RUN install-pip hashin 0.17.0
RUN install-tool hashin 0.17.0

RUN set -ex \
&& cd f \
Expand All @@ -175,7 +174,7 @@ RUN install-tool python 3.8.13
RUN install-tool python 3.11.1

# renovate: datasource=pypi
RUN install-pip pipenv 2022.12.19
RUN install-tool pipenv 2022.12.19

RUN set -ex; \
cd h-pipenv; \
Expand All @@ -191,15 +190,15 @@ ARG BUILDPACK_DEBUG
# needs to be v2
RUN install-tool python 2.7.18

# don't change
RUN install-pip pipenv 2020.11.15
# don't change, never versions don't work on python 2.7
RUN install-tool pipenv 2020.11.15
RUN install-tool poetry 0.12.17

RUN install-tool poetry 1.1.15
RUN install-tool hashin 0.17.0
RUN install-tool pip-tools 5.5.0

# renovate: datasource=pypi
RUN install-pip hashin 0.17.0

# https://github.com/python-poetry/poetry/issues/3010
RUN poetry config experimental.new-installer false

RUN set -ex; \
poetry new poetry-demo; \
Expand All @@ -210,7 +209,7 @@ RUN set -ex; \
#--------------------------------------
# final
#--------------------------------------
FROM build
FROM base

COPY --from=test-poetry-a /.dummy /.dummy
COPY --from=test-poetry-b /.dummy /.dummy
Expand Down