17 Commits

Author SHA1 Message Date
ec685d24eb Switch from os.path to pathlib
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m53s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s
2025-11-06 13:54:58 +01:00
57c0037289 Migrate to pyproject.toml 2025-11-06 13:51:26 +01:00
58ef47468e Don't run setup.py directly
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m54s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
2025-11-05 11:29:02 +01:00
583526e219 Simplify conda-recipe
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 2s
pyzebra CI/CD pipeline / test-env (push) Successful in 2m5s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s
2025-11-03 15:30:05 +01:00
108c1aae2f Updating for version 0.7.11
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / prod-env (push) Successful in 1m30s
pyzebra CI/CD pipeline / test-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s
2025-04-08 18:19:58 +02:00
b82184b9e7 Switch from miniconda to miniforge
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 0s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m28s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 1s
2025-04-08 17:57:53 +02:00
b6a43c3f3b Remove scripts
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m42s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 0s
This is an outdated way of pyzebra deployment
2025-04-08 17:33:37 +02:00
18b692a62e Replace gitlab with gitea workflow
All checks were successful
pyzebra CI/CD pipeline / prepare (push) Successful in 1s
pyzebra CI/CD pipeline / test-env (push) Successful in 1m41s
pyzebra CI/CD pipeline / prod-env (push) Has been skipped
pyzebra CI/CD pipeline / cleanup (push) Successful in 0s
2025-04-08 17:03:01 +02:00
c2d6f6b259 Revert "Install via a direct package path"
This reverts commit dfa6bfe926.
2025-02-12 11:43:15 +01:00
60b90ec9e5 Always run cleanup job
[skip ci]
2025-02-11 18:12:27 +01:00
1fc30ae3e1 Build conda packages in CI_BUILDS_DIR 2025-02-11 18:10:13 +01:00
dfa6bfe926 Install via a direct package path 2025-02-11 18:07:57 +01:00
ed3f58436b Push release commit and tag
[skip ci]
2024-11-19 16:25:10 +01:00
68f7b429f7 Extract default branch name 2024-11-19 15:29:51 +01:00
e5030902c7 Infer path of file with version from path of release script 2024-11-19 15:26:56 +01:00
60f01d9dd8 Revert "Utility style fix"
This reverts commit dc1f2a92cc.
2024-09-09 00:06:28 +02:00
bd429393a5 Clean build folder
[skip ci]
2024-09-08 23:50:46 +02:00
15 changed files with 122 additions and 133 deletions

View File

@@ -0,0 +1,53 @@
name: pyzebra CI/CD pipeline
on:
push:
branches:
- main
tags:
- '*'
env:
CONDA: /opt/miniforge3
jobs:
prepare:
runs-on: pyzebra
steps:
- run: $CONDA/bin/conda config --add channels conda-forge
- run: $CONDA/bin/conda config --set solver libmamba
test-env:
runs-on: pyzebra
needs: prepare
if: github.ref == 'refs/heads/main'
env:
BUILD_DIR: ${{ runner.temp }}/conda_build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: $CONDA/bin/conda build --no-anaconda-upload --output-folder $BUILD_DIR ./conda-recipe
- run: $CONDA/bin/conda remove --name test --all --keep-env -y
- run: $CONDA/bin/conda install --name test --channel $BUILD_DIR python=3.8 pyzebra -y
- run: sudo systemctl restart pyzebra-test.service
prod-env:
runs-on: pyzebra
needs: prepare
if: startsWith(github.ref, 'refs/tags/')
env:
BUILD_DIR: ${{ runner.temp }}/conda_build
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: $CONDA/bin/conda build --token ${{ secrets.ANACONDA_TOKEN }} --output-folder $BUILD_DIR ./conda-recipe
- run: $CONDA/bin/conda remove --name prod --all --keep-env -y
- run: $CONDA/bin/conda install --name prod --channel $BUILD_DIR python=3.8 pyzebra -y
- run: sudo systemctl restart pyzebra-prod.service
cleanup:
runs-on: pyzebra
needs: [test-env, prod-env]
if: always()
steps:
- run: $CONDA/bin/conda build purge-all

