diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml index 6e49d1f..ed07dd1 100644 --- a/.github/workflows/tests-on-pr.yml +++ b/.github/workflows/tests-on-pr.yml @@ -14,7 +14,13 @@ jobs: run: shell: bash -l {0} - runs-on: macos-14 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + python-version: [3.11, 3.12, 3.13] + steps: - name: Check out diffpy.srreal uses: actions/checkout@v4 @@ -26,7 +32,7 @@ jobs: auto-update-conda: true environment-file: environment.yml auto-activate-base: false - python-version: 3.12 + python-version: ${{ matrix.python-version }} - name: Conda config run: >- @@ -35,8 +41,8 @@ jobs: - name: Install diffpy.srreal and requirements run: | + conda install --file requirements/conda.txt conda install --file requirements/test.txt - conda install boost numpy libdiffpy setuptools diffpy.structure periodictable gsl python -m pip install . --no-deps - name: Validate diffpy.pdfgui diff --git a/requirements/conda.txt b/requirements/conda.txt index dbaae37..a9b021c 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1,9 +1,6 @@ -boost -numpy -libdiffpy -setuptools +libdiffpy=1.4.1rc1 +libboost-devel +libobjcryst +pyobjcryst diffpy.structure -gsl -# periodictable -# pyobjcryst (up to py3.11 for mac) -# dlfcn-win32 (for windows) +periodictable diff --git a/setup.py b/setup.py index f5b929f..fb542c2 100644 --- a/setup.py +++ b/setup.py @@ -48,20 +48,51 @@ def get_boost_config(): return {"include_dirs": [str(inc)], "library_dirs": [str(lib)]} +def get_objcryst_libraries(): + conda_prefix = os.environ.get("CONDA_PREFIX") + if not conda_prefix: + raise EnvironmentError( + "CONDA_PREFIX is not set. Please install ObjCryst using conda and activate the environment." + ) + if os.name == "nt": + libdir = Path(conda_prefix) / "Library" / "lib" + else: + libdir = Path(conda_prefix) / "lib" + + libs = [] + for fn in os.listdir(libdir): + stem = Path(fn).stem + if "objcryst" not in stem.lower(): + continue + # strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst + if os.name != "nt" and stem.startswith("lib"): + stem = stem[3:] + libs.append(stem) + + if not libs: + raise RuntimeError(f"No ObjCryst libraries found in {libdir}") + return libs + + if os.name == "nt": compile_args = ["/std:c++14"] macros = [("_USE_MATH_DEFINES", None)] + extra_link_args = ["/FORCE:MULTIPLE"] else: compile_args = ["-std=c++11"] macros = [] + extra_link_args = [] boost_cfg = get_boost_config() +objcryst_libs = get_objcryst_libraries() + ext_kws = { - "libraries": ["diffpy"] + get_boost_libraries(), + "libraries": ["diffpy"] + get_boost_libraries() + objcryst_libs, "extra_compile_args": compile_args, - "extra_link_args": [], + "extra_link_args": extra_link_args, "include_dirs": [numpy.get_include()] + boost_cfg["include_dirs"], "library_dirs": boost_cfg["library_dirs"], + # "runtime_library_dirs": boost_cfg["library_dirs"], "define_macros": macros, }