Skip to content

Commit d4c6ef7

Browse files
Add files via upload
1 parent 4e8b406 commit d4c6ef7

File tree

2 files changed

+336
-0
lines changed

2 files changed

+336
-0
lines changed

odoo.py

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/env python
2+
#----------------------------------------------------------
3+
# odoo cli
4+
#
5+
# To install your odoo development environement type:
6+
#
7+
# wget -O- https://raw.githubusercontent.com/odoo/odoo/8.0/odoo.py | python
8+
#
9+
# The setup_* subcommands used to boostrap odoo are defined here inline and may
10+
# only depends on the python 2.7 stdlib
11+
#
12+
# The rest of subcommands are defined in odoo/cli or in <module>/cli by
13+
# subclassing the Command object
14+
#
15+
#----------------------------------------------------------
16+
import os
17+
import re
18+
import sys
19+
import subprocess
20+
21+
GIT_HOOKS_PRE_PUSH = """
22+
#!/usr/bin/env python2
23+
import re
24+
import sys
25+
if re.search('github.com[:/]odoo/odoo.git$', sys.argv[2]):
26+
print "Pushing to /odoo/odoo.git is forbidden, please push to odoo-dev, use --no-verify to override"
27+
sys.exit(1)
28+
"""
29+
30+
def printf(f,*l):
31+
print "odoo:" + f % l
32+
33+
def run(*l):
34+
if isinstance(l[0], list):
35+
l = l[0]
36+
printf("running %s", " ".join(l))
37+
subprocess.check_call(l)
38+
39+
def git_locate():
40+
# Locate git dir
41+
# TODO add support for os.environ.get('GIT_DIR')
42+
43+
# check for an odoo child
44+
if os.path.isfile('odoo/.git/config'):
45+
os.chdir('odoo')
46+
47+
path = os.getcwd()
48+
while path != os.path.abspath(os.sep):
49+
gitconfig_path = os.path.join(path, '.git/config')
50+
if os.path.isfile(gitconfig_path):
51+
release_py = os.path.join(path, 'openerp/release.py')
52+
if os.path.isfile(release_py):
53+
break
54+
path = os.path.dirname(path)
55+
if path == os.path.abspath(os.sep):
56+
path = None
57+
return path
58+
59+
def cmd_setup_git():
60+
git_dir = git_locate()
61+
if git_dir:
62+
printf('git repo found at %s',git_dir)
63+
else:
64+
run("git", "init", "odoo")
65+
os.chdir('odoo')
66+
git_dir = os.getcwd()
67+
if git_dir:
68+
# push sane config for git < 2.0, and hooks
69+
#run('git','config','push.default','simple')
70+
# alias
71+
run('git','config','alias.st','status')
72+
# merge bzr style
73+
run('git','config','merge.commit','no')
74+
# pull let me choose between merge or rebase only works in git > 2.0, use an alias for 1
75+
run('git','config','pull.ff','only')
76+
run('git','config','alias.pl','pull --ff-only')
77+
pre_push_path = os.path.join(git_dir, '.git/hooks/pre-push')
78+
open(pre_push_path,'w').write(GIT_HOOKS_PRE_PUSH.strip())
79+
os.chmod(pre_push_path, 0755)
80+
# setup odoo remote
81+
run('git','config','remote.odoo.url','https://github.com/odoo/odoo.git')
82+
run('git','config','remote.odoo.pushurl','git@github.com:odoo/odoo.git')
83+
run('git','config','--add','remote.odoo.fetch','dummy')
84+
run('git','config','--unset-all','remote.odoo.fetch')
85+
run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/*')
86+
# setup odoo-dev remote
87+
run('git','config','remote.odoo-dev.url','https://github.com/odoo-dev/odoo.git')
88+
run('git','config','remote.odoo-dev.pushurl','git@github.com:odoo-dev/odoo.git')
89+
run('git','remote','update')
90+
# setup 8.0 branch
91+
run('git','config','branch.8.0.remote','odoo')
92+
run('git','config','branch.8.0.merge','refs/heads/8.0')
93+
run('git','checkout','8.0')
94+
else:
95+
printf('no git repo found')
96+
97+
def cmd_setup_git_dev():
98+
git_dir = git_locate()
99+
if git_dir:
100+
# setup odoo-dev remote
101+
run('git','config','--add','remote.odoo-dev.fetch','dummy')
102+
run('git','config','--unset-all','remote.odoo-dev.fetch')
103+
run('git','config','--add','remote.odoo-dev.fetch','+refs/heads/*:refs/remotes/odoo-dev/*')
104+
run('git','config','--add','remote.odoo-dev.fetch','+refs/pull/*:refs/remotes/odoo-dev/pull/*')
105+
run('git','remote','update')
106+
107+
def cmd_setup_git_review():
108+
git_dir = git_locate()
109+
if git_dir:
110+
# setup odoo-dev remote
111+
run('git','config','--add','remote.odoo.fetch','dummy')
112+
run('git','config','--unset-all','remote.odoo.fetch')
113+
run('git','config','--add','remote.odoo.fetch','+refs/heads/*:refs/remotes/odoo/*')
114+
run('git','config','--add','remote.odoo.fetch','+refs/tags/*:refs/remotes/odoo/tags/*')
115+
run('git','config','--add','remote.odoo.fetch','+refs/pull/*:refs/remotes/odoo/pull/*')
116+
117+
def setup_deps_debian(git_dir):
118+
debian_control_path = os.path.join(git_dir, 'debian/control')
119+
debian_control = open(debian_control_path).read()
120+
debs = re.findall('python-[0-9a-z]+',debian_control)
121+
debs += ["postgresql"]
122+
proc = subprocess.Popen(['sudo','apt-get','install'] + debs, stdin=open('/dev/tty'))
123+
proc.communicate()
124+
125+
def cmd_setup_deps():
126+
git_dir = git_locate()
127+
if git_dir:
128+
if os.path.isfile('/etc/debian_version'):
129+
setup_deps_debian(git_dir)
130+
131+
def setup_pg_debian(git_dir):
132+
cmd = ['sudo','su','-','postgres','-c','createuser -s %s' % os.environ['USER']]
133+
subprocess.call(cmd)
134+
135+
def cmd_setup_pg():
136+
git_dir = git_locate()
137+
if git_dir:
138+
if os.path.isfile('/etc/debian_version'):
139+
setup_pg_debian(git_dir)
140+
141+
def cmd_setup():
142+
cmd_setup_git()
143+
cmd_setup_deps()
144+
cmd_setup_pg()
145+
146+
def main():
147+
# regsitry of commands
148+
g = globals()
149+
cmds = dict([(i[4:],g[i]) for i in g if i.startswith('cmd_')])
150+
# if curl URL | python2 then use command setup
151+
if len(sys.argv) == 1 and __file__ == '<stdin>':
152+
cmd_setup()
153+
elif len(sys.argv) == 2 and sys.argv[1] in cmds:
154+
cmds[sys.argv[1]]()
155+
else:
156+
import openerp
157+
openerp.cli.main()
158+
159+
if __name__ == "__main__":
160+
main()
161+

setup.py

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
import re
6+
from glob import glob
7+
from setuptools import find_packages, setup
8+
from os.path import join, dirname
9+
10+
11+
execfile(join(dirname(__file__), 'openerp', 'release.py')) # Load release variables
12+
lib_name = 'openerp'
13+
14+
15+
def py2exe_datafiles():
16+
data_files = {}
17+
data_files['Microsoft.VC90.CRT'] = glob('C:\Microsoft.VC90.CRT\*.*')
18+
19+
for root, dirnames, filenames in os.walk('openerp'):
20+
for filename in filenames:
21+
if not re.match(r'.*(\.pyc|\.pyo|\~)$', filename):
22+
data_files.setdefault(root, []).append(join(root, filename))
23+
24+
import babel
25+
data_files['babel/localedata'] = glob(join(dirname(babel.__file__), 'localedata', '*'))
26+
others = ['global.dat', 'numbers.py', 'support.py', 'plural.py']
27+
data_files['babel'] = map(lambda f: join(dirname(babel.__file__), f), others)
28+
others = ['frontend.py', 'mofile.py']
29+
data_files['babel/messages'] = map(lambda f: join(dirname(babel.__file__), 'messages', f), others)
30+
31+
import pytz
32+
tzdir = dirname(pytz.__file__)
33+
for root, _, filenames in os.walk(join(tzdir, 'zoneinfo')):
34+
base = join('pytz', root[len(tzdir) + 1:])
35+
data_files[base] = [join(root, f) for f in filenames]
36+
37+
import docutils
38+
dudir = dirname(docutils.__file__)
39+
for root, _, filenames in os.walk(dudir):
40+
base = join('docutils', root[len(dudir) + 1:])
41+
data_files[base] = [join(root, f) for f in filenames if not f.endswith(('.py', '.pyc', '.pyo'))]
42+
43+
import passlib
44+
pl = dirname(passlib.__file__)
45+
for root, _, filenames in os.walk(pl):
46+
base = join('passlib', root[len(pl) + 1:])
47+
data_files[base] = [join(root, f) for f in filenames if not f.endswith(('.py', '.pyc', '.pyo'))]
48+
49+
return data_files.items()
50+
51+
52+
def py2exe_options():
53+
if os.name == 'nt':
54+
import py2exe
55+
return {
56+
'console': [
57+
{'script': 'odoo.py'},
58+
{'script': 'openerp-gevent'},
59+
{'script': 'openerp-server', 'icon_resources': [
60+
(1, join('setup', 'win32', 'static', 'pixmaps', 'openerp-icon.ico'))
61+
]},
62+
],
63+
'options': {
64+
'py2exe': {
65+
'skip_archive': 1,
66+
'optimize': 0, # Keep the assert running as the integrated tests rely on them.
67+
'dist_dir': 'dist',
68+
'packages': [
69+
'asynchat', 'asyncore',
70+
'commands',
71+
'dateutil',
72+
'decimal',
73+
'decorator',
74+
'docutils',
75+
'email',
76+
'encodings',
77+
'HTMLParser',
78+
'imaplib',
79+
'jinja2',
80+
'lxml', 'lxml._elementpath', 'lxml.builder', 'lxml.etree', 'lxml.objectify',
81+
'mako',
82+
'markupsafe',
83+
'mock',
84+
'openerp',
85+
'openid',
86+
'passlib',
87+
'PIL',
88+
'poplib',
89+
'psutil',
90+
'pychart',
91+
'pydot',
92+
'pyparsing',
93+
'pyPdf',
94+
'pytz',
95+
'reportlab',
96+
'requests',
97+
'select',
98+
'simplejson',
99+
'smtplib',
100+
'uuid',
101+
'vatnumber',
102+
'vobject',
103+
'win32service', 'win32serviceutil',
104+
'xlwt',
105+
'xml', 'xml.dom',
106+
'yaml',
107+
],
108+
'excludes': ['Tkconstants', 'Tkinter', 'tcl'],
109+
}
110+
},
111+
'data_files': py2exe_datafiles()
112+
}
113+
else:
114+
return {}
115+
116+
117+
setup(
118+
name='odoo',
119+
version=version,
120+
description=description,
121+
long_description=long_desc,
122+
url=url,
123+
author=author,
124+
author_email=author_email,
125+
classifiers=filter(None, classifiers.split('\n')),
126+
license=license,
127+
scripts=['openerp-server', 'openerp-gevent', 'odoo.py'],
128+
packages=find_packages(),
129+
package_dir={'%s' % lib_name: 'openerp'},
130+
include_package_data=True,
131+
install_requires=[
132+
'babel >= 1.0',
133+
'decorator',
134+
'docutils',
135+
'feedparser',
136+
'gevent',
137+
'Jinja2',
138+
'lxml', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
139+
'mako',
140+
'mock',
141+
'passlib',
142+
'pillow', # windows binary http://www.lfd.uci.edu/~gohlke/pythonlibs/
143+
'psutil', # windows binary code.google.com/p/psutil/downloads/list
144+
'psycogreen',
145+
'psycopg2 >= 2.2',
146+
'python-chart',
147+
'pydot',
148+
'pyparsing',
149+
'pypdf',
150+
'pyserial',
151+
'python-dateutil',
152+
'python-ldap', # optional
153+
'python-openid',
154+
'pytz',
155+
'pyusb >= 1.0.0b1',
156+
'pyyaml',
157+
'qrcode',
158+
'reportlab', # windows binary pypi.python.org/pypi/reportlab
159+
'requests',
160+
'simplejson',
161+
'unittest2',
162+
'vatnumber',
163+
'vobject',
164+
'werkzeug',
165+
'xlwt',
166+
],
167+
extras_require={
168+
'SSL': ['pyopenssl'],
169+
},
170+
tests_require=[
171+
'unittest2',
172+
'mock',
173+
],
174+
**py2exe_options()
175+
)

0 commit comments

Comments
 (0)