Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Extensions Platform #500

Merged
merged 52 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
62b8300
split apart attribute selection node
BradyAJohnston Feb 27, 2024
bff3419
update nodes
BradyAJohnston Feb 28, 2024
e7aafd2
update attribute selection nodes
BradyAJohnston Mar 5, 2024
348196a
rename node names to remove underscores
BradyAJohnston Mar 6, 2024
8fcc403
rename node names to remove underscores
BradyAJohnston Mar 6, 2024
9e2e085
fixing some labels
BradyAJohnston Mar 7, 2024
3c1f4fb
Merge branch 'main' into node-attributes
BradyAJohnston Apr 2, 2024
2d4bd80
updating to 4.1 and cleaning up nodes
BradyAJohnston Apr 2, 2024
1561bf4
add toml and whl building
BradyAJohnston May 8, 2024
7755b04
other packages working
BradyAJohnston May 9, 2024
a768340
update tags
BradyAJohnston May 10, 2024
b7e2daf
fix for building on windows machines
BradyAJohnston May 13, 2024
723a910
tweak
BradyAJohnston May 16, 2024
f619cfa
tweak
BradyAJohnston May 16, 2024
99be925
tweak
BradyAJohnston May 16, 2024
f834c00
bump version
BradyAJohnston Jun 5, 2024
4f44ea7
tweak and add running of tests (which currently fail)
BradyAJohnston May 28, 2024
4a45af2
Merge branch 'main' into node-attributes
BradyAJohnston Jun 10, 2024
02ee41e
updating
BradyAJohnston Jun 10, 2024
9fe054d
update most node names
BradyAJohnston Jun 10, 2024
6579615
Fix formatting of names and assembly node
BradyAJohnston Jun 10, 2024
838ce73
Merge branch '4.2' into node-attributes
BradyAJohnston Jun 10, 2024
aaa08b8
change color on Set Color node
BradyAJohnston Jun 10, 2024
2503c40
some docs
BradyAJohnston Jun 10, 2024
916ab9f
formatting
BradyAJohnston Jun 10, 2024
ee3d4cc
fix typo in MDA Universe loading
BradyAJohnston Jun 11, 2024
363bd1d
add test that would previous fail
BradyAJohnston Jun 11, 2024
da09aa0
update snapshot
BradyAJohnston Jun 11, 2024
9f6fb58
Merge pull request #523 from BradyAJohnston/fix-mda-load
BradyAJohnston Jun 11, 2024
33a0785
bump version
BradyAJohnston Jun 11, 2024
456fa2b
Merge branch 'main' into extensions-platform
BradyAJohnston Jun 11, 2024
38dcc51
fix registering for upload to platform
BradyAJohnston Jun 11, 2024
4a2c8d6
Merge branch 'node-attributes' into extensions-platform
BradyAJohnston Jun 11, 2024
5c1d2ab
move all imports to top of file
BradyAJohnston Jun 11, 2024
79cf260
able to run in blender and run tetss
BradyAJohnston Jun 11, 2024
6c604cc
re-enable logger
BradyAJohnston Jun 11, 2024
54a6de2
Rename style presets
BradyAJohnston Jun 11, 2024
5c485f8
bring starfile node back into main file
BradyAJohnston Jun 11, 2024
fb443b1
most tests passing
BradyAJohnston Jun 11, 2024
84238ff
properly register UI operators
BradyAJohnston Jun 11, 2024
dbab99a
fix custom node range creation
BradyAJohnston Jun 12, 2024
bb7ec18
tweak register
BradyAJohnston Jun 12, 2024
bb2a669
update blender release version
BradyAJohnston Jun 12, 2024
10c278f
add macos-14
BradyAJohnston Jun 12, 2024
6a4ad61
fix MDA tests
BradyAJohnston Jun 12, 2024
bfae8a5
remove unused test
BradyAJohnston Jun 12, 2024
fa7c441
remove pkg.py
BradyAJohnston Jun 12, 2024
5c3fa54
cleanup class imports
BradyAJohnston Jun 12, 2024
366c14f
cleanup build script
BradyAJohnston Jun 12, 2024
d1b487e
fix build script
BradyAJohnston Jun 12, 2024
755c7a0
remove selections for MD currently
BradyAJohnston Jun 12, 2024
aac0831
fix test
BradyAJohnston Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 22 additions & 35 deletions .github/workflows/test-addon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Test in Blender

