Skip to content

Commit

Permalink
find: simplify logic. Require Python >= 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 6, 2023
1 parent 9811232 commit 6ae426d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Atmospheric Science"
]
requires-python = ">=3.7"
requires-python = ">=3.8"
dynamic = ["version", "readme"]
dependencies = ["python-dateutil", "numpy", "xarray>=0.16.0", "scipy", "h5py", "matplotlib >= 3.1"]

Expand Down
27 changes: 8 additions & 19 deletions src/gemini3d/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,25 @@ def executable(name: str, root: Path | None = None) -> Path:
if ep.is_file():
return ep

paths = (
Path(p).expanduser()
for p in (
root,
os.environ.get("GEMINI_ROOT"),
os.environ.get("CMAKE_PREFIX_PATH"),
)
if p
)
paths = (root, os.environ.get("GEMINI_ROOT"), os.environ.get("CMAKE_PREFIX_PATH"))

for p in paths:
if not p:
continue
p = Path(p).expanduser()

for n in EXE_PATHS:
exe = p / n / name
logging.debug(f"checking {exe} for existance and executable permission")
if wsl.is_wsl_path(p):
# shutil.which() doesn't work on WSL paths
pexe = p / n / name
if pexe.is_file():
return wsl.win_path2wsl_path(pexe) # type: ignore
if exe.is_file():
return wsl.win_path2wsl_path(exe) # type: ignore
else:
exe = shutil.which(name, path=str(p / n))
logging.debug(f"{name} {p / n} => {exe}")
if exe:
if exe := shutil.which(exe, path=p / n):
return Path(exe)

raise FileNotFoundError(f"{name} not found")
raise FileNotFoundError(f"{name} not found, search paths: {paths}")


def gemini_exe(name: str = "gemini3d.run", root: Path | None = None) -> Path:
Expand All @@ -92,9 +84,6 @@ def gemini_exe(name: str = "gemini3d.run", root: Path | None = None) -> Path:

exe = executable(name, root)

if not exe:
raise FileNotFoundError(f"Gemini3D executable {name} not found")

# %% ensure Gemini3D executable is runnable
if os.name == "nt" and isinstance(exe, PurePosixPath):
cmd0 = ["wsl", str(exe)]
Expand Down
2 changes: 0 additions & 2 deletions src/gemini3d/tests/intg/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import pytest
import os
import re
import sys

import matplotlib as mpl

import gemini3d.web
import gemini3d.plot


@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires Python >= 3.8")
@pytest.mark.parametrize(
"name",
[
Expand Down

0 comments on commit 6ae426d

Please sign in to comment.