View File

@@ -1,58 +0,0 @@
stages:
- build
- deploy
- publish
- cleanup
workflow:
rules:
- if: $CI_COMMIT_TAG
variables:
BUILD_PATH: /home/pyzebra/build-prod
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
BUILD_PATH: /home/pyzebra/build-test
default:
before_script:
- source /opt/miniconda3/etc/profile.d/conda.sh
build-job:
stage: build
script:
- conda config --add channels conda-forge
- conda config --set solver libmamba
- conda build --no-anaconda-upload --output-folder $BUILD_PATH ./conda-recipe
deploy-test-job:
stage: deploy
environment: testing
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- conda activate test
- conda install --channel $BUILD_PATH --force-reinstall pyzebra -y
- sudo systemctl restart pyzebra-test.service
deploy-prod-job:
stage: deploy
environment: production
rules:
- if: $CI_COMMIT_TAG
script:
- conda activate prod
- conda install --channel $BUILD_PATH pyzebra -y
- sudo systemctl restart pyzebra-prod.service
publish-job:
stage: publish
rules:
- if: $CI_COMMIT_TAG
script:
- conda activate base
- anaconda --token $ANACONDA_TOKEN upload $(conda build --output-folder $BUILD_PATH ./conda-recipe --output)
cleanup-job:
stage: cleanup
script:
- conda build purge-all

View File

@@ -1,2 +0,0 @@
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1

View File

@@ -1,2 +0,0 @@
#!/bin/bash
$PYTHON setup.py install --single-version-externally-managed --record=record.txt

View File

@@ -1,34 +1,36 @@
{% set data = load_setup_py_data() %}
{% set version_match = load_file_regex(load_file="pyzebra/__init__.py", regex_pattern='__version__ = "(.+?)"') %}
{% set version = version_match[1] %}
{% set pyproject = load_file_data('pyproject.toml') %}
package:
name: pyzebra
version: {{ data['version'] }}
name: {{ pyproject['project']['name'] }}
version: {{ version }}
source:
path: ..
build:
script: python -m pip install .
noarch: python
number: 0
entry_points:
- pyzebra = pyzebra.app.cli:main
requirements:
build:
host:
- python >=3.8
- setuptools
- hatchling
run:
- python >=3.8
- numpy
- scipy
- h5py
- bokeh =2.4
- numba
- lmfit >=1.0.2
{% for dep in pyproject['project']['dependencies'] %}
- {{ dep }}
{% endfor %}
about:
home: https://gitlab.psi.ch/zebra/pyzebra
summary: {{ data['description'] }}
license: GNU GPLv3
license_file: LICENSE
home: {{ pyproject['project']['urls']['Homepage'] }}
summary: {{ pyproject['project']['description'] }}
license: {{ pyproject['project']['license'] }}
license_file:
{% for lf in pyproject['project']['license-files'] %}
- {{ lf }}
{% endfor %}

View File

@@ -4,24 +4,27 @@ import argparse
import os
import re
import subprocess
from pathlib import Path
def main():
default_branch = "main"
branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode().strip()
if branch != "main":
print("Aborting, not on 'main' branch.")
if branch != default_branch:
print(f"Aborting, not on '{default_branch}' branch.")
return
filepath = "pyzebra/__init__.py"
project_path = Path(__file__).resolve().parent
version_filepath = project_path / project_path.name / "__init__.py"
parser = argparse.ArgumentParser()
parser.add_argument("level", type=str, choices=["patch", "minor", "major"])
args = parser.parse_args()
with open(filepath) as f:
with open(version_filepath) as f:
file_content = f.read()
version = re.search(r'__version__ = "(.*?)"', file_content).group(1)
version = re.search(r'__version__ = "(.+?)"', file_content).group(1)
major, minor, patch = map(int, version.split(sep="."))
if args.level == "patch":
@@ -36,11 +39,12 @@ def main():
new_version = f"{major}.{minor}.{patch}"
with open(filepath, "w") as f:
f.write(re.sub(r'__version__ = "(.*?)"', f'__version__ = "{new_version}"', file_content))
with open(version_filepath, "w") as f:
f.write(re.sub(r'__version__ = "(.+?)"', f'__version__ = "{new_version}"', file_content))
os.system(f"git commit {filepath} -m 'Updating for version {new_version}'")
os.system(f"git commit {version_filepath} -m 'Updating for version {new_version}'")
os.system(f"git tag -a {new_version} -m 'Release {new_version}'")
os.system("git push --follow-tags")
if __name__ == "__main__":

