From 8e1545b2bc81cb6f2a9d81a5fdad6e80d713613b Mon Sep 17 00:00:00 2001 From: dirac6582 <38810216+dirac6582@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:43:12 +0900 Subject: [PATCH 1/2] ci: align autorelease with cellify --- .github/workflows/autorelease.yml | 34 ++++++++++++++----------------- AGENTS.md | 4 ++-- src/VisualizePhonon/__init__.py | 2 +- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml index d08a79a..6c129a3 100644 --- a/.github/workflows/autorelease.yml +++ b/.github/workflows/autorelease.yml @@ -14,30 +14,26 @@ jobs: name: Check version and create release runs-on: ubuntu-latest outputs: - tag_exists: ${{ steps.check_tag.outputs.exists }} + release_created: ${{ steps.check_tag.outputs.exists }} steps: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" + fetch-depth: 0 # Fetch all history and tags - name: Get current version id: get_version run: | - VERSION=$(python - <<'PY' - import tomllib - - with open("pyproject.toml", "rb") as f: - print(tomllib.load(f)["project"]["version"]) - PY + VERSION=$(python -c " + with open('src/VisualizePhonon/__init__.py') as f: + for line in f: + if '__version__' in line: + print(line.split('=')[1].strip().strip('\"\'')) + break + " ) - echo "VERSION=$VERSION" >> "$GITHUB_ENV" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Check if tag exists id: check_tag @@ -45,10 +41,10 @@ jobs: TAG_NAME="v${{ env.VERSION }}" if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then echo "Tag $TAG_NAME already exists. Skipping release." - echo "exists=true" >> "$GITHUB_OUTPUT" + echo "exists=true" >> $GITHUB_OUTPUT else echo "Tag $TAG_NAME does not exist. A new release will be created." - echo "exists=false" >> "$GITHUB_OUTPUT" + echo "exists=false" >> $GITHUB_OUTPUT fi - name: Create GitHub Release @@ -65,7 +61,7 @@ jobs: publish: name: Build & Publish to PyPI needs: autorelease - if: needs.autorelease.outputs.tag_exists == 'false' + if: needs.autorelease.outputs.release_created == 'false' runs-on: ubuntu-latest environment: name: pypi @@ -77,7 +73,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.10" - name: Install build dependencies run: pip install build diff --git a/AGENTS.md b/AGENTS.md index 3c13941..f64ebb8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -83,8 +83,8 @@ vaspvis generate -i test/OUTCAR -f xsf -m 0 -s 1 - codeは`ase`に依存します。parser/exporterやCIを触る場合は、`pyproject.toml`の dependencyとworkflowのinstall手順を同期させてください。 -- `pyproject.toml`のversionは`0.0.2`、`src/VisualizePhonon/__init__.py`の - `__version__`は`0.1.0`で不一致です。 +- autorelease workflowは`cellify`と同じく`src/VisualizePhonon/__init__.py`の + `__version__`を読み、対応する`v` tagがない場合にreleaseします。 - `cmdline.py`の`--scale`は`float`です。README例のように`1.0`を受け取れます。 - `vibrational_analysis.py`と`vibrational_analysis_io.py`の両方にXSF writer logic があります。出力形式を変える場合は挙動をそろえてください。 diff --git a/src/VisualizePhonon/__init__.py b/src/VisualizePhonon/__init__.py index f79aad6..0e917a8 100644 --- a/src/VisualizePhonon/__init__.py +++ b/src/VisualizePhonon/__init__.py @@ -10,7 +10,7 @@ - Export vibration modes to VESTA format """ -__version__ = "0.1.0" +__version__ = "0.0.2" from VisualizePhonon.vibrational_analysis import VibrationalMode, VibrationAnalysis __all__ = ["VibrationalMode", "VibrationAnalysis"] From 5e16c40c7011a9f501fd04f0e6fa3e2a44648d6a Mon Sep 17 00:00:00 2001 From: dirac6582 <38810216+dirac6582@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:51:29 +0900 Subject: [PATCH 2/2] build: derive version from package metadata --- AGENTS.md | 11 +++++++---- pyproject.toml | 20 +++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f64ebb8..212257a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,8 +36,10 @@ CLIで指定できる出力形式は`xsf`、`xyz`、`asy`です。 LaTeX出力を作る例。 - `mode_*`ファイルの多くは可視化の生成物です。明示的にexample出力の更新を 求められていない限り、sourceではなく生成物として扱ってください。 -- `pyproject.toml`: package metadata、console script、pytest設定、Black/isort設定。 -- `setup.py`: 最小限のsetuptools shim。 +- `pyproject.toml`: package metadata、hatchling build設定、console script、 + pytest設定、Black/isort設定。 +- `setup.py`: legacyの最小shim。通常のbuild/installは`pyproject.toml`の + hatchling設定を使います。 - `README.md`: install方法、CLI usage、citation、関連ツール。 ## 主要データフロー @@ -83,8 +85,9 @@ vaspvis generate -i test/OUTCAR -f xsf -m 0 -s 1 - codeは`ase`に依存します。parser/exporterやCIを触る場合は、`pyproject.toml`の dependencyとworkflowのinstall手順を同期させてください。 -- autorelease workflowは`cellify`と同じく`src/VisualizePhonon/__init__.py`の - `__version__`を読み、対応する`v` tagがない場合にreleaseします。 +- versionは`cellify`と同じく`src/VisualizePhonon/__init__.py`の`__version__`を + source of truthにしています。`pyproject.toml`はhatchling dynamic versionで + 同じ値を読み、autorelease workflowも対応する`v` tagを確認します。 - `cmdline.py`の`--scale`は`float`です。README例のように`1.0`を受け取れます。 - `vibrational_analysis.py`と`vibrational_analysis_io.py`の両方にXSF writer logic があります。出力形式を変える場合は挙動をそろえてください。 diff --git a/pyproject.toml b/pyproject.toml index e79af1c..8589ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=42", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "VisualizePhonon" -version = "0.0.2" +dynamic = ["version"] description = "A tool for analyzing vibrational modes from VASP OUTCAR files" readme = "README.md" authors = [ @@ -38,14 +38,6 @@ vesta = [ "pymatgen>=2022.0.0", ] -[tool.setuptools] -package-dir = {"" = "src"} -# packages = [""] -license-files = [] - -# [tool.setuptools.packages.find] -# where = ["src"] - [tool.pytest.ini_options] testpaths = ["test"] python_files = "test_*.py" @@ -60,3 +52,9 @@ line_length = 88 [project.scripts] vaspvis = "VisualizePhonon.cmdline:main" + +[tool.hatch.build.targets.wheel] +packages = ["src/VisualizePhonon"] + +[tool.hatch.version] +path = "src/VisualizePhonon/__init__.py"