#!/bin/bash
[% c("var/set_default_env") -%]
distdir="/var/tmp/dist/[% project %]"
[% IF c("var/windows") -%]
  [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
[% ELSE -%]
  [% c("var/set_PTDIR_DOCSDIR") -%]
  mkdir -p $PTDIR
[% END -%]
mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf $rootdir/[% project %]-[% c('version') %].tar.gz
cd /var/tmp/build/[% project %]-[% c('version') %]
# Let's pretend we have the setup dependency already as we don't want to get
# it downloaded during building. Just pretending and thus avoiding another
# dependency should be fine here as txsocksx catches the exception due to
# missing __version__ and __sha__ .
mkdir vcversioner-1.14.1.1-py2.7.egg
[% IF c("var/windows") -%]
  pydir="$distdir/python"
  mkdir -p $pydir/Lib/site-packages
  export PYTHONPATH="$(winepath -w $pydir)\\Lib\\site-packages"
  $PYTHON setup.py install_lib --install-dir=$(winepath -w "$pydir/Lib/site-packages")
[% ELSE -%]
  export PYTHON=python2
  $PYTHON setup.py build --build-lib build
  cp -a build/txsocksx $PTDIR/
[% END -%]
cd $distdir
[% c('tar', {
        tar_src => [ '.' ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
