-
Notifications
You must be signed in to change notification settings - Fork 21
Development on Windows
- If you have UMOG already installed, remove it.
- Install git and optionally a gui client. Use of git flow is highly recommended.
- Create a Github account.
- Fork the addon repository.
- Clone the repository to your local hard drive.
The cloning target location can be either the addon folder of Blender or anywhere on your system. However the intended form of development is to clone the repository in the addon
folder.
Example addon folder path for Linux and Blender 2.78:
/home/$user/.blender/2.78/scripts/addons/m3addon
Example addon folder path for Windows 7 and Blender 2.78:
C:\Users\%username%\AppData\Roaming\Blender Foundation\Blender\2.78\scripts\addons
In order to support compiling directly from the addon folder, UMOG's root-level __init__.py
references the rest of the modules from the UMOG subdirectory (UMOG>UMOG
). as follows:
import bpy
from . import UMOG as umg
def register():
umg.register()
bpy.utils.register_module(__name__)
def unregister():
umg.unregister()
bpy.utils.unregister_module(__name__)
In order to support compilation directly from the addon folder, such that no copy/pasting/installtion is necessary, we rename the __init__.py
file right before the compilation to __init__.temp
. When the compilation is completed, we revert this change back to __init__.py
.
This is due to the fact that the setup.py
should not live inside our package. As far as we know the build_ext
commands has no option (apart from --inplace
) to specify a target path.
Thus by renaming __ini__.py
file, we temporarily trick Cython to believe that it's not residing in the package.
-
Install Python (Anaconda) First we have to install Python itself. You should use Anaconda for that. Just take the newest version.
Installing Python this way has multiple benefits:
- Easier installation of other packages
- Easier handling of multiple Python environments
Make sure that Anaconda has been added to the
PATH
system environment variable. You can test if the installation worked by runningpython -V
(in a newly opened terminal window). The output should includeContinuum Analytics, Inc.
somewhere.Depending on what Blender version you want to compile the addon for, different versions of Python are necessary. All newer Blender versions up until Blender 2.79 officially use Python 3.5.x. The plan is to update to Python 3.6 in the Blender 2.8 project.
As UMOG currently does not work with Blender 2.8 you want to compile using Python 3.5. What we can do now is to create a Python environment for that version. Fortunately Anaconda makes this fairly easy to set up.
To create the Python 3.5 environment, just run
conda create -n py35 python=3.5 anaconda
. The new environment will be calledpy35
. To activate it you need to runactivate py35
(or in some terminalssource activate py35
). When you now runpython -V
it should show you that you are using Python 3.5. You have to activate the environment everytime you reopen the terminal. More Information can be found here.Note: The following steps should all be executed in the new correct Python environment after
activate py35
. -
Link Blender's Python to system's It is necessary to link Blender's python path to the Anaconda environment we just setup. For Windows you can follow this answer on Stack Exchange, and for Unix systems this answer is useful.
Note: It is much simpler and beneficial in the long run to create a link to the Anaconda installation rather than copying the entirety of the environment.
-
Install Cython When you used Anaconda, it will be easy to install Cython.
Just run
conda install cython
. Cython is preinstalled with the current version of Anaconda as of writing this page. So this step is just to make sure our dependencies exist. -
Build UMOG This step is the most error prone, if you have any problems, checkout the troubleshooting section at the bottom.
Go to main directory of UMOG. This folder should contain a file called
setup.py
.Run
python setup.py --all
. This can take a while. This can take a while.It also creates a
config.py
file next to thesetup.py
. You can use it to specify where the compiled addon should be copied. This should be the path to Blenders addon directory. Once you changed the file, you can thesetup.py
file again. This time it copies all files into the specified location.Later when you want to recompile UMOG, just run
python setup.py
. It will only recompile and copy the files that changed.
Note: The --copy
and --export
commands are not working properly as of writing this page.
-
Developing Without Building UMOG There is an alternative that allows for quick development without having to compile the project at every single step. For this to work, you need to:
- Run
python setup.py --clean
. To fully clean the project. - Run
python setup.py --pyximport
.
- Run
The --pyximport
allows for rapid development of Cython modules. Keep in mind that import pyximport
and pyximport.install()
must be declared before importing the Cython modules.
The setup.py
file has a few command line arguments:
-
--all
This will rebuild all Cython files which can be quite useful when Cython does not automatically detect all files that need to update after you've made a change. Should not be needed in most cases though. -
--clean
Removes all the unnecessary files for production. These include.c
,.pyd
,.so
, and.zip
files. It also removes thebuild
folder as well as all__pycache__
folders. -
--pyximport
For building Cython modules during development without explicitly runningsetup.py
after each change. Unomments the following across all files:import pyximport
pyximport.install()
-
--export
Creates a redistributable zip file. Currently under development. -
--noversioncheck
Allows to create a build with any Python version.
If your problem cannot be solved with the information, please report it.
Most errors happen because Python cannot find a correct C compiler to compile the extension modules. Here are some very helpful links on the topic:
Basicly you will have to install Visual Studio 2017 (Microsoft does not want you to install older versions) and use the x64 Native Tools Command Prompt for VS 2017
to run the python setup.py
command.
If Visual Studio 2015 is already installed on you machine but you get this error: unable to find vcvarsall.bat
it is relatively easy to fix:
You need to change the installation features. More information can be found here: http://stackoverflow.com/a/35243904/4755171