Skip to content

Commit

Permalink
chore: astral-sh/uv
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Aug 21, 2024
1 parent 485959c commit 39139cb
Show file tree
Hide file tree
Showing 49 changed files with 927 additions and 1,172 deletions.
40 changes: 17 additions & 23 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,6 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
&& rm -fr sse2neon \
; fi

# poetryを経由して開発に利用するPythonを/usr/localにビルドしてインストールする。
# Python3.10系を使いたいがUbuntu 24.04のパッケージには存在しないので、自前でビルドする必要がある。
RUN curl --fail --show-error --location --output Python.tar.xz https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tar.xz \
&& test "$(md5sum Python.tar.xz)" = "05148354ce821ba7369e5b7958435400 Python.tar.xz" \
&& mkdir -p python \
&& pushd python \
&& tar Jxf ../Python.tar.xz --strip-components=1 \
&& ./configure \
&& make \
&& make install \
&& popd \
&& rm -fr python \
&& ln -s /usr/local/bin/python3 /usr/local/bin/python

RUN /usr/local/bin/pip3 install numpy requests zstandard

# Linux用のbpyはx86_64版だけしかpypiに上がっていないため、それ以外の場合は自前でビルドしてシステムにインストールする。
# https://developer.blender.org/docs/handbook/building_blender/python_module/
# ceresのビルド中にビルドが失敗することがある。失敗した場合はNPROCS=1を付与することで解決した。
Expand All @@ -131,6 +115,20 @@ RUN /usr/local/bin/pip3 install numpy requests zstandard
# make[3]: *** Deleting file 'extern/ceres/CMakeFiles/extern_ceres.dir/internal/ceres/generated/schur_eliminator_2_2_3.cc.o'
# 一般的には `make bpy || make NPROCS=1 bpy` という対応をするが、Parallels Desktop上のUbuntu Arm64 22.04だと
# GUI全体を巻き込んでクラッシュしたのでNPROCS=1で決め打ちする。
RUN if [ "$(uname -m)" != "x86_64" ]; then \
curl --fail --show-error --location --output Python.tar.xz https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tar.xz \
&& test "$(md5sum Python.tar.xz)" = "05148354ce821ba7369e5b7958435400 Python.tar.xz" \
&& mkdir -p python \
&& pushd python \
&& tar Jxf ../Python.tar.xz --strip-components=1 \
&& ./configure \
&& make \
&& make install \
&& popd \
&& rm -fr python \
&& ln -s /usr/local/bin/python3 /usr/local/bin/python \
&& /usr/local/bin/pip3 install numpy requests zstandard \
; fi
RUN if [ "$(uname -m)" != "x86_64" ]; then \
curl --fail --show-error --location --output blender.tar.xz https://download.blender.org/source/blender-3.6.14.tar.xz \
&& test "$(md5sum blender.tar.xz)" = "e78b7af0307584551759e742dd70970f blender.tar.xz" \
Expand All @@ -157,15 +155,11 @@ WORKDIR /home/developer
# できれば "remoteEnv" で設定したいが、現在のJetBrains製品だと反映されないのでここで設定
ENV BLENDER_VRM_LOGGING_LEVEL_DEBUG=yes
ENV BLENDER_VRM_DEVCONTAINER_SPECIAL_WORKAROUNDS=yes
ENV PATH=/home/developer/.local/bin:$PATH
# JetBrains製品はXDGのパスが自動で変更され、Poetry関連パスも影響を受けるためvirtualenvなどが予期せず消えたりする。それを防ぐためにパスを固定。
ENV POETRY_CONFIG_DIR=/home/developer/.config/pypoetry
ENV POETRY_DATA_DIR=/home/developer/.local/share/pypoetry
ENV POETRY_CACHE_DIR=/home/developer/.cache/pypoetry
ENV PATH=/home/developer/.cargo/bin:/home/developer/.local/bin:$PATH
ENV UV_LINK_MODE=copy

# JetBrains製品は自動で `~/.cache` フォルダを作成するが、それだとフォルダの権限がroot:rootになる。
# poetryなどがエラーになるため、あらかじめ作っておく。
RUN mkdir -p .cache

RUN curl --fail --show-error --location https://install.python-poetry.org \
| /usr/local/bin/python3 -
RUN curl --fail --show-error --location https://astral.sh/uv/install.sh | sh
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"-p",
"test_*.py"
],
"python.defaultInterpreterPath": "./.venv-devcontainer/bin/python",
"python.defaultInterpreterPath": "./.venv/bin/python",
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
},
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/extension.patch text eol=lf
go.mod text eol=lf
go.sum text eol=lf
poetry.lock text eol=lf
uv.lock text eol=lf

