Skip to content
Merged
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
106 changes: 0 additions & 106 deletions .circleci/config.yml

This file was deleted.

22 changes: 9 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,34 @@ jobs:
matrix:
include:
- name: Python 3.6
os: ubuntu-latest
os: ubuntu-20.04
python: '3.6'
- name: Python 3.7
os: ubuntu-latest
os: ubuntu-20.04
python: '3.7'
- name: Python 3.8
os: ubuntu-latest
os: ubuntu-20.04
python: '3.8'
- name: Python 3.9
os: ubuntu-latest
os: ubuntu-20.04
python: '3.9'
- name: Python 3.10
os: ubuntu-latest
os: ubuntu-20.04
python: '3.10'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install HDF5 and MPI
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install libhdf5-serial-dev libmpich-dev
- name: Install Hyperion Fortran executables
run: |
./configure
make serial
sudo make install
- name: Install Hyperion Python package
run: pip install -e .[test]
- name: Install tox
run: pip install tox
- name: Run tests
run: pytest hyperion
run: tox -e test-bitlevel
16 changes: 0 additions & 16 deletions hyperion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

from .version import __version__

try:
_HYPERION_SETUP_
except NameError: # we are not currently running setup.py
try:
from .util import integrate
except ImportError: # indicates the C extension failed to build
import os
import sys
if os.path.exists('setup.py'):
print("\nYou appear to be importing Hyperion from the source code "
"directory. Try changing to a different directory and try "
"importing Hyperion again.\n")
sys.exit(0)
else:
raise

# Set up the test function
_test_runner = None

Expand Down
16 changes: 0 additions & 16 deletions hyperion/conftest.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
import warnings

import pytest

from .util.nans import NaNWarning


def pytest_addoption(parser):
parser.addoption('--generate-reference', help="generate reference results for bit-level tests", type="string")
parser.addoption('--enable-bit-level-tests', help="enable bit-level tests", action="store_true")


def pytest_configure(config):
warnings.simplefilter('error', NaNWarning)


def pytest_collection_modifyitems(config, items):
if config.getoption("--enable-bit-level-tests"):
return
skip_bit_level = pytest.mark.skip(reason="need --enable-bit-level-tests option to run")
for item in items:
if "bitlevel" in item.keywords:
item.add_marker(skip_bit_level)
15 changes: 15 additions & 0 deletions hyperion/testing/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest


def pytest_addoption(parser):
parser.addoption('--generate-reference', help="generate reference results for bit-level tests", type="string")
parser.addoption('--enable-bit-level-tests', help="enable bit-level tests", action="store_true")


def pytest_collection_modifyitems(config, items):
if config.getoption("--enable-bit-level-tests"):
return
skip_bit_level = pytest.mark.skip(reason="need --enable-bit-level-tests option to run")
for item in items:
if "bitlevel" in item.keywords:
item.add_marker(skip_bit_level)
4 changes: 2 additions & 2 deletions hyperion/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.0.0'
__dev__ = True
from hyperion._version import version as __version__
__dev__ = 'dev' in __version__
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = ["setuptools",
"setuptools_scm>=6.2",
"wheel",
"oldest-supported-numpy"]
build-backend = 'setuptools.build_meta'

