From 0911ef5198efd0fd2ad36070cb40d378e608900e Mon Sep 17 00:00:00 2001 From: "Kevin A. Tactac" <150723597+ktactac-ornl@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:10:07 -0400 Subject: [PATCH] Ewm7212 conda package (#4) Complete, squashing --- .github/workflows/package.yml | 51 +++++++++++++++++++ .pre-commit-config.yaml | 1 + conda.recipe/meta.yaml | 46 +++++++++++++++++ environment.yml | 18 +++++++ pyproject.toml | 30 ++++++++++- .../mantidprofiler/algorithm_tree.py | 0 .../mantidprofiler/diskrecord.py | 1 - .../mantidprofiler/mantidprofiler.py | 3 +- psrecord.py => src/mantidprofiler/psrecord.py | 1 - .../mantidprofiler/time_util.py | 0 10 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/package.yml create mode 100644 conda.recipe/meta.yaml create mode 100644 environment.yml rename algorithm_tree.py => src/mantidprofiler/algorithm_tree.py (100%) rename diskrecord.py => src/mantidprofiler/diskrecord.py (99%) rename mantid-profiler.py => src/mantidprofiler/mantidprofiler.py (99%) rename psrecord.py => src/mantidprofiler/psrecord.py (99%) rename time_util.py => src/mantidprofiler/time_util.py (100%) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..4bb621d --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,51 @@ +name: conda packaging and deployment + +on: + workflow_dispatch: + push: + branches: [main] + tags: ['v*'] + pull_request: + +jobs: + linux: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + channels: conda-forge,defaults + use-mamba: true + environment-file: environment.yml + cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }} + cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }} + + - name: build and verify wheel + run: | + python -m build --wheel --no-isolation + check-wheel-contents dist/mantidprofiler-*.whl + + - name: build conda package + run: | + # set up environment + cd conda.recipe + echo "versioningit $(versioningit ../)" + # build the package + VERSION=$(versioningit ../) conda mambabuild --channel conda-forge --output-folder . . + conda verify noarch/mantidprofiler*.tar.bz2 + - name: upload conda package to anaconda + shell: bash -l {0} + if: startsWith(github.ref, 'refs/tags/v') + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} + IS_RC: ${{ contains(github.ref, 'rc') }} + run: | + # label is main or rc depending on the tag-name + CONDA_LABEL="main" + if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi + echo pushing ${{ github.ref }} with label $CONDA_LABEL + anaconda upload --label $CONDA_LABEL conda.recipe/noarch/mantidprofiler*.tar.bz2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78d2a0e..e4ff9af 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,7 @@ repos: - id: check-added-large-files args: [--maxkb=8192] - id: check-yaml + exclude: "conda.recipe/meta.yaml" - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml new file mode 100644 index 0000000..c9091af --- /dev/null +++ b/conda.recipe/meta.yaml @@ -0,0 +1,46 @@ +# 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 version_number = version.split('+')[0] %} +# change the build number by hand if you want to rebuild the package +{% set build_number = 0 %} + +package: + name: mantidprofiler + version: {{ version_number }} + +source: + path: .. + +build: + noarch: python + number: {{ build_number }} + string: py{{py}} + script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vvv + +requirements: + host: + - python + - versioningit + - setuptools>=42 + - wheel + + build: + - setuptools>=42 + - versioningit + + run: + - python + +about: + home: {{ url }} + license: {{ license }} + license_family: GPL + license_file: ../LICENSE + summary: {{ description }} diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..dbe0291 --- /dev/null +++ b/environment.yml @@ -0,0 +1,18 @@ +name: mantid-profiler +channels: + - conda-forge +dependencies: + - anaconda-client + - boa + - check-wheel-contents + - conda-build < 4 + - conda-verify + - libmamba + - libarchive + - pre-commit + - psutil + - python-build + - setuptools + - toml + - versioningit + - wheel diff --git a/pyproject.toml b/pyproject.toml index 15102fa..6bb454c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,40 @@ [project] name = "mantidprofiler" description = "Uses psrecord and plotly.js to profile a mantid workflow" +dynamic = ["version"] requires-python = ">=3.10" readme = "README.md" license = { text = "GPL3.0" } +[project.urls] +homepage = "https://github.com/mantidproject/mantid-profiler/" +repository = "https://github.com/mantidproject/mantid-profiler/" +issues = "https://github.com/mantidproject/mantid-profiler/issues" + [build-system] -requires = ["setuptools", "wheel", "toml"] +requires = ["setuptools", "wheel", "toml", "versioningit"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +"*" = ["*.yml","*.yaml","*.ini"] + +[tool.versioningit.vcs] +method = "git" +default-tag = "0.0.1" + +[tool.versioningit.next-version] +method = "minor" + +[tool.versioningit.format] +distance = "{next_version}.dev{distance}" +dirty = "{version}+d{build_date:%Y%m%d}" +distance-dirty = "{next_version}.dev{distance}+d{build_date:%Y%m%d%H%M}" + +[tool.versioningit.write] +file = "src/mantidprofiler/_version.py" [tool.ruff] line-length = 120 diff --git a/algorithm_tree.py b/src/mantidprofiler/algorithm_tree.py similarity index 100% rename from algorithm_tree.py rename to src/mantidprofiler/algorithm_tree.py diff --git a/diskrecord.py b/src/mantidprofiler/diskrecord.py similarity index 99% rename from diskrecord.py rename to src/mantidprofiler/diskrecord.py index d8d3d74..afb5e7a 100644 --- a/diskrecord.py +++ b/src/mantidprofiler/diskrecord.py @@ -4,7 +4,6 @@ import numpy as np import psutil - from time_util import get_current_time, get_start_time diff --git a/mantid-profiler.py b/src/mantidprofiler/mantidprofiler.py similarity index 99% rename from mantid-profiler.py rename to src/mantidprofiler/mantidprofiler.py index 7f44980..674e5cf 100644 --- a/mantid-profiler.py +++ b/src/mantidprofiler/mantidprofiler.py @@ -20,9 +20,8 @@ from pathlib import Path from threading import Thread -import numpy as np - import algorithm_tree as at +import numpy as np from diskrecord import monitor as diskmonitor from diskrecord import parse_log as parse_disk_log from psrecord import monitor as cpumonitor diff --git a/psrecord.py b/src/mantidprofiler/psrecord.py similarity index 99% rename from psrecord.py rename to src/mantidprofiler/psrecord.py index 6c43a69..90f37bf 100644 --- a/psrecord.py +++ b/src/mantidprofiler/psrecord.py @@ -37,7 +37,6 @@ import numpy as np import psutil - from time_util import get_current_time, get_start_time diff --git a/time_util.py b/src/mantidprofiler/time_util.py similarity index 100% rename from time_util.py rename to src/mantidprofiler/time_util.py