# 昔はGitHubの "Code" -> "Download ZIP" からダウンロードしたファイルをアドオンとして扱う方式を採用していたが、現在は廃止している。
# しかし、その昔の廃止した方式でダウンロードしてしまい、結果アドオンがうまく動かないという報告が多数あがって来てしまった。
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ jobs:
run: |
git ls-files "*.glsl" | xargs clang-format -i
git diff --exit-code
- name: Install poetry
- name: Install UV
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install poetry dependencies
curl --fail --show-error --location https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Install UV dependencies
run: |
for _ in $(seq 5); do
if poetry install; then
if uv run python -c 'print("OK")'; then
break
fi
done
Expand All @@ -209,7 +209,7 @@ jobs:
git diff --exit-code
- name: Check property type annotations
run: |
poetry run python tools/property_typing.py > property_typing.log
uv run python tools/property_typing.py > property_typing.log
./tools/format.sh
git diff --exit-code
- name: Install hadolint
Expand All @@ -223,7 +223,7 @@ jobs:
./tools/format.sh
git diff --exit-code
./tools/lint.sh
poetry -C src run python -c "import io_scene_vrm; io_scene_vrm.register(); io_scene_vrm.unregister()"
uv run python -c "import io_scene_vrm; io_scene_vrm.register(); io_scene_vrm.unregister()"
git reset --hard "$GITHUB_SHA"
- name: Super-Linter
uses: github/super-linter@v6
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
!/src/io_scene_vrm/README.txt
!/src/io_scene_vrm/blender_manifest.toml
!/src/io_scene_vrm/editor/vroid2vrc_lipsync_recipe.json
!/poetry.lock
!/pyproject.toml
!/tools/*.bat
!/tools/*.dockerfile
!/tools/*.sh
!/tools/*.wsb
!/tests/resources
!/typings/pyproject.toml
!/uv.lock

*.blend1
*~
Expand All @@ -52,7 +52,6 @@ __pycache__/

/.idea/
/.venv/
/.venv-devcontainer/
/.vscode/
/docs/website/.hugo_build.lock
/docs/website/public/
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ English / [日本語](#ja_JP) ]

# VRM Add-on for Blender <a href="https://github.com/saturday06/VRM-Addon-for-Blender/actions"><img alt="CI status" src="https://github.com/saturday06/VRM-Addon-for-Blender/actions/workflows/test.yml/badge.svg?branch=main"></a> [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
# VRM Add-on for Blender <a href="https://github.com/saturday06/VRM-Addon-for-Blender/actions"><img alt="CI status" src="https://github.com/saturday06/VRM-Addon-for-Blender/actions/workflows/test.yml/badge.svg?branch=main"></a> [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

VRM Add-on for Blender is an add-on to add VRM-related functions into Blender.

Expand All @@ -29,7 +29,7 @@ This add-on adds VRM-related functions to Blender, such as importing and exporti

The source code for development is in the <a href="https://github.com/saturday06/VRM-Addon-for-Blender/tree/main">`main`</a> branch. Its <a href="https://github.com/saturday06/VRM-Addon-for-Blender/tree/main/src/io_scene_vrm">`src/io_scene_vrm`</a> folder is a main body of the add-on. For efficient development, you can create a link to that folder in the Blender `addons` folder.

For more advanced development, such as running tests, please use [Poetry](https://python-poetry.org/).
For more advanced development, such as running tests, please use [astral.sh/uv](https://docs.astral.sh/uv/).

```text
git checkout main
Expand Down Expand Up @@ -92,7 +92,7 @@ BlenderにVRMのインポートやエクスポート、VRM Humanoidの追加やM
開発用のソースコードは<a href="https://github.com/saturday06/VRM-Addon-for-Blender/tree/main">`main`</a>ブランチにあります。ブランチ内の <a href="https://github.com/saturday06/VRM-Addon-for-Blender/tree/main/src/io_scene_vrm">`src/io_scene_vrm`</a> フォルダがアドオン本体です。
そのフォルダへのリンクをBlenderの `addons` フォルダ内に作ることで効率的に開発をすることができます。

テストの実行など、より高度な開発をする場合は[Poetry](https://python-poetry.org/)をご利用ください。
テストの実行など、より高度な開発をする場合は[astral.sh/uv](https://docs.astral.sh/uv/)をご利用ください。

```text
git checkout main
Expand Down
Loading

0 comments on commit 39139cb

Please sign in to comment.