[tool.setuptools_scm]
write_to = "hyperion/_version.py"
6 changes: 4 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ description = Monte-Carlo Radiative Transfer Code
[options]
zip_safe = True
packages = find:
include_package_data = True
setup_requires = oldest-supported-numpy
install_requires =
numpy>=1.11
matplotlib>=1.5
Expand All @@ -31,3 +29,7 @@ hyperion.model.tests = data/*.rtout, data/*.hdf5
hyperion.importers.tests = data/*.hdf5
hyperion.grid.tests = data/*.hdf5, data/DD0010/*
hyperion.testing = coveragerc

[options.entry_points]
pytest11 =
hyperion = hyperion.testing.pytest_plugin
117 changes: 33 additions & 84 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,87 +1,36 @@
#!/usr/bin/env python

import sys

if sys.version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._HYPERION_SETUP_ = True

from setuptools import setup, Extension, find_packages
from distutils.command.sdist import sdist
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext

from hyperion.testing.helper import HyperionTest
from hyperion.version import __version__


class custom_sdist(sdist):

user_options = sdist.user_options + [('unstable', None, "make an unstable release (keep __dev__=True)")]

def __init__(self, *args, **kwargs):
sdist.__init__(self, *args, **kwargs)
self.unstable = False

def run(self):
if not self.unstable:
version_file = 'hyperion/version.py'
content = open(version_file, 'r').read()
open(version_file, 'w').write(content.replace('__dev__ = True', "__dev__ = False"))
try:
sdist.run(self)
finally:
if not self.unstable:
open(version_file, 'w').write(content)


class NumpyBuildExt(build_ext):
def run(self):
import numpy
self.include_dirs.append(numpy.get_include())
build_ext.run(self)


cmdclass = {}
cmdclass['build_py'] = build_py
cmdclass['test'] = HyperionTest
cmdclass['sdist'] = custom_sdist
cmdclass['build_ext'] = NumpyBuildExt

if 'egg_info' in sys.argv:

ext_modules = []

else:

ext_modules = [Extension("hyperion.util._integrate_core",
['hyperion/util/_integrate_core.c'],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.util._interpolate_core",
['hyperion/util/_interpolate_core.c'],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.importers._discretize_sph",
['hyperion/importers/_discretize_sph.c'],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.grid._voronoi_core",
['hyperion/grid/_voronoi_core.c',
'hyperion/grid/voropp_wrap.cc',
'hyperion/grid/voro++/c_loops.cc',
'hyperion/grid/voro++/cell.cc',
'hyperion/grid/voro++/common.cc',
'hyperion/grid/voro++/container.cc',
'hyperion/grid/voro++/container_prd.cc',
'hyperion/grid/voro++/pre_container.cc',
'hyperion/grid/voro++/unitcell.cc',
'hyperion/grid/voro++/v_base.cc',
'hyperion/grid/voro++/v_compute.cc',
'hyperion/grid/voro++/wall.cc'],
extra_compile_args = ['-O2', '-Wno-error=declaration-after-statement'],
extra_link_args=['-lstdc++'])]

setup(version=__version__,
scripts=['scripts/hyperion', 'scripts/hyperion2fits'],
cmdclass=cmdclass,
import numpy
from setuptools import setup, Extension

ext_modules = [Extension("hyperion.util._integrate_core",
['hyperion/util/_integrate_core.c'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.util._interpolate_core",
['hyperion/util/_interpolate_core.c'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.importers._discretize_sph",
['hyperion/importers/_discretize_sph.c'],
include_dirs=[numpy.get_include()],
extra_compile_args=['-Wno-error=declaration-after-statement']),
Extension("hyperion.grid._voronoi_core",
['hyperion/grid/_voronoi_core.c',
'hyperion/grid/voropp_wrap.cc',
'hyperion/grid/voro++/c_loops.cc',
'hyperion/grid/voro++/cell.cc',
'hyperion/grid/voro++/common.cc',
'hyperion/grid/voro++/container.cc',
'hyperion/grid/voro++/container_prd.cc',
'hyperion/grid/voro++/pre_container.cc',
'hyperion/grid/voro++/unitcell.cc',
'hyperion/grid/voro++/v_base.cc',
'hyperion/grid/voro++/v_compute.cc',
'hyperion/grid/voro++/wall.cc'],
include_dirs=[numpy.get_include()],
extra_compile_args = ['-O2', '-Wno-error=declaration-after-statement'],
extra_link_args=['-lstdc++'])]

setup(scripts=['scripts/hyperion', 'scripts/hyperion2fits'],
ext_modules=ext_modules)
22 changes: 22 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[tox]
envlist =
py{36,37,38,39,310}-test{,-bitlevel}
requires =
setuptools >= 30.3.0
pip >= 19.3.1
isolated_build = true

[testenv]
changedir = .tmp/{envname}
extras =
test: test
allowlist_externals =
make
commands =
pip freeze
{toxinidir}/configure --prefix={envdir}
mv Makefile {toxinidir}/
make -C {toxinidir} serial
make -C {toxinidir} install
!bitlevel: pytest --pyargs hyperion
bitlevel: pytest --pyargs hyperion --enable-bit-level-tests