「Dev:2.5/Source/Python/API/Numpy Bundle」の版間の差分
(→Where Numpy Fits in: typos) |
細 (1版 をインポートしました) |
(相違点なし)
|
2018年6月29日 (金) 05:49時点における最新版
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.
Benefits
- 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 won't load numpy at all (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 it's used but not on startup. - Numpy C API won't be used and linked against blender.
- Initially numpy should only be used for addons which need such advanced functionality, bundled scripts which don't 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.