diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2ccc57..17b7cdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,7 +45,7 @@ jobs: env: DUST_DIR: ${{github.workspace}}/data/ run: | - python setup.py develop + pip install -ve . - name: Test package env: DUST_DIR: ${{github.workspace}}/data/ diff --git a/mwdust/util/healpix.py b/mwdust/util/healpix.py index 896a3d1..5c83619 100644 --- a/mwdust/util/healpix.py +++ b/mwdust/util/healpix.py @@ -3,9 +3,8 @@ import ctypes import ctypes.util from numpy.ctypeslib import ndpointer -import os import numpy as np - +from pathlib import Path # healpy number to represent bad numbers UNSEEN = -1.6375e+30 @@ -17,9 +16,15 @@ if _libname: _lib = ctypes.CDLL(_libname) if _lib is None: - for path in sys.path: + # Add top-level mwdust repository directory for pip install (-e) ., + # just becomes site-packages for regular install + paths = sys.path + paths.append(str(Path(__file__).parent.parent.parent.absolute())) + for path in [Path(p) for p in paths]: + if not path.is_dir(): + continue try: - _lib = ctypes.CDLL(os.path.join(path, "healpix_c%s" % _ext_suffix)) + _lib = ctypes.CDLL(str(path / f"healpix_c{_ext_suffix}")) except OSError: _lib = None else: diff --git a/mwdust/util/read_SFD.py b/mwdust/util/read_SFD.py index e116a1a..5523bc5 100644 --- a/mwdust/util/read_SFD.py +++ b/mwdust/util/read_SFD.py @@ -4,6 +4,7 @@ import ctypes.util from numpy.ctypeslib import ndpointer import os, os.path +from pathlib import Path import numpy import platform import tqdm @@ -21,9 +22,15 @@ if _libname: _lib = ctypes.CDLL(_libname) if _lib is None: - for path in sys.path: + # Add top-level mwdust repository directory for pip install (-e) ., + # just becomes site-packages for regular install + paths = sys.path + paths.append(str(Path(__file__).parent.parent.parent.absolute())) + for path in [Path(p) for p in paths]: + if not path.is_dir(): + continue try: - _lib = ctypes.CDLL(os.path.join(path,'sfd_c%s' % _ext_suffix)) + _lib = ctypes.CDLL(str(path / f"sfd_c{_ext_suffix}")) except OSError: _lib = None else: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fed528d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta"