From 1da300049b2dc76a0cf1964f2ad16be6ccfa894b Mon Sep 17 00:00:00 2001 From: ebner Date: Tue, 1 Jul 2025 16:19:26 +0200 Subject: [PATCH] initial commit --- .github/workflows/build.yml | 35 +++++++++++++++ .gitignore | 4 ++ Readme.md | 89 +++++++++++++++++++++++++++++++++++++ pyenv.sh | 6 +++ pyenv.spec | 38 ++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 Readme.md create mode 100644 pyenv.sh create mode 100644 pyenv.spec diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..31b51c9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: Build and Publish RPM +name: Build and Publish RPM + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +jobs: + build-and-publish: + runs-on: "ubuntu-latest-intranet" + container: + image: gitea.psi.ch/images/rhel9-developer-gitea-actions + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build RPM + run: | + rpmbuild -ba hdfview.spec + + - name: Publish RPM package + run: | + echo curl -X PUT \ + --user "ebner:${{ secrets.PACKAGE_DEPLOY_TOKEN }}" \ + --upload-file RPMS/x86_64/*.rpm \ + "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/rpm/upload" + curl -X PUT \ + --user "ebner:${{ secrets.PACKAGE_DEPLOY_TOKEN }}" \ + --upload-file RPMS/x86_64/*.rpm \ + "${{ github.server_url }}/api/packages/${{ github.repository_owner }}/rpm/upload" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f9774b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +BUILD +BUILDROOT +RPMS +SRPMS diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..bbcb667 --- /dev/null +++ b/Readme.md @@ -0,0 +1,89 @@ +# Overview + +https://github.com/pyenv/pyenv + +Ideas for RPM packaging: +https://github.com/niligulmohar/pyenv-rpm + +# Development + +``` +docker run --platform linux/amd64 -it --rm -v $(pwd):/data --workdir /data gitea.psi.ch/images/rhel9-developer + +rpmbuild -ba pyenv.spec +``` + + +# Installation +https://github.com/pyenv/pyenv + +Installing pyenv dependencies (https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with-framework-support-on-os-x): + +```bash +dnf install gcc make patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel +``` + +Install/clone pyenv: +```bash + +[root@lxdev04 ~]# mkdir /opt/pyenv + +[root@lxdev04 ~]# git clone https://github.com/pyenv/pyenv.git /opt/pyenv +Cloning into '/opt/pyenv'... +remote: Enumerating objects: 24035, done. +remote: Counting objects: 100% (100/100), done. +remote: Compressing objects: 100% (44/44), done. +remote: Total 24035 (delta 42), reused 89 (delta 38), pack-reused 23935 +Receiving objects: 100% (24035/24035), 4.91 MiB | 23.30 MiB/s, done. +Resolving deltas: 100% (16199/16199), done. + +[root@lxdev04 ~]# ln -s /opt/pyenv/bin/pyenv /usr/bin/pyenv +``` + +Create profile script: +```bash +[root@lxdev04 bin]# cat /etc/profile.d/pyenv.sh +if [[ ${UID} -ge 1000 && ! ${USER} =~ -adm$ ]]; then + export PYENV_ROOT="$HOME/.pyenv" + # export PYENV_ROOT="/tmp/$USER/.pyenv" + [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" +fi +``` + +Installation virtualenv plugin (https://github.com/pyenv/pyenv-virtualenv): +```bash +git clone https://github.com/pyenv/pyenv-virtualenv.git /opt/pyenv/plugins/pyenv-virtualenv +``` + +Use pyenv: +```bash +# show installed versions +pyenv versions +# show current python version +pyenv version +# show possible python versions to install +pyenv install --list +# install a python version +pyenv install + +# activate python version for current shell: +pyenv shell + +# uninstall python version +pyenv uninstall + +# create a python environment +pyenv virtualenv + +# activate virtual environment in current shell +pyenv shell + +# remove virtualenv +pyenv virtualenv-delete +``` + + +*INFO: Somehow `pyenv local` does not work (i.e. switching python version based on directory!)* + +Tutorial: https://realpython.com/intro-to-pyenv diff --git a/pyenv.sh b/pyenv.sh new file mode 100644 index 0000000..840e471 --- /dev/null +++ b/pyenv.sh @@ -0,0 +1,6 @@ +if [[ ${UID} -ge 1000 && ! ${USER} =~ -adm$ ]]; then + export PYENV_ROOT="$HOME/.pyenv" + # export PYENV_ROOT="/tmp/$USER/.pyenv" + [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" +fi \ No newline at end of file diff --git a/pyenv.spec b/pyenv.spec new file mode 100644 index 0000000..645480c --- /dev/null +++ b/pyenv.spec @@ -0,0 +1,38 @@ +Summary: pyenv +Name: pyenv +Version: 2.6.3 +Release: 1%{?dist} +License: MIT +Group: Applications/System +BuildArch: noarch +Vendor: PSI +URL: https://github.com/pyenv/pyenv + +Requires: gcc, make, patch, zlib-devel, bzip2, bzip2-devel, readline-devel, sqlite, sqlite-devel, openssl-devel, tk-devel, libffi-devel, xz-devel + +%description +Provides pyenv + +# do not mangle shebangs +%global __brp_mangle_shebangs %{nil} + +%install +mkdir -p %{buildroot}/opt/pyenv +mkdir -p %{buildroot}/etc/profile.d/ +git clone --depth 1 --branch v2.6.3 https://github.com/pyenv/pyenv %{buildroot}/opt/pyenv +git clone --depth 1 --branch v1.2.4 https://github.com/pyenv/pyenv-virtualenv.git %{buildroot}/opt/pyenv/plugins/pyenv-virtualenv +rm -rf %{buildroot}/opt/pyenv/.git +rm -rf %{buildroot}/opt/pyenv/.github +rm -rf %{buildroot}/opt/pyenv/test +rm -rf %{buildroot}/opt/pyenv/src +rm -rf %{buildroot}/opt/pyenv/plugins/pyenv-virtualenv/.git +cp %{_topdir}/pyenv.sh %{buildroot}/etc/profile.d/pyenv.sh +mkdir -p %{buildroot}/usr/bin +ln -s /opt/pyenv/bin/pyenv %{buildroot}/usr/bin/pyenv + +%files +# %defattr(-,root,root,0755) +/opt/pyenv +/etc/profile.d/pyenv.sh +/usr/bin/pyenv +