Skip to content

Commit

Permalink
Stop setting the PYTHONHOME env var (#309)
Browse files Browse the repository at this point in the history
Since it was only set to work around a uWSGI bug, and that
bug does not occur when using a venv (which we now use
as of #257).

Closes #265.
GUS-W-17454520.
  • Loading branch information
edmorley authored Dec 17, 2024
1 parent ec1305f commit 7304505
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Stopped setting the `LANG` env var. ([#306](https://github.com/heroku/buildpacks-python/pull/306))
- Stopped setting the `PYTHONHOME` env var. ([#309](https://github.com/heroku/buildpacks-python/pull/309))

## [0.20.1] - 2024-12-13

Expand Down
17 changes: 0 additions & 17 deletions src/layers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,6 @@ fn generate_layer_env(layer_path: &Path, python_version: &PythonVersion) -> Laye
"PKG_CONFIG_PATH",
":",
)
// We relocate Python (install into a different location to which it was compiled), which
// Python handles fine since it recalculates its actual location at startup. However, the
// uWSGI package uses the wrong `sysconfig` APIs so tries to reference the old compile
// location, unless we override that by setting `PYTHONHOME`. See:
// https://docs.python.org/3/library/sys_path_init.html
// https://github.com/unbit/uwsgi/issues/2525
// In addition, some legacy apps have `PYTHONHOME` set to an invalid value, so if we did not
// set it explicitly here, they would fail to run both during the build and at run-time.
.chainable_insert(
Scope::All,
ModificationBehavior::Override,
"PYTHONHOME",
layer_path,
)
// Disable Python's output buffering to ensure logs aren't dropped if an app crashes.
.chainable_insert(
Scope::All,
Expand Down Expand Up @@ -323,7 +309,6 @@ mod tests {
let mut base_env = Env::new();
base_env.insert("CPATH", "/base");
base_env.insert("PKG_CONFIG_PATH", "/base");
base_env.insert("PYTHONHOME", "this-should-be-overridden");
base_env.insert("PYTHONUNBUFFERED", "this-should-be-overridden");

let layer_env = generate_layer_env(Path::new("/layer-dir"), &PythonVersion::new(3, 11, 1));
Expand All @@ -333,7 +318,6 @@ mod tests {
[
("CPATH", "/layer-dir/include/python3.11:/base"),
("PKG_CONFIG_PATH", "/layer-dir/lib/pkgconfig:/base"),
("PYTHONHOME", "/layer-dir"),
("PYTHONUNBUFFERED", "1"),
("SOURCE_DATE_EPOCH", "315532801"),
]
Expand All @@ -343,7 +327,6 @@ mod tests {
[
("CPATH", "/base"),
("PKG_CONFIG_PATH", "/base"),
("PYTHONHOME", "/layer-dir"),
("PYTHONUNBUFFERED", "1"),
]
);
Expand Down
2 changes: 0 additions & 2 deletions tests/pip_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ fn pip_basic_install_and_cache_reuse() {
PIP_DISABLE_PIP_VERSION_CHECK=1
PIP_PYTHON=/layers/heroku_python/venv
PKG_CONFIG_PATH=/layers/heroku_python/python/lib/pkgconfig
PYTHONHOME=/layers/heroku_python/python
PYTHONUNBUFFERED=1
PYTHONUSERBASE=/layers/heroku_python/pip
SOURCE_DATE_EPOCH=315532801
Expand Down Expand Up @@ -85,7 +84,6 @@ fn pip_basic_install_and_cache_reuse() {
formatdoc! {"
LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib
PATH=/layers/heroku_python/venv/bin:/layers/heroku_python/python/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHONHOME=/layers/heroku_python/python
PYTHONUNBUFFERED=1
VIRTUAL_ENV=/layers/heroku_python/venv
"}
Expand Down
2 changes: 0 additions & 2 deletions tests/poetry_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn poetry_basic_install_and_cache_reuse() {
LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/poetry/lib
PATH=/layers/heroku_python/venv/bin:/layers/heroku_python/python/bin:/layers/heroku_python/poetry/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PKG_CONFIG_PATH=/layers/heroku_python/python/lib/pkgconfig
PYTHONHOME=/layers/heroku_python/python
PYTHONUNBUFFERED=1
PYTHONUSERBASE=/layers/heroku_python/poetry
SOURCE_DATE_EPOCH=315532801
Expand Down Expand Up @@ -78,7 +77,6 @@ fn poetry_basic_install_and_cache_reuse() {
formatdoc! {"
LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib
PATH=/layers/heroku_python/venv/bin:/layers/heroku_python/python/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHONHOME=/layers/heroku_python/python
PYTHONUNBUFFERED=1
VIRTUAL_ENV=/layers/heroku_python/venv
"}
Expand Down

0 comments on commit 7304505

Please sign in to comment.