Monday, 9 September 2019

setuptools "eager_resources" to executable directory

I maintain a Python utility that allows bpy to be installable as a Python module.

Unfortunately, platform differences and Blender runtime expectations makes support for this tricky at times.

Currently, one of my big goals is to get the Blender addon scripts directory to install into the correct location. The directory (simply named after the version of Blender API) has to exist in the same directory as the Python executable.

Unfortunately the way that setuptools works (or at least the way that I have it configured) the 2.79 directory is not always placed as a sibling to the Python executable. It fails on Windows platforms outside of virtual environments.

However, I noticed in setuptools documentation that you can specify eager_resources that supposedly guarantees the location of extracted files.

https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-resource-extraction https://setuptools.readthedocs.io/en/latest/pkg_resources.html#resource-extraction

There was a lot of hand waving and jargon in the documentation, and 0 examples. I'm really confused as to how to structure my setup.py file in order to guarantee the resource extraction. Currently, I just label the whole 2.79 directory as "scripts" in my setuptools Extension and ship it.

Is there a way to write my setup.py and package my module so as to guarantee the 2.79 directory's location is the same as the currently running python executable when someone runs

py -3.6.8-32 -m pip install bpy

Besides simply "hacking it in"? I was considering writing a install_requires module that would simply move it if possible but that is mangling with the user's file system and kind of hacky. However it's the route I am going to go if this proves impossible.

Here is the original issue for anyone interested.

https://github.com/TylerGubala/blenderpy/issues/13

My build process is identical to the process descsribed in my answer here

https://stackoverflow.com/a/51575996/6767685



from setuptools "eager_resources" to executable directory

No comments:

Post a Comment