0
$\begingroup$

I am developing a Blender addon, which needs few external Python libraries (e.g. scipy, pandas, etc). I was wondering about the best approach for including them into a "stand-alone" software package. My approach would be to embed them in the addon directory under /packages/modules

Myaddon
-packages
  -addons
  -modules
     -scipy
     -pandas
     -etc..
  -presets
  -startup
-file1.py
-file2.py

This approach seems working fine. Of course, the size of the addon is bigger that initially anticipated, but I thinks that this approach is probably the only one that can make the addon usable also for non-Python users. What do you think? I just wanted to hear some other opinions.

$\endgroup$

1 Answer 1

0
$\begingroup$

The site package folder should be in sys.path and created for each Python version like site.getusersitepackages. You can use what site.getusersitepackages returns which for Blender is already in sys.path or create one inside the addon folder.

$\endgroup$
3
  • $\begingroup$ I actually added a Script Directories in Blender preferences -> File Paths. Here I selected the folder Myaddon/packages That worked on a "virgin" laptop with no Windows sys Python installed. This means that the only thing that a user should do is to extract the .zip file and select Myaddon/packages folder under Blender preferences -> File Paths $\endgroup$
    – Alex Mekx
    Commented Jun 20 at 11:35
  • $\begingroup$ That adds the folder to sys.path but does not solve other problems. You can add it yourself with sys.path.append somewhere in the register function. My solution is this. $\endgroup$
    – unwave
    Commented Jun 21 at 8:59
  • $\begingroup$ Which other problems are not solved by the solution I proposed? Can you make an example? $\endgroup$
    – Alex Mekx
    Commented Jun 23 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .