|
cat > "setup.py" << EOF |
|
# -*- coding: utf-8 -*- |
|
############################################################################## |
|
# |
|
# Copyright (C) 2013 GISCE-TI, S.L. |
|
# |
|
# This program is free software: you can redistribute it and/or modify |
|
# it under the terms of the GNU Affero General Public License as |
|
# published by the Free Software Foundation, either version 3 of the |
|
# License, or (at your option) any later version. |
|
# |
|
# This program is distributed in the hope that it will be useful, |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
# GNU Affero General Public License for more details. |
|
# |
|
# You should have received a copy of the GNU Affero General Public License |
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
# |
|
############################################################################## |
|
|
|
from os.path import join as pjoin |
|
import os |
|
import re |
|
import setuptools |
|
from datetime import datetime |
|
|
|
|
|
README_FILE = 'README.md' |
|
|
|
|
|
def get_readme_description(): |
|
if not os.path.exists(README_FILE): |
|
return '', '' |
|
with open(README_FILE, 'r') as readme: |
|
content = readme.read() |
|
short = content.split('\n')[1] |
|
return short, content |
|
|
|
|
|
def get_bzr_rev(): |
|
log = os.popen('bzr log --limit 1').read() |
|
revno = re.findall('revno: ([0-9]+)\n', log) |
|
if not revno: |
|
return '0' |
|
else: |
|
return revno[0] |
|
|
|
|
|
description, long_description = get_readme_description() |
|
|
|
|
|
install_requires = [ |
|
'openerp >= 7', |
|
] |
|
|
|
|
|
tests_require = [ |
|
'unittest2' |
|
] |
|
|
|
|
|
def openerp_addons_data(): |
|
r = {} |
|
for addon in openerp_package_dir(): |
|
addon_path = addon.split('.')[-1] |
|
for root, dirnames, filenames in os.walk(addon_path): |
|
for filename in filenames: |
|
if not re.match(r'.*(\.pyc|\.pyo|\.py|\~)$', filename): |
|
newroot = root.replace(addon_path, '', 1) |
|
newroot = newroot.replace(os.path.sep, '', 1) |
|
r.setdefault(addon, []).append(pjoin(newroot, filename)) |
|
return r |
|
|
|
|
|
def openerp_addons(): |
|
pkgs = [] |
|
for pkg in setuptools.find_packages(): |
|
pkgs.append('openerp.addons.%s' % pkg) |
|
return pkgs |
|
|
|
|
|
def openerp_package_dir(): |
|
pkg_dir = {} |
|
for pkg in setuptools.find_packages(): |
|
if '.' in pkg: |
|
continue |
|
pkg_dir['openerp.addons.%s' % pkg] = pkg |
|
return pkg_dir |
|
|
|
|
|
timestamp = datetime.now().strftime('%Y%m%d%H%M%S') |
|
|
|
|
|
setuptools.setup( |
|
name='$PACKAGE', |
|
version="1.0.%s-%s" % (get_bzr_rev(), timestamp), |
|
description=description, |
|
long_description=long_description, |
|
url="http://www.gisce.net", |
|
author="GISCE-TI, S.L.", |
|
author_email="[email protected]", |
|
license="AGPL-3", |
|
package_dir=openerp_package_dir(), |
|
packages=openerp_addons(), |
|
package_data=openerp_addons_data(), |
|
install_requires=install_requires, |
|
dependency_links=['http://nightly.openerp.com/7.0/nightly/src/'], |
|
tests_require=tests_require, |
|
) |