Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 457a974e14 | |||
| ec685d24eb | |||
| 57c0037289 | |||
| 58ef47468e | |||
| 583526e219 | |||
| 108c1aae2f | |||
| b82184b9e7 | |||
| b6a43c3f3b | |||
| 18b692a62e | |||
| c2d6f6b259 | |||
| 60b90ec9e5 | |||
| 1fc30ae3e1 | |||
| dfa6bfe926 | |||
| ed3f58436b | |||
| 68f7b429f7 | |||
| e5030902c7 | |||
| 60f01d9dd8 | |||
| bd429393a5 | |||
| 9e3ffd6230 | |||
| bdc71f15c1 | |||
| c3398ef4e5 | |||
| 9b33f1152b | |||
| dc1f2a92cc | |||
| e9ae52bb60 | |||
| 982887ab85 | |||
| 19e934e873 | |||
| 8604d695c6 | |||
| a55295829f | |||
| 4181d597a8 | |||
| c4869fb0cd |
45
.gitea/workflows/deploy.yaml
Normal file
45
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: pyzebra CI/CD pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
CONDA: /opt/miniforge3
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-env:
|
||||||
|
runs-on: pyzebra
|
||||||
|
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
|
||||||
|
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
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
stages:
|
|
||||||
- build-and-publish
|
|
||||||
- deploy
|
|
||||||
|
|
||||||
build-and-publish:
|
|
||||||
stage: build-and-publish
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- source /opt/miniconda3/etc/profile.d/conda.sh
|
|
||||||
- conda config --add channels conda-forge
|
|
||||||
- conda config --set solver libmamba
|
|
||||||
- conda config --set anaconda_upload yes
|
|
||||||
- conda build --token $ANACONDA_TOKEN /opt/pyzebra/conda-recipe
|
|
||||||
|
|
||||||
deploy-test:
|
|
||||||
stage: deploy
|
|
||||||
environment: testing
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
||||||
script:
|
|
||||||
- cd /opt/pyzebra
|
|
||||||
- git pull origin main --tags
|
|
||||||
- source /opt/miniconda3/etc/profile.d/conda.sh
|
|
||||||
- conda activate test
|
|
||||||
- conda build ./conda-recipe
|
|
||||||
- conda install --use-local --only-deps pyzebra -y
|
|
||||||
- conda build purge-all
|
|
||||||
- sudo systemctl restart pyzebra-test.service
|
|
||||||
|
|
||||||
deploy-prod:
|
|
||||||
stage: deploy
|
|
||||||
environment: production
|
|
||||||
needs: ["build-and-publish"]
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
when: delayed
|
|
||||||
start_in: 5 seconds
|
|
||||||
script:
|
|
||||||
- source /opt/miniconda3/etc/profile.d/conda.sh
|
|
||||||
- conda activate prod
|
|
||||||
- conda update pyzebra -y
|
|
||||||
- sudo systemctl restart pyzebra-prod.service
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
|
|
||||||
if errorlevel 1 exit 1
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
|
|
||||||
@@ -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:
|
package:
|
||||||
name: pyzebra
|
name: {{ pyproject['project']['name'] }}
|
||||||
version: {{ data['version'] }}
|
version: {{ version }}
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: ..
|
path: ..
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
script: python -m pip install .
|
||||||
noarch: python
|
noarch: python
|
||||||
number: 0
|
|
||||||
entry_points:
|
entry_points:
|
||||||
- pyzebra = pyzebra.app.cli:main
|
- pyzebra = pyzebra.app.cli:main
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
build:
|
host:
|
||||||
- python >=3.8
|
- python >=3.8
|
||||||
- setuptools
|
- hatchling
|
||||||
run:
|
run:
|
||||||
- python >=3.8
|
- python >=3.8
|
||||||
- numpy
|
{% for dep in pyproject['project']['dependencies'] %}
|
||||||
- scipy
|
- {{ dep }}
|
||||||
- h5py
|
{% endfor %}
|
||||||
- bokeh =2.4
|
|
||||||
- numba
|
|
||||||
- lmfit >=1.0.2
|
|
||||||
|
|
||||||
|
|
||||||
about:
|
about:
|
||||||
home: https://github.com/paulscherrerinstitute/pyzebra
|
home: {{ pyproject['project']['urls']['Homepage'] }}
|
||||||
summary: {{ data['description'] }}
|
summary: {{ pyproject['project']['description'] }}
|
||||||
license: GNU GPLv3
|
license: {{ pyproject['project']['license'] }}
|
||||||
license_file: LICENSE
|
license_file:
|
||||||
|
{% for lf in pyproject['project']['license-files'] %}
|
||||||
|
- {{ lf }}
|
||||||
|
{% endfor %}
|
||||||
|
|||||||
@@ -4,24 +4,27 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
default_branch = "main"
|
||||||
branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode().strip()
|
branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode().strip()
|
||||||
if branch != "main":
|
if branch != default_branch:
|
||||||
print("Aborting, not on 'main' branch.")
|
print(f"Aborting, not on '{default_branch}' branch.")
|
||||||
return
|
return
|
||||||
|
|
||||||
filepath = "pyzebra/__init__.py"
|
project_path = Path(__file__).resolve().parent
|
||||||
|
version_filepath = project_path / project_path.name / "__init__.py"
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("level", type=str, choices=["patch", "minor", "major"])
|
parser.add_argument("level", type=str, choices=["patch", "minor", "major"])
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
with open(filepath) as f:
|
with open(version_filepath) as f:
|
||||||
file_content = f.read()
|
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="."))
|
major, minor, patch = map(int, version.split(sep="."))
|
||||||
|
|
||||||
if args.level == "patch":
|
if args.level == "patch":
|
||||||
@@ -36,11 +39,12 @@ def main():
|
|||||||
|
|
||||||
new_version = f"{major}.{minor}.{patch}"
|
new_version = f"{major}.{minor}.{patch}"
|
||||||
|
|
||||||
with open(filepath, "w") as f:
|
with open(version_filepath, "w") as f:
|
||||||
f.write(re.sub(r'__version__ = "(.*?)"', f'__version__ = "{new_version}"', file_content))
|
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(f"git tag -a {new_version} -m 'Release {new_version}'")
|
||||||
|
os.system("git push --follow-tags")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
35
pyproject.toml
Normal file
35
pyproject.toml
Normal 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"
|
||||||
@@ -6,4 +6,4 @@ from pyzebra.sxtal_refgen import *
|
|||||||
from pyzebra.utils import *
|
from pyzebra.utils import *
|
||||||
from pyzebra.xtal import *
|
from pyzebra.xtal import *
|
||||||
|
|
||||||
__version__ = "0.7.9"
|
__version__ = "0.7.11"
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
14
setup.py
14
setup.py
@@ -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",
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user