on:
push:
branches: ["main"]
branches: ["main", "4.2", "extensions-platform"]
pull_request:
branches: ["main", "4.1"]
branches: ["main", "4.2", "extensions-platform"]

jobs:
build:
Expand All @@ -13,57 +13,44 @@ jobs:
max-parallel: 4
fail-fast: false
matrix:
blender-version: ["4.1"]
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
# os: [macos-13]
blender-version: ["4.2"]
os: [ubuntu-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11.7

- name: Test in Blender MacOS Intel
if: matrix.os == 'macos-13'
run: |
curl -L -o blender.dmg https://download.blender.org/release/Blender4.1/blender-4.1.0-macos-x64.dmg
hdiutil attach blender.dmg
cp -R /Volumes/Blender/Blender.app /Applications/
hdiutil detach /Volumes/Blender
/Applications/Blender.app/Contents/MacOS/Blender --version
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/install.py
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/run.py -- -v
- name: Cache Blender
uses: actions/cache@v2
with:
path: ~/blender.tar.xz
key: ${{ runner.os }}-blender-${{ hashFiles('**/test-addon.yml') }}

- name: Test in Blender MacOS ARM
if: matrix.os == 'macos-14'
run: |
curl -L -o blender.dmg https://download.blender.org/release/Blender4.1/blender-4.1.0-macos-arm64.dmg
curl -L -o blender.dmg https://cdn.builder.blender.org/download/daily/blender-4.2.0-beta+v42.6f724b83c663-darwin.arm64-release.dmg
hdiutil attach blender.dmg
cp -R /Volumes/Blender/Blender.app /Applications/
hdiutil detach /Volumes/Blender
/Applications/Blender.app/Contents/MacOS/Blender --version
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/install.py
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/run.py -- -v

- name: Test in Blender Windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://download.blender.org/release/Blender4.1/blender-4.1.0-windows-x64.zip" -OutFile "blender.zip"
Expand-Archive -Path "blender.zip" -DestinationPath "blender"
.\blender\blender-4.1.0-windows-x64\blender.exe --version
.\blender\blender-4.1.0-windows-x64\blender.exe -b --python tests/install.py
.\blender\blender-4.1.0-windows-x64\blender.exe -b --python tests/run.py -- -v tests/

/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/run.py -- -v tests/

- name: Test in Blender Linux
if: matrix.os == 'ubuntu-latest'
run: |
wget -nv https://download.blender.org/release/Blender4.1/blender-4.1.0-linux-x64.tar.xz
tar -xf blender-4.1.0-linux-x64.tar.xz

blender-4.1.0-linux-x64/blender --version
blender-4.1.0-linux-x64/blender -b --python tests/install.py
blender-4.1.0-linux-x64/blender -b --python tests/run.py -- -v tests/ --cov=molecularnodes --cov-report=xml:coverage.xml --ignore=molecularnodes/ui/panel.py

if [[ ! -f ./blender.tar.xz ]]; then
wget -nv https://cdn.builder.blender.org/download/daily/blender-4.2.0-beta+v42.6f724b83c663-linux.x86_64-release.tar.xz -O ./blender.tar.xz
fi
mkdir -p ./blender
ls -lrta
tar -xf ./blender.tar.xz -C ./blender --strip-components=1
ls -lrta
blender/blender --version
blender/blender -b --python tests/install.py
blender/blender -b --python tests/run.py -- -v tests/ --cov=molecularnodes --cov-report=xml:coverage.xml --ignore=molecularnodes/ui/panel.py
- name: Expose coverage as a CI download
uses: actions/upload-artifact@v1
if: matrix.os == 'ubuntu-latest'
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*.blend1
__pycache__/*
.vscode/*
molecularnodes_*.zip
molecularnodes*.zip
*.pyc
.Rproj.user
/.quarto/
Expand All @@ -27,5 +27,4 @@ poetry.lock
*.vdb
docs/nodes/*.qmd
!docs/nodes/index.qmd


*.whl
157 changes: 144 additions & 13 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,155 @@
import glob
import os
import shutil
import subprocess
import sys
import zipfile
from dataclasses import dataclass
from typing import List, Union

import tomlkit

# zips up the template file
def zip_template():
# Define the directory and zip file paths
dir_path = 'molecularnodes/assets/template/Molecular Nodes'
zip_file_path = 'molecularnodes/assets/template/Molecular Nodes.zip'

# Create a ZipFile object in write mode
with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
# Walk the directory tree and add files to the zip file
for root, dirs, files in os.walk(dir_path):
@dataclass
class Platform:
pypi_suffix: str
metadata: str


# tags for blender metadata
# platforms = ["windows-x64", "macos-arm64", "linux-x64", "windows-arm64", "macos-x64"]


windows_x64 = Platform(pypi_suffix="win_amd64", metadata="windows-x64")
linux_x64 = Platform(pypi_suffix="manylinux2014_x86_64", metadata="linux-x64")
macos_arm = Platform(pypi_suffix="macosx_12_0_arm64", metadata="macos-arm64")
macos_intel = Platform(pypi_suffix="macosx_10_15_x86_64", metadata="macos-x64")


required_packages = [
"mrcfile==1.4.3",
"starfile==0.5.6",
"MDAnalysis==2.7.0",
"biotite==0.41.0",
]


build_platforms = [
windows_x64,
linux_x64,
macos_arm,
macos_intel,
]


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


def download_whls(
python_version="3.11",
packages: List[str] = required_packages,
platforms: Union[Platform, List[Platform]] = build_platforms,
):
if isinstance(platforms, Platform):
platforms = [platforms]

for platform in platforms:
for package in required_packages:
run_python(
f"-m pip download {package} --dest ./molecularnodes/wheels --only-binary=:all: --python-version={python_version} --platform={platform.pypi_suffix}"
)


toml_path = "molecularnodes/blender_manifest.toml"


def update_toml_whls(platform: Platform):
# List all .whl files in the wheels/ subdirectory
wheel_files = glob.glob("./wheels/*.whl", root_dir="molecularnodes")

# scipy and pyarrow both are extremly large packages and aren't actually required by us,
# so we can safely remove them (and potentially others) for bundling a smaller wheels/*
for whl in wheel_files:
if "scipy" in whl or "pyarrow" in whl:
os.remove(os.path.join("molecularnodes/", whl.removeprefix("./")))
wheel_files.remove(whl)

# Load the TOML file
with open(toml_path, "r") as file:
manifest = tomlkit.parse(file.read())

# Update the wheels list
manifest["wheels"] = wheel_files
manifest["version"] = "{}-{}".format(manifest["version"], platform.metadata)
manifest["platforms"] = platform.metadata

manifest_str = (
tomlkit.dumps(manifest)
.replace('["', '[\n\t"')
.replace('", "', '",\n\t"')
.replace('"]', '",\n]')
)

# Write the updated TOML file
with open(toml_path, "w") as file:
file.write(manifest_str)


def reset_toml() -> None:
with open(toml_path, "r") as file:
manifest = tomlkit.parse(file.read())

manifest["version"] = manifest["version"].split("-")[0]
manifest["wheels"] = []
manifest["platforms"] = []

with open(toml_path, "w") as file:
file.write(tomlkit.dumps(manifest))


def zip_extension(platform: Platform) -> None:
# Load the TOML file
with open(toml_path, "r") as file:
manifest = tomlkit.parse(file.read())

# Get the version number
version = manifest["version"].split("-")[0]

zip_file_name = f"molecularnodes-{version}-{platform.metadata}.zip"

# Create the zip file
with zipfile.ZipFile(zip_file_name, "w", zipfile.ZIP_DEFLATED) as zip_file:
# Walk the molecularnodes folder
for root, dirs, files in os.walk("molecularnodes"):
# Ignore __pycache__ directories
if "__pycache__" in root or "blend1" in files:
continue
for file in files:
# Get the path of the file
# Get the file path
file_path = os.path.join(root, file)

# Add the file to the zip file
zipf.write(file_path, arcname=os.path.relpath(
file_path, start='molecularnodes/assets/template/'))
zip_file.write(
file_path, arcname=os.path.relpath(file_path, "molecularnodes")
)


def remove_whls():
dir_path = "./molecularnodes/wheels"
if os.path.exists(dir_path):
shutil.rmtree(dir_path)


def build(platform: Platform) -> None:
download_whls(platforms=platform)
update_toml_whls(platform=platform)
zip_extension(platform=platform)
remove_whls()
reset_toml()


if __name__ == "__main__":
zip_template()
for platform in build_platforms:
build(platform)
1 change: 0 additions & 1 deletion docs/.jupyter_cache/__version__.txt

This file was deleted.

Loading
Loading