From BlenderWiki

Jump to: navigation, search

Autopackage & Blender in Linux

This is a some tests making an autopackage for blender, with the steps to make your own.

if your interested in trying out the one Iv built, here it is.

first of all, get the autopackage tools.

You'll only need the Autopackage Development Environment and APBuild.

Here is the main spec file that manages building and generating the package. It needs to be saved in ./autopackage/default.apspec relative to the root of your blender source tree.

# -*- shell-script -*-
ShortName: Blender3D
SoftwareVersion: 2.44
DisplayName: Blender3D
Summary: Blender is an open source software 3D animation program.
PackageVersion: 1
CPUArchitectures: x86
AutopackageTarget: 1.2
Type: Application
License: GNU General Public License (GPL)
Compression: lzma # requires v1.2 of AutopackageTarget

Blender is a 3D application with a robust feature set similar in scope and depth
to other high-end 3D software such as Softimage|XSI, Cinema 4D, 3ds Max and Maya.
These features include advanced simulation tools such as rigid body dynamics,
fluid dynamics, and softbody dynamics, modifier based modeling tools,
powerful character animation tools,
a node based material and compositing system and an embedded scripting engine based on Python.

# If you're using autotools, the default should be enough.
# prepareBuild will set up apbuild and run configure for you. If you
# need to pass arguments to configure, just add them to prepareBuild:
# prepareBuild --enable-foo --disable-bar

# prepareBuild assumes ./configure; make; make install
# use scons instead, disable most things to get maximum compatibility
export APBUILD_STATIC="png jpeg z python2.5"
export CFLAGS=-Os -pipe 

scons \
	CC=apgcc \
	CXX=apg++ \
	BF_INSTALLDIR=$build_root/build \
	WITH_FFMPEG=false \

# copy python scripts into our own defined PYTHONHOME

# os
copyFiles $PYLIB_FROM/			$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/			$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/

copyFiles $PYLIB_FROM/			$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/

copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/
 copyFiles $PYLIB_FROM/			$PYLIB_TO/
 copyFiles $PYLIB_FROM/		$PYLIB_TO/

copyFiles $PYLIB_FROM/			$PYLIB_TO/
copyFiles $PYLIB_FROM/			$PYLIB_TO/
copyFiles $PYLIB_FROM/			$PYLIB_TO/
copyFiles $PYLIB_FROM/			$PYLIB_TO/
copyFiles $PYLIB_FROM/			$PYLIB_TO/
copyFiles $PYLIB_FROM/		$PYLIB_TO/
copyFiles $PYLIB_FROM/		$PYLIB_TO/
copyFiles $PYLIB_FROM/		$PYLIB_TO/
copyFiles $PYLIB_FROM/		$PYLIB_TO/

echo '<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="">
  <mime-type type="application/blender3d">
    <comment>Blender 3D file</comment>
    <magic priority="50">
      <match offset="0" type="string" value="BLENDER" />
    <glob pattern="*.blend*" />
</mime-info>' > $build_root/blend.xml

# copy icons, hicolor is a freedesktop standard location for icons.
copyFiles ./release/freedesktop/icons/16x16/blender.png $build_root/icons/hicolor/16x16/apps/
copyFiles ./release/freedesktop/icons/22x22/blender.png $build_root/icons/hicolor/22x22/apps/
copyFiles ./release/freedesktop/icons/32x32/blender.png $build_root/icons/hicolor/32x32/apps/
copyFiles ./release/freedesktop/icons/scalable/blender.svg $build_root/icons/hicolor/scalable/apps/

# Remove unneeded files
# Since I use blenders CVS repo for running scripts,
# there may be some files here.
rm $build_root/build/.blender/scripts/bpydata/config/*.cfg
rm $build_root/build/.blender/scripts/*.pyc
rm $build_root/build/.blender/scripts/bpymodules/*.pyc

# Warning, since we have international disabled, remove language files
# this should be removed before release
rm -rf $build_root/build/.blender/locale

# If you're using prepareBuild above, there is no need to change this!


# add some libs here SDL would be good

# This command will tell makeinstaller what to include in the package.
# The selection comes from the files created by 'make install' or equivalent.
# Usually, you can leave this at the default
echo '*' | import

# See for details
# MYPREFIX="$HOME/.local/" # use instead of $PREFIX, so we are never installed globaly.
copyFiles build/* "$PREFIX/share/blender_dev"

# dot files dont copy??
copyFiles build/.blender/* "$PREFIX/share/blender_dev/.blender/"

# Make a shell script
# This script sets the HOME dir so we can have our own scripts.
# Keep this so you can launch from the command line with a system wide install
echo "#!/bin/sh
exec $PREFIX/share/blender_dev/blender
" > build/blender_dev # so we can use copyFile and track the change, create bin if its not there

copyFile build/blender_dev $PREFIX/bin/blender_dev
chmod +x $PREFIX/bin/blender_dev

# make a desktop file, this should be in blender alredy, HACK!
echo "[Desktop Entry]
Name=Blender3D dev
Comment=Blender is an open source software 3D animation program.
Exec=env HOME='$PREFIX/share/blender_dev/' PYTHONHOME='$PREFIX/share/blender_dev/pymodules' '$PREFIX/share/blender_dev/blender' %F
Icon=blender.svg" > build/blender_dev.desktop

copyFile build/blender_dev.desktop $HOME/Desktop/blender_dev.desktop

installIcon icons/*
installMenuItem "Graphics" build/blender_dev.desktop
installMime blend.xml

# Leaving this at the default is safe unless you use custom commands in
# "Install" to create files. By default, all autopackage API functions are
# logged.

in your blender root (where youd normaly run make or scons) run


This will run scons with some alternative options.

if all goes well youll end up with a file "Blender3D-2.44.x86.package" in the same directory. you should be able to run this on another system with minimal chance of linking errors etc.

you can do a

chmod +x Blender3D\ 2.44.package
./Blender3D\ 2.44.package

or once you have autopackage

package install Blender3D\ 2.44.package

to install the package.

I want this to be able to coexist with an existing install of blender, so Iv made it install to """~/.local/share/blender_dev/""" and the binary is accessed from """~/.local/bin/blender_dev"""

This can be changed to suit out needs.

Static Linking


Python needs to be built so libpython.a is created.

extract Python-2.5.1.tar.bz2


./configure --enable-shared

edit ./Modules/Setup

uncomment "#*shared*" around line 152 and rename to "*static*" The following modules are built into libpython2.5.a

uncomment: array, math, time, operator, itertools, cStringIO, cPickle, zlib, _struct, _weakref, _random, binascii, collections, fcntl, spwd, grp, select


#array arraymodule.c	# array objects


array arraymodule.c	# array objects

python in blender will be able to import these modules without python being on the system.


make install

Note make CC=apgcc CXX=apg++ does not work, gives errors linking at the end of the build.

Now there will be a libpython2.5.a in ./ that you can copy to /usr/lib

Known Problems (Autopackage)

1) The GUI installer dosnt work in ubuntu feisty + autopackage 1.22 (it does on my PC which is slackware), The gui loads but before installing it hangs with a progress bar moving from side to side. - With debug enabled, I see an error "Cannot open Display" - as if X is not open, is this a known problem? (installing via command line works)