Skip to content

Building

Joachim Metz edited this page Jul 31, 2016 · 12 revisions

Introduction

The pytsk source code can be build with different compilers:

  • Using GNU Compiler Collection (GCC)
    • Using Cygwin
  • Using Minimalist GNU for Windows (MinGW)
  • Using Microsoft Visual Studio

Or directly packaged with different package managers:

  • Using Debian package tools (DEB)
  • Using RedHat package tools (RPM)
  • Using Mac OS X pkgbuild

Note that as of February 26, 2016 pytsk bundles a version of libtsk and is no longer linked against. So there no longer is a need to separately build libtsk.

Check Troubleshooting if you run into issues building pytsk.

Getting the source

Source package

To get the source package go to the downloads page and download the file named:

pytsk3-<version>.tar.gz

Note: the Source code .zip and .tar.gz files are not distribution packages and therefore do not included files necessary for a stand-alone build.

The source package can be extracted by running:

tar xfv pytsk3-<version>.tgz

This will create the source directory:

pytsk3

Git

To retrieve the source from the repository make sure to install: git

On a Debian-based system it can be installed by running:

sudo apt-get install git

On Windows download git from: http://git-scm.com/download/win

To get the source using git run:

git clone https://github.com/py4n6/pytsk

Using GNU Compiler Collection (GCC)

Before you build pytsk and tools using GNU Compiler Collection (GCC) you'll need to have the necessary compilation and build tools installed. Make sure that on

  • a Linux machine, you have build-essential (Debian-based) or the Development Tools (RedHat-based) installed.
  • a Mac OS X machine, you have XCode (with command line tools) or MacPorts (or equivalent)

Change into the source directory and run the following commands to build pytsk:

python setup.py build

To install:

python setup.py install

Visual Studio

Before you build pytsk and tools using Visual Studio you'll need to have the necessary compilation and build tools installed. Make sure that on a Windows machine, you have Microsoft Visual C++ Compiler for Python 2.7 or Visual Studio.

Change into the source directory and run the following commands to build pytsk:

python setup.py build

To install:

python setup.py install

Visual Studio 2010 and later

Since Python 2.7 expects Visual Studio 2008 for setup.py to work with Visual Studio 2010 we need to run it from either the "Visual Studio Command Prompt (2010)" or "Windows SDK 7.1 Command Prompt" (or equivalent).

Also check if the VS90COMNTOOLS environment variable is set:

echo %VS90COMNTOOLS%

If not set the VS90COMNTOOLS to match VS100COMNTOOLS:

set VS90COMNTOOLS=%VS100COMNTOOLS%

Note the name of the environment variable differs per Visual Studio version.

Using Minimalist GNU for Windows (MinGW)

Not recommended due to possible ABI (Application Binary Interface) differences between Python and pytsk.

Creating a MSI

If you want to be able to manage the installation via "Programs and Features" in Windows you can create a MSI-based installer by running:

C:\Python27\python.exe setup.py bdist_msi

This will create a file equivalent to:

dist\pytsk-20160318.win32-py2.7.msi

Using Debian package tools (DEB)

To build pytsk using the Debian package tools make sure you have the following packages installed:

sudo apt-get install build-essential debhelper fakeroot python2.7-all-dev

Prepare the Debian packing files:

cp -rf dpkg debian

To build the Debian package change into the source directory and run:

dpkg-buildpackage -rfakeroot

This will create the following files in the parent directory:

python-pytsk3_20160318-1_amd64.deb
python3-pytsk3_20160318-1_amd64.deb

To install the pytsk Debian package run:

sudo dpkg -i python-pytsk3_20160318-1_amd64.deb

Using RedHat package tools (RPM)

To build pytsk using the RedHat package tools make sure you have the following packages installed:

yum install rpm-build python-devel libtalloc-devel

To build:

python2 setup.py bdist_rpm && python3 setup.py bdist_rpm

This will create several files in the dist sub directory including:

python-pytsk3-20160318-1.x86_64.rpm
python3-pytsk3-20160318-1.x86_64.rpm

To install the pytsk RedHat package run:

sudo rpm -ivh dist/python-pytsk3-20160318-1.x86_64.rpm

Using Mac OS X pkgbuild

Note that Mac OS X 10.11 (El Capitan) disallows installation in /usr by default, hence we use /usr/local

pytsk

To build pkg files run the following command from the build root directory:

tar xvfz pytsk-20160318.tgz 
cd pytsk-20160318/
ARCHFLAGS='-arch x86_64' python setup.py bdist
mkdir dist/tmp && cd dist/tmp && tar xfvz ../*gz && cd ../..
mkdir -p dist/tmp/usr/local/share/doc/pytsk3
cp LICENSE dist/tmp/usr/local/share/doc/pytsk3
pkgbuild --root dist/tmp --identifier com.github.py4n6.pytsk --version 20160318 --ownership recommended ../pytsk3-20160318.pkg
cd ..

To install the required pkg files run:

sudo installer -target / -pkg pytsk3-20160318.pkg