forked from NaN-tic/tryton-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pypi.py
46 lines (34 loc) · 1.36 KB
/
pypi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import os
from invoke import task, Collection, run
from .scm import get_repo
from .utils import read_config_file
README_MSG = "\nNotes\n"
README_MSG+= "=====\n\n"
README_MSG+= "This packages includes some backports and bugfixes from original.\n"
README_MSG+= "Find it at: http://bitbucket.org/nantic/trytond-patches\n"
@task()
def prepare(config, unstable=True):
Config = read_config_file(config, unstable=unstable)
for section in Config.sections():
repo = get_repo(section, Config)
revision = repo['revision']
path = repo['path']
setup_file = os.path.join(path, 'setup.py')
run('sed -i "s/trytond_/nantic_/g" %s' % setup_file)
run('sed -i "s/=version,/=version+\'.%s\',/g" %s'%
(revision, setup_file))
run('sed -i "/download_url=/d" %s' % setup_file)
readme_file = os.path.join(path, 'README')
run('echo "%s" >> %s' % (README_MSG, readme_file))
@task()
def dist(pypi, config, unstable=True):
Config = read_config_file(config, unstable=unstable)
for section in Config.sections():
repo = get_repo(section, Config)
pypi = repo['pypi'] or 'nantic'
path = repo['path']
run('cd %s; python setup.py sdist upload -r %s' % (path, pypi))
PypiCollection = Collection()
PypiCollection.add_task(prepare)
PypiCollection.add_task(dist)