This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dodo.py
147 lines (116 loc) · 4.79 KB
/
dodo.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# TODO:
# - tmp dirs
import os
import doit
from doit import action
from pyct import * # noqa
############################################################
# TODO: remove if project is updated to use pyctdev
miniconda_url = {
"Windows": "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe",
"Linux": "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh",
"Darwin": "https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh"
}
def task_download_miniconda():
import platform
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
url = miniconda_url[platform.system()]
miniconda_installer = url.split('/')[-1]
def download_miniconda(targets):
urlretrieve(url,miniconda_installer)
return {'targets': [miniconda_installer],
'uptodate': [True], # (as has no deps)
'actions': [download_miniconda]}
############################################################
example = {
'name':'example',
'long':'example',
'type':str,
'default':'pkg_depend'
}
example_pkgname = {
'name':'example_pkgname',
'long':'example-pkgname',
'type':str,
'default':''
}
from distutils.dir_util import copy_tree
def task_copy_example_project():
def copy_example(example):
from_ = os.path.join(doit.get_initial_workdir(), "examples", example)
copy_tree(from_,'.')
return {
'params':[example],
'actions':[(copy_example,),]
}
def task_git_init():
return {
'actions':[
action.CmdAction('git init && git add . && git commit -m "init" && git tag -a v0.0.1 -m "one" && echo two > two && git add two && git commit -m "two"')
]
}
def task_get_git_version():
return {'actions': [action.CmdAction('git describe --long',save_out='git_version')]}
def _x(example,example_pkgname):
# more param computing :(
return example_pkgname if example_pkgname!='' else example
# TODO: this task - like develop install below - should be done in a
# throwaway environment. Should probably just use tox here too.
def task_verify_installed_version():
return {
'getargs': {'git_version': ('get_git_version','git_version')},
'uptodate': [False],
'params': [example,example_pkgname],
'actions':[
action.CmdAction(
lambda example,example_pkgname: 'mkdir /tmp/9k && cd /tmp/9k && tmpverify %s'%_x(example,example_pkgname) +' %(git_version)s'),
]
}
# TODO: split up
def task_original_script():
env1 = os.environ.copy()
shared_packages = os.path.join(doit.get_initial_workdir(), "dist")
env1["PIP_FIND_LINKS"] = shared_packages
env2 = os.environ.copy()
env2['PYTHONPATH'] = os.getcwd() # TODO win
return {
'getargs': {'git_version': ('get_git_version','git_version')},
'params': [example,example_pkgname],
'actions':[
# 1. verify package generation & installation
action.CmdAction('tox -e py -- %(git_version)s',env=env1),
# dev install, then...
# TODO: need prerelease param just now; remove pre & index urls after release
action.CmdAction('pip install -f ' + shared_packages + ' --pre --index-url=https://test.pypi.org/simple/ --extra-index-url=https://pypi.org/simple -e .',env=env2),
# 2. ...verify in git repo (TODO: could just be "tmpverify %(example)s", I think)
action.CmdAction(lambda example,example_pkgname: 'python '+ _x(example,example_pkgname)+'/tests/__init__.py '+_x(example,example_pkgname),env=env2),
# 3. ...verify outside git repo
action.CmdAction(lambda example,example_pkgname: 'mkdir /tmp/9k && cd /tmp/9k && tmpverify '+_x(example,example_pkgname) +' %(git_version)s',env=env2),
# TODO: should be some kind of clean up option
action.CmdAction(lambda example,example_pkgname: 'pip uninstall -y '+_x(example,example_pkgname))
]
}
def task_check_dirty_package_name():
# TODO: test should be less bash
return {
'actions':[
'echo "#dirty" >> setup.py',
'git describe --dirty --long',
'python setup.py sdist',
'python -c "import os,glob; assert len(glob.glob(\'dist/*+g*.dirty.tar.gz\'))==1, os.listdir(\'dist\')"',
]}
def task_check_dirty_fails_conda_package():
# TODO: test should be less bash
return {
'actions':[
'echo "#dirty" >> setup.py',
'git describe --dirty --long',
'! conda build conda.recipe > conda-dirty-check 2>&1',
'grep "Error: bad character \'-\' in package/version" conda-dirty-check'
],
'teardown':[
'python -c "print(open(\'conda-dirty-check\').read())"'
]}