release: 0.0.1
This commit is contained in:
parent
5f58d7fb56
commit
f5a68d936c
50
README.md
50
README.md
|
|
@ -100,6 +100,56 @@ pip install pandas numpy scipy scikit-learn matplotlib seaborn openpyxl xlrd
|
||||||
pip install black autopep8 basedpyright
|
pip install black autopep8 basedpyright
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 1.6 打包 Qfunctions + Qtorch 为 Conda 包
|
||||||
|
|
||||||
|
项目已提供可直接构建的打包文件:
|
||||||
|
|
||||||
|
- `pyproject.toml`
|
||||||
|
- `conda_env/recipe/meta.yaml`
|
||||||
|
|
||||||
|
构建步骤:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate Deeplearning
|
||||||
|
conda install -n Deeplearning -y conda-build anaconda-client
|
||||||
|
cd /home/newbie/Project/MachineLearning/Deeplearning
|
||||||
|
conda-build conda_env/recipe
|
||||||
|
```
|
||||||
|
|
||||||
|
本地安装(从本机 conda-bld):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate Deeplearning
|
||||||
|
conda install -n Deeplearning -y -c local deeplearning-qtools
|
||||||
|
```
|
||||||
|
|
||||||
|
安装后即可使用:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -c "import Qfunctions, Qtorch; print('ok')"
|
||||||
|
```
|
||||||
|
|
||||||
|
发布到 Anaconda.org 后,其他项目(如 GestureRecognition)可直接安装:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda install -c <your-channel> deeplearning-qtools
|
||||||
|
```
|
||||||
|
|
||||||
|
一键发布到 Gitea(自动构建 + 打 tag + push + 可选创建 Release):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/newbie/Project/MachineLearning/Deeplearning
|
||||||
|
chmod +x Scripts/publish_to_gitea.sh
|
||||||
|
./Scripts/publish_to_gitea.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
如果希望脚本自动在 Gitea 创建 Release 并上传 conda 包,请先设置:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export GITEA_TOKEN=<your_gitea_token>
|
||||||
|
./Scripts/publish_to_gitea.sh
|
||||||
|
```
|
||||||
|
|
||||||
## 2. 项目约定
|
## 2. 项目约定
|
||||||
|
|
||||||
### 2.1 输入数据格式
|
### 2.1 输入数据格式
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# One-command publish flow:
|
||||||
|
# 1) Build conda package
|
||||||
|
# 2) Commit current changes (if any)
|
||||||
|
# 3) Tag as v<version>
|
||||||
|
# 4) Push branch + tag to origin (your Gitea remote)
|
||||||
|
# 5) Optionally create Gitea Release and upload built package when GITEA_TOKEN is set
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
|
||||||
|
if ! command -v python >/dev/null 2>&1; then
|
||||||
|
echo "python not found in PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v conda >/dev/null 2>&1; then
|
||||||
|
echo "conda not found in PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v conda-build >/dev/null 2>&1; then
|
||||||
|
echo "conda-build is not installed in current environment."
|
||||||
|
echo "Run: conda install -n Deeplearning -y conda-build"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION="$(python - <<'PY'
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
|
text = pathlib.Path('pyproject.toml').read_text(encoding='utf-8')
|
||||||
|
m = re.search(r'^version\s*=\s*"([^"]+)"', text, flags=re.M)
|
||||||
|
if not m:
|
||||||
|
raise SystemExit('Could not read version from pyproject.toml')
|
||||||
|
print(m.group(1))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
TAG="v${VERSION}"
|
||||||
|
|
||||||
|
echo "Building conda package for version: ${VERSION}"
|
||||||
|
PKG_PATH="$(conda-build conda_env/recipe --output)"
|
||||||
|
conda-build conda_env/recipe
|
||||||
|
|
||||||
|
if git diff --quiet && git diff --cached --quiet; then
|
||||||
|
echo "No local file changes to commit."
|
||||||
|
else
|
||||||
|
git add pyproject.toml conda_env/recipe/meta.yaml conda_env/recipe/README.md Scripts/publish_to_gitea.sh README.md
|
||||||
|
git commit -m "release: ${VERSION}" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if git rev-parse "${TAG}" >/dev/null 2>&1; then
|
||||||
|
echo "Tag ${TAG} already exists locally."
|
||||||
|
else
|
||||||
|
git tag -a "${TAG}" -m "Release ${TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Pushing current branch and tag to origin"
|
||||||
|
git push origin HEAD
|
||||||
|
git push origin "${TAG}"
|
||||||
|
|
||||||
|
echo "Pushed to origin."
|
||||||
|
|
||||||
|
if [[ -z "${GITEA_TOKEN:-}" ]]; then
|
||||||
|
echo "GITEA_TOKEN not set. Skip creating Gitea Release."
|
||||||
|
echo "Built package: ${PKG_PATH}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ORIGIN_URL="$(git remote get-url origin)"
|
||||||
|
|
||||||
|
parse_owner_repo() {
|
||||||
|
local url="$1"
|
||||||
|
if [[ "$url" =~ ^git@([^:]+):(.+)\.git$ ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}|${BASH_REMATCH[2]}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$url" =~ ^https?://([^/]+)/(.+)\.git$ ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}|${BASH_REMATCH[2]}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
PARSED="$(parse_owner_repo "$ORIGIN_URL")"
|
||||||
|
if [[ -z "$PARSED" ]]; then
|
||||||
|
echo "Cannot parse origin URL: $ORIGIN_URL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
GITEA_HOST="${PARSED%%|*}"
|
||||||
|
OWNER_REPO="${PARSED#*|}"
|
||||||
|
API_BASE="https://${GITEA_HOST}/api/v1/repos/${OWNER_REPO}"
|
||||||
|
|
||||||
|
echo "Creating or updating Gitea release ${TAG} on ${OWNER_REPO}"
|
||||||
|
|
||||||
|
RELEASE_JSON="$(curl -sS -X POST "${API_BASE}/releases" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" || true)"
|
||||||
|
|
||||||
|
RELEASE_ID="$(printf '%s' "$RELEASE_JSON" | python - <<'PY'
|
||||||
|
import json,sys
|
||||||
|
text=sys.stdin.read().strip()
|
||||||
|
if not text:
|
||||||
|
print('')
|
||||||
|
raise SystemExit
|
||||||
|
try:
|
||||||
|
obj=json.loads(text)
|
||||||
|
except Exception:
|
||||||
|
print('')
|
||||||
|
raise SystemExit
|
||||||
|
print(obj.get('id',''))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [[ -z "$RELEASE_ID" ]]; then
|
||||||
|
RELEASE_ID="$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" "${API_BASE}/releases/tags/${TAG}" | python - <<'PY'
|
||||||
|
import json,sys
|
||||||
|
text=sys.stdin.read().strip()
|
||||||
|
try:
|
||||||
|
obj=json.loads(text)
|
||||||
|
except Exception:
|
||||||
|
print('')
|
||||||
|
raise SystemExit
|
||||||
|
print(obj.get('id',''))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$RELEASE_ID" ]]; then
|
||||||
|
echo "Failed to get release id for tag ${TAG}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PKG_FILE="$(basename "$PKG_PATH")"
|
||||||
|
echo "Uploading asset ${PKG_FILE}"
|
||||||
|
curl -sS -X POST "${API_BASE}/releases/${RELEASE_ID}/assets?name=${PKG_FILE}" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary "@${PKG_PATH}" >/dev/null
|
||||||
|
|
||||||
|
echo "Release published: ${TAG}"
|
||||||
|
echo "Asset uploaded: ${PKG_FILE}"
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Build and install Deeplearning conda package
|
||||||
|
|
||||||
|
This recipe packages both `Qfunctions` and `Qtorch` into one conda package:
|
||||||
|
|
||||||
|
- Package name: `deeplearning-qtools`
|
||||||
|
- Import names after install: `Qfunctions`, `Qtorch`
|
||||||
|
|
||||||
|
## 1) Build package
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate Deeplearning
|
||||||
|
conda install -n Deeplearning -y conda-build anaconda-client
|
||||||
|
cd /home/newbie/Project/MachineLearning/Deeplearning
|
||||||
|
conda-build conda_env/recipe
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2) Install from local build output
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda activate Deeplearning
|
||||||
|
conda install -n Deeplearning -y -c local deeplearning-qtools
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3) Verify imports
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -c "import Qfunctions, Qtorch; print('ok')"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4) Upload to Anaconda.org (optional)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Login once
|
||||||
|
anaconda login
|
||||||
|
|
||||||
|
# Upload generated package (linux-64/noarch path depends on build output)
|
||||||
|
anaconda upload /home/<USER>/miniconda3/conda-bld/noarch/deeplearning-qtools-0.0.1-py_0.conda
|
||||||
|
```
|
||||||
|
|
||||||
|
After upload, others can install with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda install -c <your-channel> deeplearning-qtools
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
{% set name = "deeplearning-qtools" %}
|
||||||
|
{% set version = "0.0.1" %}
|
||||||
|
|
||||||
|
package:
|
||||||
|
name: {{ name|lower }}
|
||||||
|
version: {{ version }}
|
||||||
|
|
||||||
|
source:
|
||||||
|
path: ../..
|
||||||
|
|
||||||
|
build:
|
||||||
|
noarch: python
|
||||||
|
number: 0
|
||||||
|
script: "{{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vv"
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
host:
|
||||||
|
- python >=3.10
|
||||||
|
- pip
|
||||||
|
- setuptools >=68
|
||||||
|
- wheel
|
||||||
|
run:
|
||||||
|
- python >=3.10
|
||||||
|
- numpy >=1.24
|
||||||
|
- pandas >=2.0
|
||||||
|
- matplotlib >=3.7
|
||||||
|
- scikit-learn >=1.3
|
||||||
|
- openpyxl >=3.1
|
||||||
|
- pytorch >=2.0
|
||||||
|
|
||||||
|
test:
|
||||||
|
imports:
|
||||||
|
- Qfunctions
|
||||||
|
- Qtorch
|
||||||
|
|
||||||
|
about:
|
||||||
|
summary: Reusable Qfunctions and Qtorch modules from Deeplearning
|
||||||
|
license: Proprietary
|
||||||
|
|
||||||
|
extra:
|
||||||
|
recipe-maintainers:
|
||||||
|
- deeplearning-team
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=68", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "deeplearning-qtools"
|
||||||
|
version = "0.0.1"
|
||||||
|
description = "Reusable Qfunctions and Qtorch modules from Deeplearning"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.10"
|
||||||
|
authors = [{ name = "Deeplearning Team" }]
|
||||||
|
dependencies = [
|
||||||
|
"numpy>=1.24",
|
||||||
|
"pandas>=2.0",
|
||||||
|
"matplotlib>=3.7",
|
||||||
|
"scikit-learn>=1.3",
|
||||||
|
"openpyxl>=3.1",
|
||||||
|
"torch>=2.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
include-package-data = true
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["Qfunctions*", "Qtorch*"]
|
||||||
|
exclude = ["Result*", "Static*", "Scripts*", "conda_env*"]
|
||||||
Loading…
Reference in New Issue