diff --git a/.github/workflows/unittest.yml b/.github/workflows/workflow.yml similarity index 69% rename from .github/workflows/unittest.yml rename to .github/workflows/workflow.yml index afef764..49b42d3 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/workflow.yml @@ -37,7 +37,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - conda-build: + python-build: runs-on: ubuntu-latest defaults: run: @@ -54,21 +54,50 @@ jobs: - conda-forge - mcvine - mantid - - name: install multiphonon - run: | - python -m pip install -e . - - name: building python wheel + - name: Build python wheel shell: bash -l {0} run: | python -m build --wheel --no-isolation + check-wheel-contents dist/multiphonon-*.whl + - name: Upload python wheel in the repo # the artifact is saved for building the conda package + uses: actions/upload-artifact@v4 + with: + name: multiphonon_wheel + path: dist/multiphonon-*.whl + conda-build: + needs: python-build + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v4 + - uses: mamba-org/setup-micromamba@v1 + with: + environment-file: conda_environment.yml + cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/conda_environment.yml') }} + cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/conda_environment.yml') }} + condarc: | + channels: + - conda-forge + - mantid + - mcvine + - name: Download python wheel from python-build + uses: actions/download-artifact@v4 + with: + name: multiphonon_wheel + path: dist + - shell: bash -l {0} + run: | + # show files + ls -la - name: build conda package shell: bash -l {0} run: | - # set up environment + # enter conda cd conda.recipe echo "versioningit $(versioningit ../)" # build the package - CHANNELS="--channel mcvine --channel mantid --channel conda-forge" VERSION=$(versioningit ../) conda mambabuild --output-folder . . conda verify noarch/multiphonon*.tar.bz2 - name: upload conda package to anaconda diff --git a/.gitignore b/.gitignore index 9195ee7..15bef93 100644 --- a/.gitignore +++ b/.gitignore @@ -26,9 +26,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST -conda.recipe/ src/multiphonon/_version.py -!conda.recipe/meta.yaml # PyInstaller # Usually these files are written by a python script from a template diff --git a/README.md b/README.md index cedfd1f..0d67a6d 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,33 @@ This code converts a S(Q,E) INS spectrum to DOS. * Intermediate results are saved for further investigation * Handle inputs in nxs and nxspe files for sample and empty can measurements (requires Mantid) +## Development Installation and Testing + +Create and activate conda environment for shiver development + +```bash +conda env create +# or +mamba env create + +conda activate multiphonon +``` +The environment.yml is used for building the code in editable mode and creating the python wheel + +Install multiphonon (in editable mode) + +```bash +python -m pip install -e . + +``` + +```bash +pytest + +``` + +The conda_environment.yml is only used to build the multiphonon as a conda package. + ## Installation Installation is handled with conda. Please see [Installation instructions](https://sns-chops.github.io/multiphonon/installation.html) for details. diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat deleted file mode 100644 index cbf296f..0000000 --- a/conda-recipe/bld.bat +++ /dev/null @@ -1 +0,0 @@ -echo Windows build is not supported diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh deleted file mode 100644 index 50c8cfb..0000000 --- a/conda-recipe/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -python setup.py install --prefix=$PREFIX diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml deleted file mode 100644 index 50cddb7..0000000 --- a/conda-recipe/meta.yaml +++ /dev/null @@ -1,37 +0,0 @@ -package: - name: multiphonon - version: "0.1.6" - -source: - git_rev: v0.1.6 - git_url: https://github.com/neutrons/multiphonon.git - -requirements: - build: - - python - - numpy - - scipy - - run: - - python - - numpy - - histogram - - scipy - - matplotlib - - pytest - - pyyaml - - mantid -# - ipywe - -build: - noarch: python - script_env: - -test: - imports: - - multiphonon - -about: - home: - license: - license_file: diff --git a/conda-recipe/run-build.sh b/conda-recipe/run-build.sh deleted file mode 100755 index b73042a..0000000 --- a/conda-recipe/run-build.sh +++ /dev/null @@ -1 +0,0 @@ -conda build --python 3.9 --numpy 1.20 . diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml new file mode 100644 index 0000000..da55e04 --- /dev/null +++ b/conda.recipe/meta.yaml @@ -0,0 +1,54 @@ +# load information from pyproject.toml +{% set pyproject = load_file_data('pyproject.toml') %} +{% set project = pyproject.get('project', {}) %} +{% set license = project.get('license').get('text') %} +{% set description = project.get('description') %} +{% set project_url = pyproject.get('project', {}).get('urls') %} +{% set url = project_url.get('homepage') %} +# this will get the version set by environment variable +{% set version = environ.get('VERSION') %} +{% set git_describe_number = environ.get('GIT_DESCRIBE_NUMBER', '0') | string %} + +package: + name: multiphonon + version: {{version}} + +channels: + - conda-forge + +source: + path: .. + +build: + noarch: python + number: {{ git_describe_number }} + string: py{{py}} + script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv + +requirements: + host: + - python + - versioningit + + build: + - setuptools + - versioningit + + run: + - numpy + - histogram + - scipy + - matplotlib + - mantid + + test: + imports: + - multiphonon + + +about: + home: {{ url }} + license: {{ license }} + license_family: GPL + license_file: ../LICENSE + summary: {{ description }} diff --git a/conda_environment.yml b/conda_environment.yml new file mode 100644 index 0000000..2544c53 --- /dev/null +++ b/conda_environment.yml @@ -0,0 +1,37 @@ +#Only for conda build with boa depedency +#Only use for building a conda package: conda mambabuild +name: multiphonon_conda_build_only +channels: + - conda-forge + - mantid + - mcvine +dependencies: + - anaconda-client + - boa + - check-wheel-contents + - conda-build + - conda-verify + - coverage + - mantid >= 6.4 + - matplotlib + - libmamba + - libarchive + - pre-commit + - python >=3.8 + - pytest + - pytest-cov + - python-build + - sphinx + - sphinx-rtd-theme + - numpydoc + - versioningit + - setuptools + - coveralls + - ipywidgets # used in one test + - pyre == 0.8.3 + - histogram + - pip + - pip: + - numpy #<2.0.0 + - scipy + - ipywe == 0.1.3a1 diff --git a/environment.yml b/environment.yml index 65fa5ff..43802e5 100644 --- a/environment.yml +++ b/environment.yml @@ -1,24 +1,26 @@ +#default environment for installing python package +#Note: Use this name: multiphonon channels: - conda-forge - mcvine - mantid dependencies: - - anaconda-client - - boa + #- anaconda-client + #- boa - check-wheel-contents - - conda-build - - conda-verify + #- conda-build + #- conda-verify - coverage - histogram == 0.3.9 - - numpy == 1.20.3 - - scipy == 1.9.0 + - numpy >= 1.20.3,< 2.0 + - scipy >= 1.9.0,< 1.14.0 - python >=3.8 - pyre == 0.8.3 - mantid == 6.4 - matplotlib - - libmamba - - libarchive + #- libmamba + #- libarchive - pre-commit - pytest - pytest-cov diff --git a/pyproject.toml b/pyproject.toml index dc46107..0e0ce36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,8 +18,8 @@ requires = [ "wheel", "toml", "versioningit", - "numpy == 1.20.3", - "scipy == 1.9.0" + "numpy >= 1.20.3, <2.0", + "scipy >= 1.9.0, < 1.14.0" ] build-backend = "setuptools.build_meta"