Skip to content

Commit

Permalink
Add pyproject.toml file and fix C-code loading code for its use
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Oct 13, 2023
1 parent bb867d9 commit 45ac2cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
13 changes: 9 additions & 4 deletions mwdust/util/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
11 changes: 9 additions & 2 deletions mwdust/util/read_SFD.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

0 comments on commit 45ac2cb

Please sign in to comment.