diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..fc5be75 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,33 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + push: + branches: [main, qa, next] + tags: ['v*'] + +jobs: + python-build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - name: Set up MicroMamaba + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: environment.yml + condarc: | + channels: + - conda-forge + - mantid + - default + cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }} + cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }} + - name: Build source distribution + shell: bash -l {0} + run: | # this is used as part of making the rpm + python -m build --sdist --no-isolation + # the wheel isn't build because this is a unusual package diff --git a/README.md b/README.md index 1606728..954bc69 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Testing is described in the `test/` subdirectory. This package uses a hand-written spec file for releasing on rpm based systems rather than the one generated by python. To run it execute ``` -./rpmbuild +./rpmbuild.sh ``` And look for the results in the `dist` directory. diff --git a/environment.yml b/environment.yml index d9b33d3..079cf66 100644 --- a/environment.yml +++ b/environment.yml @@ -8,3 +8,4 @@ dependencies: - mantid # framework only - pyinotify - pre-commit + - python-build diff --git a/livereduce.spec b/livereduce.spec index 1fa0427..e0f6d0b 100644 --- a/livereduce.spec +++ b/livereduce.spec @@ -5,7 +5,7 @@ Summary: %{summary} Name: python-%{srcname} -Version: 1.10 +Version: 1.11 Release: %{release}%{?dist} Source0: %{srcname}-%{version}.tar.gz License: MIT @@ -16,7 +16,8 @@ BuildArch: noarch Vendor: Pete Peterson Url: https://github.com/mantidproject/livereduce -BuildRequires: python%{python3_pkgversion} python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion} +BuildRequires: systemd-rpm-macros Requires: python%{python3_pkgversion} Requires: jq @@ -25,34 +26,39 @@ Requires: nsd-app-wrap %description There should be a meaningful description, but it is not needed quite yet. -%{?python_provide:%python_provide python-%{srcname}} +%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} %prep -%setup -n %{srcname}-%{version} -n %{srcname}-%{version} +%setup -q -n %{srcname}-%{version} -n %{srcname}-%{version} %build -%py3_build +# no build step %install -%py3_install +%{__rm} -rf $RPM_BUILD_ROOT +# put things in the bin directory +%{__mkdir} -p %{buildroot}%{_bindir}/ +%{__install} -m 644 scripts/livereduce.py %{buildroot}%{_bindir}/ +%{__install} -m 755 scripts/livereduce.sh %{buildroot}%{_bindir}/ +%{__mkdir} -p %{buildroot}%{_unitdir}/ +%{__install} -m 644 livereduce.service %{buildroot}%{_unitdir}/ %check -%{__python3} setup.py test +# no test step %clean -rm -rf $RPM_BUILD_ROOT +%{__rm} -rf $RPM_BUILD_ROOT %post -mkdir -p /var/log/SNS_applications/ -chown snsdata /var/log/SNS_applications/ -chmod 1755 /var/log/SNS_applications/ +%{__mkdir} -p /var/log/SNS_applications/ +%{__chown} snsdata /var/log/SNS_applications/ +%{__chmod} 1755 /var/log/SNS_applications/ %preun -rm -f /var/log/SNS_applications/livereduce.log* +%{__rm} -f /var/log/SNS_applications/livereduce.log* %files %doc README.md -%{python3_sitelib}/* %{_bindir}/livereduce.py %{_bindir}/livereduce.sh -%{_prefix}/lib/systemd/system/livereduce.service +%{_unitdir}/livereduce.service diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5d490c1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,31 @@ +[project] +name = "livereduce" +description = "Daemon for running live data reduction with systemd" +version="1.11" +#dynamic = ["version"] +requires-python = ">=3.9" +license = { text = "MIT License" } +authors = [{name="Pete Peterson",email="petersonpf@ornl.gov"}] + +[project.urls] +Homepage = "https://github.com/mantidproject/livereduce" + +[build-system] +requires = [ + "setuptools", + "wheel", + "toml" + ] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data=true + +[tool.setuptools.packages.find] +where = ["."] +exclude = ["test"] + +[tool.setuptools.package-data] +"*" = ["*.sh", "*.service"] + +#TODO define entrypoints diff --git a/rpmbuild b/rpmbuild.sh similarity index 86% rename from rpmbuild rename to rpmbuild.sh index b6b8876..7f470ac 100755 --- a/rpmbuild +++ b/rpmbuild.sh @@ -1,6 +1,6 @@ #!/bin/sh rm -rf dist livereduce.egg-info -python setup.py sdist +python -m build --sdist --no-isolation cp dist/livereduce-*.tar.gz ~/rpmbuild/SOURCES/ rpmbuild -ba livereduce.spec cp ~/rpmbuild/RPMS/noarch/python-livereduce-*-*.*.noarch.rpm dist/ diff --git a/setup.py b/setup.py deleted file mode 100644 index 36b46d4..0000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name="livereduce", - version="1.10", - description="Need a description", - author="Pete Peterson", - author_email="petersonpf@ornl.gov", - url="https://github.com/mantidproject/livereduce", - long_description="""Daemon for running live data reduction with systemd""", - license="The MIT License (MIT)", - scripts=["scripts/livereduce.py", "scripts/livereduce.sh"], - packages=find_packages(), - package_dir={}, - setup_requires=[], - data_files=[("/usr/lib/systemd/system/", ["livereduce.service"])], -)