Skip to content

Commit

Permalink
add support for bdist wheel build
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerGubala committed Oct 19, 2020
1 parent 962cf5d commit ec57368
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .vscode/tasks/Docker/manylinux/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function repair_wheel {

# Compile wheels
for PYBIN in /opt/python/cp37*/bin; do
"${PYBIN}/pip" install /blenderpy --global-option="build_ext" --global-option="--builtbpy='/build/linux/bin/'" -v
"${PYBIN}/pip" wheel /blenderpy --global-option="build_ext" --global-option="--builtbpy='/build/linux/bin/'" --no-deps -v -w wheelhouse/
# to install, uncomment the below line
# "${PYBIN}/pip" install /blenderpy --global-option="build_ext" --global-option="--builtbpy=/build/linux/bin/" -v
"${PYBIN}/pip" wheel /blenderpy --build-option="--builtbpy=/build/linux/bin/" -v -w wheelhouse/
done

# Bundle external shared libraries into the wheels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for PYBIN in /opt/python/*/bin; do
for PYBIN in /opt/python/cp37*/bin; do
"${PYBIN}/pip" install -U pip
"${PYBIN}/pip" install -r /blenderpy/requirements.txt
done
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
context: .
dockerfile: ./.containers/Dockerfile
target: blenderpy-manylinux-wheel-builder
command: bash -c "/blenderpy/.vscode/tasks/Docker/manylinux/build.sh"
command: bash -c "/blenderpy/.vscode/tasks/Docker/manylinux/build.sh && /blenderpy/.vscode/tasks/Docker/manylinux/build_wheels.sh"
container_name: blenderpy-manylinux-wheel-builder
volumes:
- ./build:/build
Expand Down
41 changes: 40 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import platform
import re
from setuptools import find_packages, setup, Extension
from setuptools.command.build_py import build_py
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install
from setuptools.command.install_lib import install_lib
Expand Down Expand Up @@ -169,6 +170,27 @@ def run(self):

super().run()

class CMakeBuild(build_py):
"""Create custom build
"""

user_options = build_py.user_options + [
("builtbpy=", None, "Location of prebuilt bpy binaries"),
("cuda", None, "Install with CUDA Cycles"),
("optix", None, "Install with Optix Cycles"),
("optixroot=", None, "Custom OptiX install location")
]

def initialize_options(self):
"""Allows for `cmake_extension_prebuild_dir`
"""

super().initialize_options()
self.builtbpy = None
self.cuda = None
self.optix = None
self.optixroot = None

class BuildCMakeExt(build_ext):
"""
Builds using cmake instead of the python setuptools implicit build
Expand All @@ -184,12 +206,28 @@ def initialize_options(self):
"""Allows for `cmake_extension_prebuild_dir`
"""

build_ext.initialize_options(self)
super().initialize_options()
self.builtbpy = None
self.cuda = None
self.optix = None
self.optixroot = None

def finalize_options(self):
"""Grab options from previous call to `build`
This is required to get the options passed into --build-options
during bdist_wheel creation
"""

super().finalize_options()

self.set_undefined_options('build_py',
('builtbpy', 'builtbpy'),
('cuda', 'cuda'),
('optix', 'optix'),
('optixroot', 'optixroot')
)

def run(self):
"""
Perform build_cmake before doing the 'normal' stuff
Expand Down Expand Up @@ -361,6 +399,7 @@ def copy_bpy(self, source_path: pathlib.Path, dest_path: pathlib.Path):
install_requires=["numpy"],
url="https://github.com/TylerGubala/blenderpy",
cmdclass={
'build': CMakeBuild,
'build_ext': BuildCMakeExt,
'install_data': InstallCMakeLibsData,
'install_lib': InstallCMakeLibs,
Expand Down

0 comments on commit ec57368

Please sign in to comment.