mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
2097eab028
Before: - if `wheel` was not already installed, then `get-pip.py` would automatically install the latest version on PyPI, which is `0.34.2` (or `0.33.6` for Python 3.4). - if `wheel` was already installed, then it was left unchanged regardless of the version installed. Now: - if `wheel` is not already installed, then the same versions will be installed as before, except these versions are pinned and will now not change unexpectedly after future `wheel` releases. - if `wheel` is already installed, then it's upgraded/downgraded to the target version as needed. Partly addresses #1000, though this change only helps builds where the pip/setuptools/wheel install flow is triggered (currently only new apps or ones where Python was purged or pip was not the correct version). Since the wheel version is now known, it's output to the build log to ease debugging and for parity with pip/setuptools. The rest of #1000 will be fixed in later commits.
138 lines
3.2 KiB
Bash
Executable File
138 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Default Python Versions
|
|
# shellcheck source=bin/default_pythons
|
|
source "bin/default_pythons"
|
|
|
|
testGitEgg() {
|
|
compile "git-egg"
|
|
assertCaptured "requests"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testSmartRequirements() {
|
|
local cache_dir="$(mktmpdir)"
|
|
compile "requirements-standard" "$cache_dir"
|
|
assertFile "requests" ".heroku/python/requirements-declared.txt"
|
|
assertCapturedSuccess
|
|
compile "psycopg2" "$cache_dir"
|
|
assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testStackChange() {
|
|
local cache_dir="$(mktmpdir)"
|
|
mkdir -p "${cache_dir}/.heroku"
|
|
echo "different-stack" > "${cache_dir}/.heroku/python-stack"
|
|
compile "requirements-standard" "$cache_dir"
|
|
assertCaptured "clearing cache"
|
|
assertFile "$STACK" ".heroku/python-stack"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testSetupPy() {
|
|
compile "setup-py"
|
|
assertCaptured "maya"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testStandardRequirements() {
|
|
compile "requirements-standard"
|
|
assertCaptured "requests"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPipenv() {
|
|
compile "pipenv"
|
|
assertCaptured "Installing pip 9.0.2, setuptools 39.0.1 and wheel 0.34.2"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPipenvLock() {
|
|
compile "pipenv-lock"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPipenvVersion() {
|
|
compile "pipenv-version"
|
|
assertCaptured $DEFAULT_PYTHON_VERSION
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPipenvVersion2() {
|
|
compile "pipenv-version2"
|
|
assertCaptured $LATEST_27
|
|
assertCapturedSuccess
|
|
}
|
|
testPipenvFullVersion() {
|
|
compile "pipenv-full-version"
|
|
assertCaptured "3.6.3"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testNoRequirements() {
|
|
compile "no-requirements"
|
|
assertCapturedError
|
|
}
|
|
|
|
testWarnOldDjango() {
|
|
compile "old-django"
|
|
assertCaptured "Your Django version is nearing the end of its community support."
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testDontWarnOldDjango() {
|
|
compile "not-old-django"
|
|
assertNotCaptured "Your Django version is nearing the end of its community support."
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testHooks() {
|
|
# Test that the hooks are called correctly, and that the environment contains
|
|
# the app's config vars but no unexpected env vars from the buildpack.
|
|
local env_dir="$(mktmpdir)"
|
|
echo 'test' > "${env_dir}/SOME_APP_CONFIG_VAR"
|
|
local expected_env_vars=(
|
|
_
|
|
BIN_DIR
|
|
BUILD_DIR
|
|
BUILDPACK_LOG_FILE
|
|
CACHE_DIR
|
|
C_INCLUDE_PATH
|
|
CPLUS_INCLUDE_PATH
|
|
ENV_DIR
|
|
EXPORT_PATH
|
|
HOME
|
|
LANG
|
|
LD_LIBRARY_PATH
|
|
LIBRARY_PATH
|
|
OLDPWD
|
|
PATH
|
|
PKG_CONFIG_PATH
|
|
PROFILE_PATH
|
|
PWD
|
|
PYTHONUNBUFFERED
|
|
SHLVL
|
|
SOME_APP_CONFIG_VAR
|
|
STACK
|
|
VENDOR_URL
|
|
)
|
|
if [[ "${STACK}" == "cedar-14" || "${STACK}" == "heroku-16" ]]; then
|
|
# Remove "OLDPWD" from expected_env_vars since for bash <4.4 it's not exported to subshells:
|
|
# https://github.com/heroku/heroku-buildpack-python/pull/1011#issuecomment-665117835
|
|
read -ra expected_env_vars <<< "${expected_env_vars[@]/OLDPWD/}"
|
|
fi
|
|
compile 'hooks' '' "${env_dir}"
|
|
assertCaptured "pre_compile ran!"
|
|
assertCaptured "pre_compile env: ${expected_env_vars[*]}."
|
|
assertCaptured "post_compile ran!"
|
|
assertCaptured "post_compile env: ${expected_env_vars[*]}."
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
pushd $(dirname 0) >/dev/null
|
|
popd >/dev/null
|
|
|
|
source $(pwd)/test/utils
|
|
source $(pwd)/test/shunit2
|