mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-09-19 22:30:05 +00:00
CMake now invokes distutils correctly
This commit is contained in:
parent
eb63ac0753
commit
8c6785594c
@ -337,19 +337,25 @@ if(PYTHONINTERP_FOUND AND SWIG_FOUND)
|
||||
if(NUMPY_ERR)
|
||||
message(WARNING "Unable to import numpy.")
|
||||
else()
|
||||
message(STATUS "Numpy package has been located, Python bindings will be built.")
|
||||
message(STATUS "Numpy package has been located.")
|
||||
set(PYCMD ${PYTHON_EXECUTABLE} setup.py build )
|
||||
list(APPEND PYCMD --osddir=${LIBRARY_OUTPUT_PATH} )
|
||||
list(APPEND PYCMD --build-platlib=${PROJECT_BINARY_DIR}/python )
|
||||
list(APPEND PYCMD --build-temp=${PROJECT_BINARY_DIR}/temp )
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/python
|
||||
COMMAND ${PYTHON_EXECUTABLE} setup.py build --osddir=${LIBRARY_OUTPUT_PATH} --build-base=${PROJECT_BINARY_DIR}/python
|
||||
WORKING_DIRECTORY python
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/python/osd
|
||||
COMMAND ${PYCMD}
|
||||
WORKING_DIRECTORY ../python
|
||||
DEPENDS osd_static_cpu osd_dynamic_cpu
|
||||
COMMENT "Building Python bindings with distutils"
|
||||
)
|
||||
add_custom_target(python ALL
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/python)
|
||||
install(CODE "execute_process("
|
||||
"WORKING_DIRECTORY python "
|
||||
"COMMAND ${PYTHON_EXECUTABLE} setup.py build --osddir=${LIBRARY_OUTPUT_PATH} --build-base=/home/prideout/git/OpenSubdiv/build/python install")
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/python/osd
|
||||
)
|
||||
install(CODE "execute_process(
|
||||
WORKING_DIRECTORY ../python
|
||||
COMMAND ${PYCMD} install --user)"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -1,17 +1,13 @@
|
||||
# Instructions
|
||||
|
||||
The OpenSubdiv Python wrapper has been tested with Python 2.6 and Python 2.7.
|
||||
Make sure you have the numpy module installed before you begin.
|
||||
Make sure you install SWIG and numpy before you begin.
|
||||
|
||||
First, try building the extension with:
|
||||
CMake builds the extension like this:
|
||||
|
||||
./setup.py build osddir='../build/lib'
|
||||
./setup.py build --osddir='../build/lib' --build-platlib='../build/python'
|
||||
|
||||
You'll need to replace `../build/lib` with the folder that has `libosdCPU.a` et al.
|
||||
|
||||
This creates a build folder with a platform-specific subfolder, such as:
|
||||
|
||||
./build/lib.macosx-10.8-intel-2.7
|
||||
If you invoke this manually, you'll need to replace `../build/lib` with the folder that has `libosdCPU.a`.
|
||||
|
||||
Next, try out the unit tests:
|
||||
|
||||
@ -41,3 +37,4 @@ After installing the module, you can generate and view the Sphinx-generated docu
|
||||
- Instead of using OsdCpuVertexBuffer, create a "NumpyCpuVertexBuffer" that wraps a numpy array
|
||||
- Add an API that looks very similar to the RIB parameters for RiHierarchicalSubdiv
|
||||
- Remove all the caveats that are listed in the Sphinx docs :)
|
||||
- Sphinx documentation should be CMake-ified.
|
||||
|
0
python/demo/interactive.py
Normal file → Executable file
0
python/demo/interactive.py
Normal file → Executable file
0
python/demo/main.py
Normal file → Executable file
0
python/demo/main.py
Normal file → Executable file
@ -57,7 +57,7 @@
|
||||
|
||||
from OpenGL.GL import *
|
||||
|
||||
ProgramFiles = ['demo/simple.glsl']
|
||||
ProgramFiles = ['simple.glsl']
|
||||
|
||||
Programs = {
|
||||
"BareBones" : {
|
||||
|
@ -66,23 +66,12 @@ import os, os.path
|
||||
np_include_dir = numpy.get_include()
|
||||
np_library_dir = os.path.join(np_include_dir, '../lib')
|
||||
osd_include_dirs = ['../opensubdiv', '../regression']
|
||||
|
||||
def import_build_folder():
|
||||
import sys, distutils.util, os.path
|
||||
build_dir = "build/lib.{0}-{1}.{2}".format(
|
||||
distutils.util.get_platform(),
|
||||
*sys.version_info)
|
||||
if not os.path.exists(build_dir):
|
||||
print "Folder does not exist: " + build_dir
|
||||
print "Perhaps you need to run:"
|
||||
print " python setup.py build"
|
||||
else:
|
||||
sys.path.insert(0, build_dir)
|
||||
osddir = '../build/lib'
|
||||
|
||||
osd_shim = Extension(
|
||||
'osd._shim',
|
||||
include_dirs = osd_include_dirs,
|
||||
library_dirs = ['../build/lib', np_library_dir],
|
||||
library_dirs = [osddir, np_library_dir],
|
||||
libraries = ['osdCPU', 'npymath'],
|
||||
swig_opts = ['-c++'],
|
||||
sources = [
|
||||
@ -95,6 +84,21 @@ osd_shim.extra_compile_args = \
|
||||
|
||||
os.environ['ARCHFLAGS'] = '-arch ' + os.uname()[4]
|
||||
|
||||
def setBuildFolder(folder):
|
||||
osddir = folder
|
||||
osd_shim.runtime_library_dirs = [folder]
|
||||
osd_shim.library_dirs = [folder, np_library_dir]
|
||||
|
||||
def importBuildFolder():
|
||||
import os.path
|
||||
builddir = os.path.join(osddir, "../python")
|
||||
if not os.path.exists(builddir):
|
||||
print "Folder does not exist: " + builddir
|
||||
print "Perhaps you need to run:"
|
||||
print " python setup.py build"
|
||||
else:
|
||||
sys.path.insert(0, builddir)
|
||||
|
||||
class TestCommand(Command):
|
||||
description = "runs unit tests"
|
||||
user_options = []
|
||||
@ -103,7 +107,7 @@ class TestCommand(Command):
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
import_build_folder()
|
||||
importBuildFolder()
|
||||
import unittest, test
|
||||
suite = unittest.defaultTestLoader.loadTestsFromModule(test)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
@ -116,8 +120,9 @@ class DemoCommand(Command):
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
import_build_folder()
|
||||
importBuildFolder()
|
||||
import demo
|
||||
os.chdir('demo')
|
||||
demo.main()
|
||||
|
||||
class InteractiveCommand(Command):
|
||||
@ -128,8 +133,9 @@ class InteractiveCommand(Command):
|
||||
def finalize_options(self):
|
||||
pass
|
||||
def run(self):
|
||||
import_build_folder()
|
||||
importBuildFolder()
|
||||
import demo
|
||||
os.chdir('demo')
|
||||
demo.interactive()
|
||||
|
||||
class DocCommand(Command):
|
||||
@ -156,7 +162,7 @@ class BuildCommand(build):
|
||||
build.finalize_options(self)
|
||||
if self.osddir is None:
|
||||
self.osddir = '../build/lib'
|
||||
osd_shim.runtime_library_dirs = [self.osddir]
|
||||
setBuildFolder(self.osddir)
|
||||
def run(self):
|
||||
build.run(self)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user