From BlenderWiki
Proposal is to include numpy with official blender builds.
Why
Blender has its own mathutils module, but this is focused on math for access to object rotations, vertex positions, color. But misses large matricies and more advanced math functionality that numpy has, which would take considerable effort to include in mathutils.
Since blender is already very math focused (being a 3D app), including numpy makes sense for us.
Benifits
- Addon authors can take advantage of numpys optimized matrix functions.
- Users can use these addons without having to manually install numpy.
Tradeoffs
- Less flexibility to use updated python if numpy has not been updated too.
- Less flexibility to use another python implimentation (pypy for example), though they are working on their own numpy.
- Greater download size (approx 1.1mb compressed)
Where Numpy Fits in
- Default setup wont load numpy a tall (no slower startup times).
- Numpy should not be depended on for core scripts (for the purpose of the discussion, scripts that load on startup). OR...
Import numpy when its used but not on startup. - Numpy C API wont be used and linked against blender.
- Initially numpy should only be used for addons which need such advanced functionality, bundled scripts which dont take advantage of numpy should keep using mathutils since it integrates better with blender.
Stripping Out Cruft
Heres the CMake install command that is used to get rid of extra files, reducing numpy's compressed size to around 1.1mb
install(
DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy
DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages
PATTERN ".svn" EXCLUDE
PATTERN "__pycache__" EXCLUDE # * any cache *
PATTERN "*.pyc" EXCLUDE # * any cache *
PATTERN "*.pyo" EXCLUDE # * any cache *
PATTERN "distutils" EXCLUDE # ./distutils
PATTERN "oldnumeric" EXCLUDE # ./oldnumeric
PATTERN "doc" EXCLUDE # ./doc
PATTERN "tests" EXCLUDE # ./tests
PATTERN "f2py" EXCLUDE # ./f2py - fortran/python interface code, not fun for blender devs.
PATTERN "include" EXCLUDE # include dirs all over, we wont use NumPy/CAPI
PATTERN "*.h" EXCLUDE # some includes are not in include dirs
PATTERN "*.a" EXCLUDE # ./core/lib/libnpymath.a - for linking, we dont need.
)
Steps to Include Numpy in Releases
Linux
On linux numpy is to be copied from site-packages when installing python. if its not found it will warn numpy is missing. DONE
Windows and OSX
Numpy will need to be build as a dependancy and included in the lib/ dir as other pre-built libraries are.
Steps to Include Numpy in Distro Packages
no need, they will just have numpy as a dependency for blender.