Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MacOS CI config #59

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ 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
- name: Set up Python ${{ matrix.python-version }}
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
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
17 changes: 17 additions & 0 deletions abacusnbody/common.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions abacusnbody/data/compaso_halo_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -1741,4 +1742,3 @@ def unpack_euler16(bin_this):
('sigmavtan_L2com', np.float32),
('rvcirc_max_L2com', np.float32),
], align=True)

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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']

Expand All @@ -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",
Expand Down