Skip to content

Commit

Permalink
move tomlkit install to build script (#639)
Browse files Browse the repository at this point in the history
* move tomlkit install to build script

* improve run_python
  • Loading branch information
BradyAJohnston authored Oct 22, 2024
1 parent b4b9915 commit be51a5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
echo "${{ github.workspace }}/${{ env.BLENDER_VERSION }}/" >> $GITHUB_PATH
- name: Build extension
run: |
blender -b -P tests/python.py -- -m pip install tomlkit
blender -b -P build.py
mkdir artifact
mv ${{ env.ADDON_NAME }}-${{ steps.read_manifest.outputs.value }}-*.zip ./artifact/.
Expand Down
28 changes: 22 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,28 @@
from typing import List, Union
import bpy

import tomlkit

def run_python(args: str | List[str]):
python = os.path.realpath(sys.executable)

if isinstance(args, str):
args = [python] + args.split(" ")
elif isinstance(args, list):
args = [python] + args
else:
raise ValueError(
"Arguments must be a string to split into individual arguments by space"
"or a list of individual arguments already split"
)

subprocess.run(args)


try:
import tomlkit
except ModuleNotFoundError:
run_python("-m pip install tomlkit")
import tomlkit

toml_path = "molecularnodes/blender_manifest.toml"
whl_path = "./molecularnodes/wheels"
Expand Down Expand Up @@ -44,11 +65,6 @@ class Platform:
]


def run_python(args: str):
python = os.path.realpath(sys.executable)
subprocess.run([python] + args.split(" "))


def remove_whls():
for whl_file in glob.glob(os.path.join(whl_path, "*.whl")):
os.remove(whl_file)
Expand Down

0 comments on commit be51a5a

Please sign in to comment.