diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 38e10240..2dc9a714 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,10 +5,14 @@ on: [push] jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest] python-version: ["3.7", "3.8", "3.9", "3.10"] + include: + - os: macos-latest + python-version: "3.10" steps: - uses: actions/checkout@v2 @@ -16,6 +20,11 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + + - name: Install MacOS dependencies + if: matrix.os == 'macos-latest' + run: brew install gsl + - name: Install dependencies run: | python -m pip install -U pip diff --git a/CHANGES.rst b/CHANGES.rst index fae147dd..e8c77cd9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,13 @@ Changelog ========= +1.3.1 (upcoming) +---------------- + +Enhancements +~~~~~~~~~~~~ +- Add support for MacOS and add CI config [#59] + 1.3.0 (2022-06-08) ------------------ diff --git a/abacusnbody/common.py b/abacusnbody/common.py new file mode 100644 index 00000000..a926d143 --- /dev/null +++ b/abacusnbody/common.py @@ -0,0 +1,17 @@ +'''Common utility functions. +''' + +def maxthreads(): + '''Return the number of logical cores available to this process. + First tries the affinity mask, then the total number of CPUs, + then 1 if all else fails. + ''' + import multiprocessing + import os + + try: + maxthreads = len(os.sched_getaffinity(0)) + except AttributeError: + maxthreads = multiprocessing.cpu_count() or 1 + + return maxthreads diff --git a/abacusnbody/data/compaso_halo_catalog.py b/abacusnbody/data/compaso_halo_catalog.py index 873e91d7..951bb1c9 100644 --- a/abacusnbody/data/compaso_halo_catalog.py +++ b/abacusnbody/data/compaso_halo_catalog.py @@ -290,10 +290,11 @@ raise Exception("Abacus ASDF extension not properly loaded! Try reinstalling abacusutils, or updating ASDF: `pip install asdf>=2.8`") from e from . import bitpacked +from ..common import maxthreads # Default to 4 decompression threads, or fewer if fewer cores are available DEFAULT_BLOSC_THREADS = 4 -DEFAULT_BLOSC_THREADS = max(1, min(len(os.sched_getaffinity(0)), DEFAULT_BLOSC_THREADS)) +DEFAULT_BLOSC_THREADS = max(1, min(maxthreads(), DEFAULT_BLOSC_THREADS)) from . import asdf as _asdf _asdf.set_nthreads(DEFAULT_BLOSC_THREADS) @@ -1741,4 +1742,3 @@ def unpack_euler16(bin_this): ('sigmavtan_L2com', np.float32), ('rvcirc_max_L2com', np.float32), ], align=True) - diff --git a/setup.py b/setup.py index 19cbc38b..0a54b576 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import os -from setuptools import setup, find_namespace_packages +from setuptools import setup, find_packages install_requires = ['numpy>=1.16','blosc>=1.9.2','astropy>=4.0.0','scipy>=1.5.0','numba>=0.50','asdf>=2.8','h5py','pyyaml'] @@ -27,7 +27,7 @@ long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/abacusorg/abacusutils", - packages=find_namespace_packages(include=['abacusnbody.*']), + packages=find_packages(include=['abacusnbody']), include_package_data=True, classifiers=[ "Programming Language :: Python :: 3",