From 2c7bf1f28d422d02ecd84c3f14eb58d38dda0ff2 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Fri, 20 Jun 2025 15:37:31 -0500 Subject: [PATCH 1/7] find objcryst --- setup.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f5b929f..5cdbbb1 100644 --- a/setup.py +++ b/setup.py @@ -48,20 +48,46 @@ 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): + low = fn.lower() + if "objcryst" in low: + libs.append(os.path.splitext(fn)[0]) + 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, } From 99cd3d382b769190b190f7d3286efdcaa9b18fef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 20:38:59 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit hooks --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5cdbbb1..d25ba1d 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ def get_objcryst_libraries(): if os.name == "nt": compile_args = ["/std:c++14"] macros = [("_USE_MATH_DEFINES", None)] - extra_link_args = ["/FORCE:MULTIPLE"] + extra_link_args = ["/FORCE:MULTIPLE"] else: compile_args = ["-std=c++11"] macros = [] From 12481e9ac78d9cf27a54beedd4769d6e40afeafd Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Sun, 22 Jun 2025 14:56:48 -0500 Subject: [PATCH 3/7] update conda requirements, correct objcryst flag --- requirements/conda.txt | 11 ++++------- setup.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/requirements/conda.txt b/requirements/conda.txt index dbaae37..0f11dbe 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1,9 +1,6 @@ -boost -numpy libdiffpy -setuptools +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 d25ba1d..c16945f 100644 --- a/setup.py +++ b/setup.py @@ -61,9 +61,14 @@ def get_objcryst_libraries(): libs = [] for fn in os.listdir(libdir): - low = fn.lower() - if "objcryst" in low: - libs.append(os.path.splitext(fn)[0]) + stem = Path(fn).stem + if "objcryst" not in stem.lower(): + continue + # strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst + if stem.startswith("lib"): + stem = stem[3:] + libs.append(stem) + if not libs: raise RuntimeError(f"No ObjCryst libraries found in {libdir}") return libs From cabdcc705aa7ae3ee7f2a69b0ea166f14ad7ddc0 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Sun, 22 Jun 2025 15:00:18 -0500 Subject: [PATCH 4/7] force libdiffpy rc version --- requirements/conda.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/conda.txt b/requirements/conda.txt index 0f11dbe..a9b021c 100644 --- a/requirements/conda.txt +++ b/requirements/conda.txt @@ -1,4 +1,4 @@ -libdiffpy +libdiffpy=1.4.1rc1 libboost-devel libobjcryst pyobjcryst From fa597f8403e5ba5874fe8164c33ec36731313671 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Sun, 22 Jun 2025 15:10:08 -0500 Subject: [PATCH 5/7] update tests --- .github/workflows/tests-on-pr.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 From 170f9c9aaf98f6d853ef48957d183a1a458932cb Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Sun, 22 Jun 2025 15:18:04 -0500 Subject: [PATCH 6/7] try removing extra insurance --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c16945f..dd48ed9 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,7 @@ def get_objcryst_libraries(): "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"], + # "runtime_library_dirs": boost_cfg["library_dirs"], "define_macros": macros, } From a86ab582eebaac9ac2e474208def563b89daa703 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Sun, 22 Jun 2025 15:26:05 -0500 Subject: [PATCH 7/7] make MSVC linker happy --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index dd48ed9..fb542c2 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ def get_objcryst_libraries(): if "objcryst" not in stem.lower(): continue # strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst - if stem.startswith("lib"): + if os.name != "nt" and stem.startswith("lib"): stem = stem[3:] libs.append(stem)