From 4d037eea220e0ccae090004f8b10f40d932493dd Mon Sep 17 00:00:00 2001 From: Christoph Schueler Date: Fri, 4 Oct 2024 11:08:20 +0300 Subject: [PATCH] Try to fix github workflow #3 --- .github/workflows/pythonapp.yml | 3 --- build_ext.py | 38 ++++++++++++++++----------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 8c83816..0fcc637 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -23,9 +23,6 @@ jobs: # - os: ubuntu-latest # cibw_archs: "aarch64" steps: - - name: Install prerequisites - run: sudo apt-get install -y gcc cmake libssl-dev libpython3-dev python3-dev libffi-dev - - uses: actions/checkout@v3 - name: Install Rust uses: actions-rs/toolchain@v1 diff --git a/build_ext.py b/build_ext.py index 572500e..cb75c3b 100644 --- a/build_ext.py +++ b/build_ext.py @@ -9,7 +9,7 @@ import sysconfig from pathlib import Path from tempfile import TemporaryDirectory -from typing import Optional +from typing import Optional, Tuple TOP_DIR = Path(__file__).parent @@ -26,13 +26,10 @@ def get_python_base() -> str: # Applies in this form only to Windows. - - base = VARS.get("base", "") - if base: - return base - installed_base = VARS.get("installed_base") - if installed_base: - return installed_base + if "base" in VARS and VARS["base"]: + return VARS["base"] + if "installed_base" in VARS and VARS["installed_base"]: + return VARS["installed_base"] def alternate_libdir(pth: str): @@ -66,9 +63,10 @@ def get_py_config() -> dict: arch = None if uname.system == "Linux": arch = VARS.get("MULTIARCH", "") - if not arch: - print("WARNING: var 'MULTIARCH' not found. search may fail!") + found = False for dir_var in DIR_VARS: + if found: + break dir_name = VARS.get(dir_var) if not dir_name: continue @@ -79,16 +77,19 @@ def get_py_config() -> dict: else: print("PF?", uname.system) for fp in full_path: + print(f"Trying {fp!r}") if fp.exists(): - print(f"found Python library: '{full_path}'") - libdir = dir_name + print(f"found Python library: {fp!r}") + libdir = str(fp.parent) + found = True break - # else: - # print(f"NOT found: '{full_path}'") + if not found: + print("Could NOT locate Python library.") + return dict(exe=sys.executable, include=include, libdir="", library=library) return dict(exe=sys.executable, include=include, libdir=libdir, library=library) -def sort_by_version(version: str) -> tuple[int]: +def sort_by_version(version: str) -> Tuple[int]: h, m, s = version.split(".") return int(h), int(m), int(s) @@ -130,15 +131,12 @@ def build_extension(debug: bool = False, use_temp_dir=True) -> None: cmake_args = [ f"-DPython3_EXECUTABLE={py_cfg['exe']}", f"-DPython3_INCLUDE_DIR={py_cfg['include']}", - f"-DPython3_LIBRARY={str(Path(py_cfg['libdir']) / Path(py_cfg['library']))}", # noqa: RUF010 f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm ] + if py_cfg["libdir"]: + cmake_args.append(f"-DPython3_LIBRARY={str(Path(py_cfg['libdir']) / Path(py_cfg['library']))}") build_args = ["--config Release", "--verbose"] - # Adding CMake arguments set as environment variable - # (needed e.g. to build for ARM OSx on conda-forge) - - # cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 /path/to/src if sys.platform.startswith("darwin"): # Cross-compile support for macOS - respect ARCHFLAGS if set