Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate away from the deprecated pkgutil.find_loader() #1493

Merged
merged 2 commits into from
Oct 3, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## Unreleased


## v237 (2023-10-03)

- Fixed `pkgutil.find_loader` deprecation warning when using Python 3.12. ([#1493](https://github.com/heroku/heroku-buildpack-python/pull/1493))

## v236 (2023-10-02)

- Added support for Python 3.12. ([#1490](https://github.com/heroku/heroku-buildpack-python/pull/1490))
Expand Down
6 changes: 2 additions & 4 deletions bin/utils
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ measure-size() {
echo "$(du -s .heroku/python 2>/dev/null || echo 0) | awk '{print $1}')"
}

# Returns 0 if the specified module exists, otherwise returns 1.
is_module_available() {
# Returns 0 if the specified module exists, otherwise returns 1.
# Uses pkgutil rather than pkg_resources or pip's CLI, since pkgutil exists
# in the stdlib, and doesn't depend on the choice of package manager.
local module_name="${1}"
python -c "import sys, pkgutil; sys.exit(0 if pkgutil.find_loader('${module_name}') else 1)"
python -c "import sys, importlib.util; sys.exit(0 if importlib.util.find_spec('${module_name}') else 1)"
}

# The requirement versions are effectively buildpack constants, however, we want
Expand Down