Skip to content

Commit

Permalink
fix(python): fix and check all uninstalled imports in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 23, 2022
1 parent 6bca42c commit 0e4e2c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ jobs:

- name: Check import without optional dependencies
run: |
pip uninstall pandas -y
python -c 'import polars'
pip uninstall numpy -y
python -c 'import polars'
pip uninstall pyarrow -y
python -c 'import polars'
declare -a deps=("pandas"
"pyarrow"
"fsspec"
"matplotlib"
"backports.zoneinfo"
"connectorx"
"xlsx2csv"
)
for d in "${deps[@]}"
do
echo "uninstall $i and check imports..."
pip uninstall "$d" -y
python -c 'import polars'
done
windows:
runs-on: windows-latest
Expand Down
7 changes: 6 additions & 1 deletion py-polars/polars/import_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def zoneinfo_mod() -> ModuleType:


def pkg_is_available(name: str) -> bool:
return importlib.util.find_spec(name) is not None
try:
return importlib.util.find_spec(name) is not None
# in python 3.7 backports.zoneinfo fails
# likely due to the dot in the package name
except ModuleNotFoundError:
return False


def lazy_isinstance(value: Any, module_bound: str, types: Callable[[], Any]) -> bool:
Expand Down

0 comments on commit 0e4e2c1

Please sign in to comment.