From 1e8a323c1968ed579b9211b52cb1a1a14a622540 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 7 Feb 2019 23:11:59 +0000 Subject: [PATCH 1/7] Use setup.cfg --- setup.cfg | 33 +++++++++++++++++++++++++++++++++ setup.py | 26 ++++---------------------- 2 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 setup.cfg 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) From 6bde298dc8700281e88103fcc9ae8e0390c23547 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 12:30:47 +0100 Subject: [PATCH 2/7] Fix compatibility with recent versions of pytest --- hyperion/conftest.py | 12 ++++++++++-- hyperion/model/tests/test_bit_level.py | 19 ++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) 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): From c90381af40df57715550f575d73fc3dd5e11019b Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 14:37:46 +0100 Subject: [PATCH 3/7] Update how tests are run and install hdf5-static from conda-forge --- .circleci/config.yml | 12 ++++++------ .travis.yml | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 403644b7..12837e8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,10 +29,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: @@ -56,10 +56,10 @@ jobs: command: pip install numpy - run: name: Installing Python package - command: pip install .[test] + command: pip install -e .[test] - 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 +83,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 From e29ede9fe4bfcad32d2ed25f01f6e0dbeeebbb75 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 14:59:35 +0100 Subject: [PATCH 4/7] Upgrade setuptools and pip --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 12837e8a..00dd5928 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 @@ -51,6 +54,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 From b249c558ad7f2af222b67e34723f4808d5ed45a7 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 18:09:14 +0100 Subject: [PATCH 5/7] Install Cython into HDF5 1.8 environment --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00dd5928..e37060b5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,7 +59,7 @@ jobs: 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 -e .[test] From 59500ae12e60bca64c831a900a0989c5d9f70e0d Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 21:26:42 +0100 Subject: [PATCH 6/7] Try and fix continuous integration --- .circleci/config.yml | 3 +++ Makefile.in | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e37060b5..db43a183 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,9 @@ jobs: - run: name: Installing Python package 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: pytest hyperion --enable-bit-level-tests diff --git a/Makefile.in b/Makefile.in index 636f707b..460d11cf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -294,6 +294,7 @@ vor_mpi: $(OBJECTS_VOR_MPI) install: bin/hyperion_* mkdir -p @prefix@/bin - cp bin/hyperion_* @prefix@/bin/ + cp bin/hyperion_??? @prefix@/bin/ + cp bin/hyperion_???_mpi @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 From 89aa5289a614e177b12ef133359c71f6e7ea79be Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 14 May 2020 21:50:33 +0100 Subject: [PATCH 7/7] Try and fix copy command --- Makefile.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 460d11cf..ad9522f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -294,7 +294,6 @@ vor_mpi: $(OBJECTS_VOR_MPI) install: bin/hyperion_* mkdir -p @prefix@/bin - cp bin/hyperion_??? @prefix@/bin/ - cp bin/hyperion_???_mpi @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