[Bf-committers] Proposal: include Python's distutils

Campbell Barton ideasman42 at gmail.com
Mon Feb 15 09:28:40 CET 2016


TL;DR version.
We can include distutils, but pip also needs config and a config header.

Uploaded diff: https://developer.blender.org/D1805
Best postpone until after 2.77 is out.

-----

Some backstory on using system vs bundled Python.

In the past Python developers could just remove the Python bundled with Blender,
then Blender would fallback to the operating systems Python.

While this isn't the same as being able to install packages into
Blender's own Python,
in practice it meant Python developers could use a full Python
installation if they needed.

This can still work, however for ms-windows we're using a different
MSVC to official CPython builds,
so Blender can't use python.org's Python package (some ABI
compatibility issues).

I tested this on Linux and I'm no longer able to remove the local
Python and run Blender,
it turns out this only works when the absolute location of the Python
library on your system matches the location used at build time.
The build bot uses "/opt/lib/python-3.5.0x", so chances you have this
on your installation are low.

To override this path, set the PYTHONPATH, on my system for eg:
PYTHONPATH=/usr/lib/python3.5 ./blender
(will update docs on this topic).

Since we can't guarantee the systems Python is compatible with
Blender's, including distutils (to support pip) seems fine.
However we need to include a bit more then just `distutils`.

To get pip working I needed to include:

- python/lib/distutils
- python/lib/config-{version}
- python/include/python{version}/pyconfig.h

Checked our pre-compiled Python OSX & Windows contain the include
files, so don't see any need for platform maintainers to update the
Python builds.


More information about the Bf-committers mailing list