From 3ba47613837d86621b3e00ad12e0bd137420687e Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 20 Nov 2023 13:39:29 -0500 Subject: [PATCH 01/13] WIP Move metadata to pyproject.toml --- pyproject.toml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1e50d68 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[project] +name = "livereduce" +description = "Daemon for running live data reduction with systemd" +version="1.10" +#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" + +#TODO define entrypoints From 13bd65f8f396304d0e3dff6c7f153db593674a3c Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 08:05:06 -0500 Subject: [PATCH 02/13] Add python-build so wheels can be made --- environment.yml | 1 + 1 file changed, 1 insertion(+) 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 From 275f406e63a388655c71ebdcb077f9d28dba770e Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 08:23:29 -0500 Subject: [PATCH 03/13] Change how source distribution is created --- rpmbuild | 2 +- setup.py | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 setup.py diff --git a/rpmbuild b/rpmbuild index b6b8876..7f470ac 100755 --- a/rpmbuild +++ b/rpmbuild @@ -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"])], -) From 9c0b89795131f7ef60f7cb8dcb109bd5ecf87da7 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 08:56:32 -0500 Subject: [PATCH 04/13] Add action to build source distribution --- .github/workflows/actions.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/actions.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..d636217 --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,32 @@ +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: | + python -m build --sdist --no-isolation From 458c493c1dabb4df91be9e7914291ee75c0ed00c Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 11:28:37 -0500 Subject: [PATCH 05/13] Tell setuptools where to look for things --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1e50d68..eaed9e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,4 +18,8 @@ requires = [ ] build-backend = "setuptools.build_meta" +[tool.setuptools.packages.find] +where = ["."] +exclude = ["test"] + #TODO define entrypoints From dba72fef42a918784d86e20f33829b39bb11abd3 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 11:29:04 -0500 Subject: [PATCH 06/13] Add a comment about the wheels not working --- .github/workflows/actions.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index d636217..fc5be75 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -28,5 +28,6 @@ jobs: cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }} - name: Build source distribution shell: bash -l {0} - run: | + 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 From 7a45c35c571ba46849311d0c3e372ee8993726ed Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 14:47:11 -0500 Subject: [PATCH 07/13] Add package data to source distribution --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index eaed9e5..2b3eddd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,9 @@ requires = [ ] build-backend = "setuptools.build_meta" +[tool.setuptools] +include-package-data=true + [tool.setuptools.packages.find] where = ["."] exclude = ["test"] From fe4c55ca23883763d6de0fe6f11cd988797c46fd Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 20 Nov 2023 13:39:29 -0500 Subject: [PATCH 08/13] Move metadata to pyproject.toml --- pypyroject.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pypyroject.toml diff --git a/pypyroject.toml b/pypyroject.toml new file mode 100644 index 0000000..4888fc3 --- /dev/null +++ b/pypyroject.toml @@ -0,0 +1,14 @@ +[project] +name = "livereduce" +description = "Daemon for running live data reduction with systemd" +version="1.10" +#dynamic = ["version"] +requires-python = ">=3.9" +#dependencies = [ +# "mantidworkbench >= 6.7.20230830", +# "pyoncat ~= 1.6" +#] license = { text = "MIT License" } +authors = [{name="Pete Peterson",email="petersonpf@ornl.gov"}] + +[project.urls] +Homepage = "https://github.com/mantidproject/livereduce" From 91d7d7d1e5ba65b22d2e603a5aa6483ef4f991ba Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 16:09:50 -0500 Subject: [PATCH 09/13] Switch from python install to installing directly in spec file --- livereduce.spec | 31 ++++++++++++++++++------------- pyproject.toml | 3 +++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/livereduce.spec b/livereduce.spec index 1fa0427..ff73f1a 100644 --- a/livereduce.spec +++ b/livereduce.spec @@ -16,7 +16,7 @@ BuildArch: noarch Vendor: Pete Peterson Url: https://github.com/mantidproject/livereduce -BuildRequires: python%{python3_pkgversion} python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion} Requires: python%{python3_pkgversion} Requires: jq @@ -25,34 +25,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 index 2b3eddd..4c009aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,4 +25,7 @@ include-package-data=true where = ["."] exclude = ["test"] +[tool.setuptools.package-data] +"*" = ["*.sh", "*.service"] + #TODO define entrypoints From 12c7c5060236555e4840bf042ddd0cbe20194542 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 17:01:47 -0500 Subject: [PATCH 10/13] Remove accidentally named file --- pypyroject.toml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 pypyroject.toml diff --git a/pypyroject.toml b/pypyroject.toml deleted file mode 100644 index 4888fc3..0000000 --- a/pypyroject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "livereduce" -description = "Daemon for running live data reduction with systemd" -version="1.10" -#dynamic = ["version"] -requires-python = ">=3.9" -#dependencies = [ -# "mantidworkbench >= 6.7.20230830", -# "pyoncat ~= 1.6" -#] license = { text = "MIT License" } -authors = [{name="Pete Peterson",email="petersonpf@ornl.gov"}] - -[project.urls] -Homepage = "https://github.com/mantidproject/livereduce" From 735232d852ad637c5b765ec9fabb0b641d850f72 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 22 Nov 2023 17:03:39 -0500 Subject: [PATCH 11/13] Bump version to 1.11 --- livereduce.spec | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/livereduce.spec b/livereduce.spec index ff73f1a..e0dd750 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 diff --git a/pyproject.toml b/pyproject.toml index 4c009aa..5d490c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "livereduce" description = "Daemon for running live data reduction with systemd" -version="1.10" +version="1.11" #dynamic = ["version"] requires-python = ">=3.9" license = { text = "MIT License" } From 89097a732c26828739f92df40cfa9e9791f8e1c4 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 27 Nov 2023 13:53:52 -0500 Subject: [PATCH 12/13] Rename script for creating the rpm --- README.md | 2 +- rpmbuild => rpmbuild.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename rpmbuild => rpmbuild.sh (100%) 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/rpmbuild b/rpmbuild.sh similarity index 100% rename from rpmbuild rename to rpmbuild.sh From 36a913f4ea9f5ac34e541955e671c819f664feec Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Wed, 29 Nov 2023 16:13:03 -0500 Subject: [PATCH 13/13] Missed systemd-rpm-macros as build requirement --- livereduce.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/livereduce.spec b/livereduce.spec index e0dd750..e0f6d0b 100644 --- a/livereduce.spec +++ b/livereduce.spec @@ -17,6 +17,7 @@ Vendor: Pete Peterson Url: https://github.com/mantidproject/livereduce BuildRequires: python%{python3_pkgversion} +BuildRequires: systemd-rpm-macros Requires: python%{python3_pkgversion} Requires: jq