mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Migrate away from sp-grep (#1119)
Switches the last consumers of it to a simpler utility function that uses `pkgutil.find_loader()`: https://docs.python.org/3/library/pkgutil.html#pkgutil.find_loader Both of these consumers are covered by existing tests. Then removes `sp-grep` and the remaining parts of `pip-pop`. Closes @W-8208817@.
This commit is contained in:
@@ -96,3 +96,11 @@ python_sqlite3_check() {
|
||||
( python2_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_2" ) \
|
||||
|| ( python3_check "$VERSION" && version_gte "$VERSION" "$MIN_PYTHON_3" )
|
||||
}
|
||||
|
||||
is_module_available() {
|
||||
# Returns 0 is 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)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user