Skip to content

Commit ee56331

Browse files
committed
add alternative build via just
1 parent 63d74f7 commit ee56331

3 files changed

Lines changed: 131 additions & 11 deletions

File tree

justfile

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,134 @@
11
set windows-shell := ["pwsh", "-c"]
22

3+
renderLibVersion := "0.3.2"
4+
5+
default: frontend dotnet-test
6+
7+
# deletes all build files
8+
[windows]
9+
[confirm]
10+
clean:
11+
Remove-Item -Recurse -Force ./prebuilt
12+
13+
# deletes all build files
14+
[unix]
15+
[confirm]
16+
clean:
17+
rm -rf ./prebuilt
18+
19+
# builds flipbook.js via npm
320
[working-directory: 'FlipViewer']
421
frontend:
522
npm install
623
npm run build
724
echo "Copying .js to python package..."
825
cp ./dist/flipbook.js ../PyWrapper/simpleimageio/flipbook.js
926

27+
[unix]
28+
_ensure_dirs:
29+
mkdir -p runtimes/linux-x64/native
30+
mkdir -p runtimes/win-x64/native
31+
mkdir -p runtimes/osx-x64/native
32+
mkdir -p runtimes/osx-arm64/native
33+
mkdir -p build
34+
35+
[windows]
36+
_ensure_dirs:
37+
New-Item -ItemType Directory runtimes/linux-x64/native > $null
38+
New-Item -ItemType Directory runtimes/win-x64/native > $null
39+
New-Item -ItemType Directory runtimes/osx-x64/native > $null
40+
New-Item -ItemType Directory runtimes/osx-arm64/native > $null
41+
New-Item -ItemType Directory build > $null
42+
43+
# Downloads the precompiled binaries for OIDN from GitHub
44+
[windows]
45+
_download:
46+
if (-not(Test-Path -Path "prebuilt" -PathType Container))
47+
{
48+
Invoke-WebRequest -Uri "https://github.com/pgrit/RenderLibs/releases/download/v{{renderLibVersion}}/RenderLibs-v{{renderLibVersion}}.zip" -OutFile "prebuilt.zip"
49+
Expand-Archive "prebuilt.zip" -DestinationPath ./prebuilt
50+
rm prebuilt.zip
51+
}
52+
53+
# Downloads the precompiled binaries for OIDN from GitHub
54+
[unix]
55+
_download:
56+
if ! {{ path_exists("./prebuilt") }}; then \
57+
wget "https://github.com/pgrit/RenderLibs/releases/download/v{{renderLibVersion}}/RenderLibs-v{{renderLibVersion}}.zip" -O prebuilt.zip ;\
58+
unzip -d ./prebuilt/ prebuilt.zip ;\
59+
rm prebuilt.zip ;\
60+
fi
61+
62+
# Copies the precompiled binaries to their appropriate places
63+
copy-oidn: _ensure_dirs _download
64+
cp prebuilt/linux/lib/libtbb.so.12.12 runtimes/linux-x64/native/libtbb.so.12
65+
cp prebuilt/linux/lib/libOpenImageDenoise.so.2.2.0 runtimes/linux-x64/native/libOpenImageDenoise.so
66+
cp prebuilt/linux/lib/libOpenImageDenoise_core.so.2.2.0 runtimes/linux-x64/native/
67+
cp prebuilt/linux/lib/libOpenImageDenoise_device_cpu.so.2.2.0 runtimes/linux-x64/native/
68+
69+
cp prebuilt/win/bin/tbb12.dll runtimes/win-x64/native/
70+
cp prebuilt/win/bin/OpenImageDenoise.dll runtimes/win-x64/native/OpenImageDenoise.dll
71+
cp prebuilt/win/bin/OpenImageDenoise_core.dll runtimes/win-x64/native/
72+
cp prebuilt/win/bin/OpenImageDenoise_device_cpu.dll runtimes/win-x64/native/
73+
74+
cp prebuilt/osx/lib/libtbb.12.12.dylib runtimes/osx-x64/native/libtbb.12.dylib
75+
cp prebuilt/osx/lib/libOpenImageDenoise.2.2.0.dylib runtimes/osx-x64/native/libOpenImageDenoise.dylib
76+
cp prebuilt/osx/lib/libOpenImageDenoise_core.2.2.0.dylib runtimes/osx-x64/native/
77+
cp prebuilt/osx/lib/libOpenImageDenoise_device_cpu.2.2.0.dylib runtimes/osx-x64/native/
78+
79+
cp prebuilt/osx-arm64/lib/libtbb.12.12.dylib runtimes/osx-arm64/native/libtbb.12.dylib
80+
cp prebuilt/osx-arm64/lib/libOpenImageDenoise.2.2.0.dylib runtimes/osx-arm64/native/libOpenImageDenoise.dylib
81+
cp prebuilt/osx-arm64/lib/libOpenImageDenoise_core.2.2.0.dylib runtimes/osx-arm64/native/
82+
cp prebuilt/osx-arm64/lib/libOpenImageDenoise_device_cpu.2.2.0.dylib runtimes/osx-arm64/native/
83+
84+
# Builds the C++ wrapper library for x86 and arm
85+
[macos]
86+
[working-directory: "./build/" ]
87+
build-native:
88+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64" ..
89+
cmake --build . --config Release
90+
91+
# Empty the build folder first to avoid cache issues
92+
rm -rf *
93+
94+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64" ..
95+
cmake --build . --config Release
96+
97+
# Builds the C++ wrapper library
98+
[linux]
99+
[windows]
100+
[working-directory: "./build/" ]
101+
build-native:
102+
cmake -DCMAKE_BUILD_TYPE=Release ..
103+
cmake --build . --config Release
104+
105+
# Builds the python package for deployment. Assumes the frontend was built.
106+
python:
107+
python -m pip install build wheel
108+
python -m build --sdist
109+
110+
# Force installs a fresh build of the python package in the user directory
111+
[unix]
112+
python-dev:
113+
rm -rf ./dist/*
114+
python -m build --wheel
115+
whl=$(find ./dist -name *.whl);\
116+
python -m pip install --user $whl;\
117+
python -m pip install --user --force-reinstall --no-deps $whl
118+
119+
# Force installs a fresh build of the python package in the user directory
120+
[windows]
121+
python-dev:
122+
python -m build --wheel
123+
$latestWhl = Get-ChildItem -Path "./dist/*.whl" | Sort-Object LastAccessTime -Descending | Select-Object -First 1
124+
python -m pip install --user $latestWhl.FullName
125+
python -m pip install --user --force-reinstall --no-deps $latestWhl.FullName
126+
127+
[working-directory: "./PyTest/"]
128+
python-test: python-dev
129+
python -m unittest
130+
131+
# Builds and tests the .NET library
132+
dotnet-test: build-native copy-oidn
133+
dotnet build
134+
dotnet test

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ requires = [
44
"wheel",
55
"cmake>=3.14",
66
]
7-
build-backend = "setuptools.build_meta"
7+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# https://stackoverflow.com/questions/42585210/extending-setuptools-extension-to-use-cmake-in-setup-py
44

55
import os
6-
import shutil
76
import pathlib
87
from setuptools import setup, Extension
98
from setuptools.command.build_ext import build_ext as build_ext_orig
10-
from distutils.command import build as build_module
9+
1110

1211
class CMakeExtension(Extension):
1312
def __init__(self, name):
1413
# don't invoke the original build_ext for this special extension
1514
super().__init__(name, sources=[])
1615

16+
1717
class build_ext(build_ext_orig):
1818
def run(self):
1919
for ext in self.extensions:
@@ -33,16 +33,10 @@ def build_cmake(self, ext):
3333
# Configure CMake arguments
3434
config = 'Release'
3535
cmake_args = [
36-
'-DPYLIB=' + str(extdir.parent.absolute()), # destination for the shared library
36+
'-DPYLIB=' + str(extdir.parent.absolute()), # destination for the shared library
3737
'-DCMAKE_BUILD_TYPE=' + config,
3838
'-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15'
3939
]
40-
# if shutil.which("ninja") and shutil.which("clang"):
41-
# cmake_args.extend([
42-
# '-G', 'Ninja',
43-
# '-DCMAKE_CXX_COMPILER=clang++',
44-
# '-DCMAKE_C_COMPILER=clang'
45-
# ])
4640
build_args = [ '--config', config ]
4741

4842
# Run CMake and build (automatically copies the .dll / .so / .dylib file)
@@ -52,6 +46,7 @@ def build_cmake(self, ext):
5246
self.spawn(['cmake', '--build', '.'] + build_args)
5347
os.chdir(str(cwd))
5448

49+
5550
with open("README.md", "r") as fh:
5651
long_description = fh.read()
5752

@@ -65,11 +60,11 @@ def build_cmake(self, ext):
6560
long_description=long_description,
6661
long_description_content_type="text/markdown",
6762

63+
license="MIT",
6864
packages=['simpleimageio'],
6965
package_dir={'simpleimageio': 'PyWrapper/simpleimageio'},
7066
classifiers=[
7167
"Programming Language :: Python :: 3",
72-
"License :: OSI Approved :: MIT License",
7368
"Operating System :: OS Independent",
7469
],
7570
python_requires='>=3.6',

0 commit comments

Comments
 (0)