35
pyproject.toml Normal file
View File

@@ -0,0 +1,35 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "pyzebra"
dynamic = ["version"] # version will be read from __init__.py
requires-python = ">=3.8"
dependencies = [
"numpy",
"scipy",
"h5py",
"bokeh ~=2.4",
"numba",
"lmfit >=1.0.2",
]
authors = [
{name = "Paul Scherrer Institute"}
]
maintainers = [
{name = "Ivan Usov", email = "ivan.usov@psi.ch"}
]
description = "An experimental data analysis library for zebra instrument."
readme = "README.md"
license = "GPL-3.0-or-later"
license-files = ["LICENSE"]
[project.urls]
Homepage = "https://gitea.psi.ch/zebra/pyzebra"
[tool.hatch.build.targets.wheel]
include = ["pyzebra"]
[tool.hatch.version]
path = "pyzebra/__init__.py"

View File

@@ -6,4 +6,4 @@ from pyzebra.sxtal_refgen import *
from pyzebra.utils import *
from pyzebra.xtal import *
__version__ = "0.7.10"
__version__ = "0.7.11"

View File

@@ -364,7 +364,7 @@ def create():
_update_proj_plots()
proj_auto_checkbox = CheckboxGroup(
labels=["Projections Intensity Range:"], active=[0], width=145, margin=[10, 5, 0, 5]
labels=["Projections Intensity Range"], active=[0], width=145, margin=[10, 5, 0, 5]
)
proj_auto_checkbox.on_change("active", proj_auto_checkbox_callback)

View File

@@ -689,7 +689,7 @@ def create():
_update_image()
main_auto_checkbox = CheckboxGroup(
labels=["Frame Intensity Range:"], active=[0], width=145, margin=[10, 5, 0, 5]
labels=["Frame Intensity Range"], active=[0], width=145, margin=[10, 5, 0, 5]
)
main_auto_checkbox.on_change("active", main_auto_checkbox_callback)
@@ -721,7 +721,7 @@ def create():
_update_proj_plots()
proj_auto_checkbox = CheckboxGroup(
labels=["Projections Intensity Range:"], active=[0], width=145, margin=[10, 5, 0, 5]
labels=["Projections Intensity Range"], active=[0], width=145, margin=[10, 5, 0, 5]
)
proj_auto_checkbox.on_change("active", proj_auto_checkbox_callback)

View File

@@ -1,11 +0,0 @@
[Unit]
Description=pyzebra-test web server
[Service]
Type=simple
User=pyzebra
ExecStart=/bin/bash /usr/local/sbin/pyzebra-test.sh
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -1,4 +0,0 @@
source /opt/miniconda3/etc/profile.d/conda.sh
conda activate test
python /opt/pyzebra/pyzebra/app/cli.py --port=5010 --allow-websocket-origin=pyzebra.psi.ch:5010 --args --spind-path=/opt/spind

View File

@@ -1,10 +0,0 @@
[Unit]
Description=pyzebra web server
[Service]
Type=simple
ExecStart=/bin/bash /usr/local/sbin/pyzebra.sh
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -1,4 +0,0 @@
source /opt/miniconda3/etc/profile.d/conda.sh
conda activate prod
pyzebra --port=80 --allow-websocket-origin=pyzebra.psi.ch:80 --args --spind-path=/opt/spind

View File

@@ -1,14 +0,0 @@
import re
from setuptools import find_packages, setup
with open("pyzebra/__init__.py") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
setup(
name="pyzebra",
version=version,
description="An experimental data analysis library for zebra instrument.",
packages=find_packages(),
license="GNU GPLv3",
)