diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ededed..93574a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,13 +11,17 @@ on: jobs: job: - name: Build + name: Build (${{ matrix.extra }}) runs-on: ubuntu-latest strategy: matrix: python-version: [ '3.12', ] + extra: [ + casa, + pipeline, + ] steps: - uses: actions/checkout@v7 with: @@ -31,6 +35,6 @@ jobs: python -m pip install --upgrade pip pip install build pip install . - pip install .[casa] + pip install ".[${{ matrix.extra }}]" - name: Build package run: python -m build diff --git a/phangsPipeline/casaStuff.py b/phangsPipeline/casaStuff.py index ea06715..5dc2718 100644 --- a/phangsPipeline/casaStuff.py +++ b/phangsPipeline/casaStuff.py @@ -2,7 +2,6 @@ import casashell import casatasks import casatools -import casaplotms from almahelpers_localcopy import tsysspwmap from casatasks import ( casalog, @@ -51,10 +50,22 @@ quanta, ) +# plotms is only needed within the ALMA SD pipeline +try: + import casaplotms + plotms = casaplotms.plotms + +except (ImportError, ModuleNotFoundError): + plotms = None + print("Could not import casaplotms") + try: import casaviewer + viewer = casaviewer.imview + except (ImportError, ModuleNotFoundError): casaviewer = None + viewer = None print("Could not import casaviewer") # TODO: Move back to CASA task @@ -79,7 +90,3 @@ tbtool = table metool = measures qatool = quanta - -plotms = casaplotms.plotms -if casaviewer is not None: - viewer = casaviewer.imview diff --git a/pyproject.toml b/pyproject.toml index c8e484d..f9e55d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ name = "phangsPipeline" dynamic = ["version"] description = "PHANGS-ALMA Pipeline" readme = "README.md" -requires-python = ">=3.12, <3.13" +requires-python = ">=3.12" license = {file = "LICENSE"} authors = [ @@ -52,13 +52,22 @@ dependencies = [ [project.optional-dependencies] casa = [ "casadata >= 2025.9.22", - "casaplotms >= 2.8.2", "casarecipes >= 0.4.0", - "casashell >= 6.7.3.21, < 6.7.6.14", - "casatasks >= 6.7.3.21, < 6.7.6.14", - "casatools >= 6.7.3.21, < 6.7.6.14", - "casaviewer >= 2.4.4 ; platform_system != 'Darwin'", + "casashell >= 6.7.3.21", + "casatasks >= 6.7.3.21", + "casatools >= 6.7.3.21", +] +pipeline = [ + "casaplotms >= 2.8.2", # plotms is only used within the ALMA SD pipeline. "pipeline@git+https://open-bitbucket.nrao.edu/scm/pipe/pipeline.git", + "phangsPipeline[casa]", +] +viewer = [ + "casaviewer >= 2.4.4 ; platform_system != 'Darwin'", +] + +all = [ + "phangsPipeline[casa,viewer,pipeline]", ] # Optional packages for the test suite diff --git a/pytest.toml b/pytest.toml index d0bed0e..2129635 100644 --- a/pytest.toml +++ b/pytest.toml @@ -7,6 +7,7 @@ addopts = [ ] markers = [ "casa: marks tests as requiring CASA install (deselect with '-m \"not casa\"')", + "pipeline: marks tests as requiring the ALMA SD pipeline/plotms install, a superset of casa (deselect with '-m \"not pipeline\"')", ] testpaths = [ "tests", diff --git a/tests/test_casa_imports.py b/tests/test_casa_imports.py index 3e2c336..9f08db7 100644 --- a/tests/test_casa_imports.py +++ b/tests/test_casa_imports.py @@ -1,5 +1,4 @@ import pytest -import sys from inspect import getfullargspec try: @@ -32,14 +31,7 @@ class TestCASAImports: casa_imports = [ "casashell", - "casaplotms", - pytest.param( - "casaviewer", - marks=pytest.mark.xfail( - sys.platform == "darwin", - reason="casaviewer not available on Mac OS X", - ), - ), + pytest.param("casaplotms", marks=pytest.mark.pipeline), "casatasks.private.sdint_helper", ] diff --git a/tox.ini b/tox.ini index 7544515..afeb61c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py3{12}{,-casa}{,-oldestdeps,-cov} + py3{12}{,-casa,-pipeline}{,-oldestdeps,-cov} lint docs requires = @@ -38,41 +38,44 @@ allowlist_externals = description = run tests casa: with CASA packages enabled + pipeline: with CASA + pipeline packages enabled oldestdeps: with the oldest supported dependencies cov: with coverage deps = oldestdeps: minimum_dependencies extras = casa: casa + pipeline: pipeline test - casa: test-casa + casa,pipeline: test-casa commands = echo Running on {env:PLATFORM} - # If using CASA, create a temp directory to install data - casa: rm -rf {env:ENVDIR} - casa: mkdir -p {env:ENVDIR} + # If using CASA or the pipeline extra, create a temp directory to install data + casa,pipeline: rm -rf {env:ENVDIR} + casa,pipeline: mkdir -p {env:ENVDIR} # Move CASA startup files - casa: mkdir -p {env:ENVDIR}{/}.casa - casa: cp {env:CASACONFIGDIR}{/}startup.py {env:ENVDIR}{/}.casa{/} - casa: cp {env:CASACONFIGDIR}{/}config.py {env:ENVDIR}{/}.casa{/} + casa,pipeline: mkdir -p {env:ENVDIR}{/}.casa + casa,pipeline: cp {env:CASACONFIGDIR}{/}startup.py {env:ENVDIR}{/}.casa{/} + casa,pipeline: cp {env:CASACONFIGDIR}{/}config.py {env:ENVDIR}{/}.casa{/} # Download CASA data - casa: mkdir -p {env:CASADIR}{/}data - casa: python -m casaconfig --update-all - casa: python -m casaconfig --current-data + casa,pipeline: mkdir -p {env:CASADIR}{/}data + casa,pipeline: python -m casaconfig --update-all + casa,pipeline: python -m casaconfig --current-data # Download and extract the latest analysisUtils - casa: uvx zenodo_get 10.5281/zenodo.7502159 -o {env:ENVDIR} - casa: tar -xf {env:ENVDIR}{/}analysis_scripts.tar -C {env:ENVDIR}{/} + casa,pipeline: uvx zenodo_get 10.5281/zenodo.7502159 -o {env:ENVDIR} + casa,pipeline: tar -xf {env:ENVDIR}{/}analysis_scripts.tar -C {env:ENVDIR}{/} {list_dependencies_command} # Run tests - !casa: pytest -m "not casa" \ - casa: pytest \ + !casa-!pipeline: pytest -m "not casa" \ + casa-!pipeline: pytest -m "not pipeline" \ + pipeline: pytest \ cov: --cov --cov-branch --cov-report=xml:{env:PLATFORM}-{envname}-coverage.xml \ cov: --junitxml={env:PLATFORM}-{envname}-junit.xml -o junit_family=legacy \ {posargs}