From 92b9905ede2c855bef8ff1cb8299b78e72cd98c3 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Wed, 23 May 2012 07:44:11 +0200 Subject: [PATCH] Haarcascades included into dist repo, for use with the executable. Input data to be removed from github (and included only in archives) --- .gitignore | 3 ++- MANIFEST.in | 3 ++- setup.py | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1ad9605..3e626e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc -data/output/* +data/* build dist +MANIFEST \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 2d7437e..49e0598 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ recursive-include test *.py recursive-include data\input\sample * -recursive-include data\output \ No newline at end of file +recursive-include data\output +recursive-include facemovie\haarcascades *.xml \ No newline at end of file diff --git a/setup.py b/setup.py index 23167bb..0209ad8 100644 --- a/setup.py +++ b/setup.py @@ -5,15 +5,46 @@ Created on 19 avr. 2012 ''' # creating executable here from distutils.core import setup -import py2exe, sys, os +import sys +import os +import glob + +import py2exe + import facemovie sys.argv.append('py2exe') +def find_data_files(source,target,patterns): + """Locates the specified data-files and returns the matches + in a data_files compatible format. + + source is the root of the source data tree. + Use '' or '.' for current directory. + target is the root of the target data tree. + Use '' or '.' for the distribution directory. + patterns is a sequence of glob-patterns for the + files you want to copy. + """ + if glob.has_magic(source) or glob.has_magic(target): + raise ValueError("Magic not allowed in src, target") + ret = {} + for pattern in patterns: + pattern = os.path.join(source,pattern) + for filename in glob.glob(pattern): + if os.path.isfile(filename): + targetpath = os.path.join(target,os.path.relpath(filename,source)) + path = os.path.dirname(targetpath) + ret.setdefault(path,[]).append(filename) + return sorted(ret.items()) + # Utility function to read the README file. def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() +haar_files = find_data_files('facemovie','',['haarcascades/*.xml']) +print haar_files + setup( name = "Facemovie", version = "0.4", @@ -25,7 +56,7 @@ setup( url = "https://github.com/jlengrand/FaceMovie", download_url = "https://github.com/jlengrand/FaceMovie", # FIXME : To be updated packages=['facemovie', 'facemovie.lib', 'facemovie.haarcascades'], - package_data={'facemovie': ['haarcascades/*.xml']}, # Adds xml files to the lib + #package_data={'facemovie': ['haarcascades/*.xml']}, # Adds xml files to the lib long_description=read('README.markdown'), classifiers=[ "Development Status :: 3 - Alpha", @@ -38,6 +69,7 @@ setup( "Programming Language :: Python :: 2 :: Only", ], platforms ={"Linux"}, + data_files = haar_files, options = {'py2exe': {'bundle_files': 1, 'includes': ['numpy'] } }, console=['facemovie/Facemoviefier.py'], zipfile = None,