diff --git a/.circleci/config.yml b/.circleci/config.yml index 403644b7..db43a183 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,6 +21,9 @@ jobs: HYPERION_HDF5_VERSION=18 ./configure make make install + - run: + name: Upgrade setuptools and pip + command: pip install setuptools pip --upgrade - run: name: Installing Numpy command: pip install numpy==1.11.3 @@ -29,10 +32,10 @@ jobs: command: pip install Cython==0.24.1 - run: name: Installing Python package - command: pip install .[test] matplotlib==1.5.3 astropy==1.2.2 h5py==2.4.0 yt==3.2.3 + command: pip install -e .[test] matplotlib==1.5.3 astropy==1.2.2 h5py==2.4.0 yt==3.2.3 - run: name: Run full test suite (including bit-level tests) - command: python setup.py test --enable-bit-level-tests + command: pytest hyperion --enable-bit-level-tests # Build with HDF5 1.8 hdf5-18: @@ -51,15 +54,21 @@ jobs: HYPERION_HDF5_VERSION=18 ./configure make make install + - run: + name: Upgrade setuptools and pip + command: pip install setuptools pip --upgrade - run: name: Installing Numpy - command: pip install numpy + command: pip install numpy Cython - run: name: Installing Python package - command: pip install .[test] + command: pip install -e .[test] + - run: + name: Ensure an old version of pytest is available + command: pip install "pytest<3.7,>=2.8" - run: name: Run full test suite (including bit-level tests) - command: python setup.py test --enable-bit-level-tests + command: pytest hyperion --enable-bit-level-tests # Build with HDF5 1.10 hdf5-110: @@ -83,10 +92,10 @@ jobs: command: pip3 install numpy - run: name: Installing Python package - command: pip3 install .[test] + command: pip3 install -e .[test] - run: name: Run full test suite (including bit-level tests) - command: python3 setup.py test --enable-bit-level-tests + command: pytest hyperion --enable-bit-level-tests workflows: version: 2 diff --git a/.travis.yml b/.travis.yml index 47be52f7..4da8820d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: global: - SETUP_XVFB=True - CONDA_CHANNELS='conda-forge' - - CONDA_DEPENDENCIES='numpy astropy h5py matplotlib yt mpich hdf5' + - CONDA_DEPENDENCIES='numpy astropy h5py matplotlib yt mpich hdf5 hdf5-static' - SETUP_CMD='test' - MPLBACKEND='Agg' matrix: @@ -23,8 +23,9 @@ install: - if [[ $TRAVIS_OS_NAME == osx ]]; then conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64; fi script: + - set -e - ./configure - make serial - sudo make install - - python setup.py install # to get the hyperion script installed - - python setup.py $SETUP_CMD + - pip install -e .[test] + - pytest hyperion diff --git a/Makefile.in b/Makefile.in index 636f707b..ad9522f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -294,6 +294,6 @@ vor_mpi: $(OBJECTS_VOR_MPI) install: bin/hyperion_* mkdir -p @prefix@/bin - cp bin/hyperion_* @prefix@/bin/ + cp -r bin/hyperion_* @prefix@/bin/ clean:; rm *.mod src/*.mod src/*/*.mod *.o */*.o bin/* *~ */*~ fort.* ; echo "This file can be deleted." > bin/empty.txt ; echo "This file can be deleted." > src/modules/empty.txt diff --git a/hyperion/conftest.py b/hyperion/conftest.py index 5571d055..aa894a43 100644 --- a/hyperion/conftest.py +++ b/hyperion/conftest.py @@ -5,11 +5,19 @@ 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) \ No newline at end of file + 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) diff --git a/hyperion/model/tests/test_bit_level.py b/hyperion/model/tests/test_bit_level.py index 66af6b75..3826f547 100644 --- a/hyperion/model/tests/test_bit_level.py +++ b/hyperion/model/tests/test_bit_level.py @@ -9,10 +9,8 @@ import shutil import itertools -try: - import pytest -except: - from astropy.tests.helper import pytest +import pytest + import numpy as np from six import StringIO @@ -26,7 +24,6 @@ DATA = os.path.join(os.path.dirname(__file__), 'data') -bit_level = pytest.mark.skipif(str(not pytest.config.getoption('enable_bit_level_tests'))) @pytest.fixture(scope="module") def generate(request): @@ -137,7 +134,7 @@ def setup_class(self): setup_all_grid_types(self, pc, 1.e-20) self.dust_file = os.path.join(DATA, 'kmh_lite.hdf5') - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('grid_type', 'sample_sources_evenly', 'multiple_densities'), list(itertools.product(GRID_TYPES, [False, True], [False, True]))) def test_specific_energy(self, tmpdir, grid_type, sample_sources_evenly, multiple_densities, generate): @@ -175,7 +172,7 @@ def test_specific_energy(self, tmpdir, grid_type, sample_sources_evenly, multipl reference_file = os.path.join(DATA, function_name() + ".rtout") assert_identical_results(output_file, reference_file) - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('grid_type', 'raytracing', 'sample_sources_evenly'), list(itertools.product(GRID_TYPES, [False, True], [False, True]))) def test_peeloff(self, tmpdir, grid_type, raytracing, sample_sources_evenly, generate): @@ -339,7 +336,7 @@ def setup_class(self): def teardown_class(self): shutil.rmtree(self.tmpdir) - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('tau'), [0.1, 1, 10, 100]) def test_pascucci(self, tmpdir, tau, generate): @@ -445,7 +442,7 @@ class TestPinteBenchmark(object): The current tests do not test the imaging part of the Pinte benchmark. ''' - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('tau'), [1000, 10000, 100000, 1000000]) def test_pinte_seds(self, tmpdir, tau, generate): @@ -547,7 +544,7 @@ def test_pinte_seds(self, tmpdir, tau, generate): reference_file = os.path.join(DATA, function_name() + ".rtout") assert_identical_results(output_file, reference_file) - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('tau'), [1000, 10000, 100000, 1000000]) def test_pinte_images(self, tmpdir, tau, generate): @@ -638,7 +635,7 @@ def test_pinte_images(self, tmpdir, tau, generate): reference_file = os.path.join(DATA, function_name() + ".rtout") assert_identical_results(output_file, reference_file) - @bit_level + @pytest.mark.bitlevel @pytest.mark.parametrize(('tau'), [1000, 10000, 100000, 1000000]) def test_pinte_specific_energy(self, tmpdir, tau, generate): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..922cde97 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,33 @@ +[metadata] +name = Hyperion +url = http://www.hyperion-rt.org +author = Thomas Robitaille +author_email = thomas.robitaille@gmail.com +license = BSD +description = Monte-Carlo Radiative Transfer Code + +[options] +zip_safe = True +packages = find: +include_package_data = True +setup_requires = numpy>=1.11 +install_requires = + numpy>=1.11 + matplotlib>=1.5 + astropy>=1.2 + h5py>=2.4 + yt>=3.2 + six + +[options.extras_require] +docs = + sphinx + numpydoc +test = + pytest + +[options.package_data] +hyperion.model.tests = data/*.rtout, data/*.hdf5 +hyperion.importers.tests = data/*.hdf5 +hyperion.grid.tests = data/*.hdf5, data/DD0010/* +hyperion.testing = coveragerc diff --git a/setup.py b/setup.py index ea88c6a2..b46a3ba8 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from distutils.command.build_ext import build_ext from hyperion.testing.helper import HyperionTest -from hyperion.version import __version__, __dev__ +from hyperion.version import __version__ class custom_sdist(sdist): @@ -81,25 +81,7 @@ def run(self): extra_compile_args = ['-O2', '-Wno-error=declaration-after-statement'], extra_link_args=['-lstdc++'])] -scripts = ['hyperion', 'hyperion2fits'] - -setup(name='Hyperion', - version=__version__, - url='http://www.hyperion-rt.org', - description='Monte-Carlo Radiative Transfer Code', - long_description='Monte-Carlo Radiative Transfer Code', - author='Thomas Robitaille', - author_email='thomas.robitaille@gmail.com', - license='BSD', - packages=find_packages(), - package_data={'hyperion.model.tests': ['data/*.rtout', 'data/*.hdf5'], - 'hyperion.importers.tests': ['data/*.hdf5'], - 'hyperion.grid.tests': ['data/*.hdf5', 'data/DD0010/*'], - 'hyperion.testing': ['coveragerc']}, - scripts=['scripts/' + x for x in scripts], +setup(version=__version__, + scripts=['scripts/hyperion', 'scripts/hyperion2fits'], cmdclass=cmdclass, - ext_modules=ext_modules, - setup_requires=['numpy>=1.11'], - install_requires=['numpy>=1.11', 'matplotlib>=1.5', 'astropy>=1.2', 'h5py>=2.4', 'yt>=3.2', 'six'], - extras_require={'test': ['pytest'], - 'docs': ['sphinx', 'numpydoc']}) + ext_modules=ext_modules)