Skip to content

Commit

Permalink
Add build scripts fro win and osx, add patch_version command to setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed Apr 15, 2014
1 parent dc6ddcf commit b3e8ec9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/package-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cd deps
tar xf chromaprint-fpcalc-*.tar.gz
rm chromaprint-fpcalc-*.tar.gz
export PATH=`pwd`/`ls | grep chromaprint-fpcalc`:$PATH
cd ..

python2.7 setup.py patch_version --platform=osx
version=`python -c 'import picard; print picard.__version__'`

. e/bin/activate

rm -rf dist build locale
python2.7 setup.py clean
python2.7 setup.py build_ext -i
python2.7 setup.py build_locales -i
python2.7 setup.py py2app

cd dist
ditto -rsrc --arch x86_64 'MusicBrainz Picard.app' 'MusicBrainz Picard.tmp'
rm -r 'MusicBrainz Picard.app'
mv 'MusicBrainz Picard.tmp' 'MusicBrainz Picard.app'
hdiutil create -volname "MusicBrainz Picard $version" -srcfolder 'MusicBrainz Picard.app' -ov -format UDBZ MusicBrainz-Picard-$version.dmg
24 changes: 24 additions & 0 deletions scripts/package-win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set PATH=%PATH%;%WORKSPACE%;C:\MinGW\bin;C:\Python27;C:\Python27\Scripts;"C:\Program Files\7-Zip"
call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"

del installer\*.exe

copy /Y "C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\msvcr90.dll" .
copy /Y "C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\msvcp90.dll" .

7z e -odeps deps\chromaprint-fpcalc-*.zip
copy /Y deps\fpcalc.exe .

REM virtualenv --system-site-packages e
set PATH=%WORKSPACE%\e\scripts;%PATH%

pip install -U discid
pip install -U mutagen

python setup.py patch_version --platform=win

rmdir /S /Q dist
python setup.py clean
python setup.py build_ext -i
python setup.py build_locales -i
python setup.py bdist_nsis
28 changes: 28 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import datetime
import glob
import os
import re
Expand Down Expand Up @@ -535,6 +536,32 @@ def write_utf8(s, **kwargs):
len(attributes)))


class picard_patch_version(Command):
description = "Update PICARD_BUILD_VERSION_STR for daily builds"
user_options = [
('platform=', 'p', "platform for the build version, ie. osx or win"),
]

def initialize_options(self):
self.platform = 'unknown'

def finalize_options(self):
pass

def run(self):
self.patch_version('picard/__init__.py')

def patch_version(self, filename):
regex = re.compile(r'^PICARD_BUILD_VERSION_STR\s*=.*$', re.MULTILINE)
with open(filename, 'r+b') as f:
source = f.read()
build = self.platform + '_' + datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S')
patched_source = regex.sub('PICARD_BUILD_VERSION_STR = "%s"' % build, source)
f.seek(0)
f.write(patched_source)
f.truncate()


def cflags_to_include_dirs(cflags):
cflags = cflags.split()
include_dirs = []
Expand Down Expand Up @@ -583,6 +610,7 @@ def _picard_get_locale_files():
'update_constants': picard_update_constants,
'get_po_files': picard_get_po_files,
'regen_pot_file': picard_regen_pot_file,
'patch_version': picard_patch_version,
},
'scripts': ['scripts/picard'],
}
Expand Down

0 comments on commit b3e8ec9

Please sign in to comment.