forked from urnest/urnest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOdinfile
284 lines (250 loc) · 8.68 KB
/
Odinfile
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# install source (static source, generated C++ and omniidl_be) into $INST_SRC,
# install tools (hcp-split etc) into $INST_BIN
# ... note omnicxy/{cxy,omniidl_be} are moved up a level so they are in
# $INST_SRC/{cxy,omniidl_be}
%install!==(.)+cmd=(%installer.sh) (%hcp-gen.tar) (%idl-gen.tar) (%tools.tar):run
#build and run all tests
%all==%all.tree:leaves
%all.tree==<<
mypy-plugins%all
xju%all.tree
omnicxy%all.tree
hcp%all.tree
dion%all.tree
xwl%all.tree:leaves
%tags
#example%all.tree
%cxx-opts==<<
+inc_sp=(omnicxy)
+inc_sp=(.)
+inc_sp=(%hcp-gen)
+inc_sp=(%idl-gen)
+inc_sp=(/usr/include/freetype2)
+ld_flags=-lpthread
%idl-opts==<<
+inc_sp=(.)
+inc_sp=(omnicxy)
+cxy='-exju::Exception=xju/Exception.hh'
+hcp-split=(hcp%hcp-split)
%hcp-opts==<<
+G +hcp-split=(hcp%hcp-split)
%hcp-gen==Odinfile%hcp-gen.virdir_spec:vir_dir
%hcp-gen.virdir_spec == <<
%xju==./xju/Odinfile%hcp-gen
%hcp==./hcp/Odinfile%hcp-gen
%cxy==./omnicxy/cxy/Odinfile%hcp-gen
%dion==./dion/Odinfile%hcp-gen
%example==./example/Odinfile%hcp-gen
%idl-gen==Odinfile%idl-gen.virdir_spec:vir_dir
%idl-gen.virdir_spec == <<
%hcp==./hcp/Odinfile%idl-gen
%cxy==./omnicxy/cxy/Odinfile%idl-gen
%xju==./xju/Odinfile%idl-gen
%tags==%all.list-of-tags+(%tags-opts):merged-tags
%tags-opts==<<
+hcp-tags-merge=(hcp/hcp-tags-merge)
+hcp-tags=(hcp%hcp-tags)
%all.list-of-tags==<<
.+(%tags-opts):merged-tags
xju%tags
hcp%tags
omnicxy/cxy%tags
dion%tags
%hcp-gen.tar==()+cmd=(%vir-tree-tar.sh) (%hcp-gen)+need=(%hcp-gen:vir_tree_list):stdout
%idl-gen.tar==()+cmd=(%vir-tree-tar.sh) (%idl-gen)+need=(%idl-gen:vir_tree_list):stdout
%tools.tar==()+cmd=(%vir-tree-tar.sh) (%tools-inst-bin.vir_dir)+need=(%tools-inst-bin.vir_dir:vir_tree_list):stdout
%vir-tree-tar.sh == ! <<
#!/bin/sh
cd "$1" &&
tar chf - .
%tools-inst-bin.vir_dir == %tools-inst-bin.vir_dir_spec:vir_dir
%tools-inst-bin.vir_dir_spec == <<
%hcp-split==hcp%hcp-split
%hcp-parse-file==hcp%hcp-parse-file
%hcp-what-is-at==hcp%hcp-what-is-at
%hcp-tags==hcp%hcp-tags
%tags-opts==hcp/hcp-tags-merge
%hcp-scope-at==hcp%hcp-scope-at
%hcp-map-to-source==hcp%hcp-map-to-source
%hcp-remove-throw-clauses==hcp%hcp-remove-throw-clauses
%tag-lookup-service==hcp/tags%tag-lookup-service
%hcp-import-symbol-at==hcp/tags%hcp-import-symbol-at
%hcp-find-def==hcp/tags%hcp-find-def
%hcp-symbol-completions==hcp/tags%hcp-symbol-completions
%hcp-symbol-at==hcp/tags%hcp-symbol-at
%cosnaming-client==omnicxy/cosnaming-client
%monitor-ntp-sync==xju/linux/ntpd/monitor-ntp-sync
%monitor-disk-space==xju/linux/disk-space/monitor-disk-space
%monitor-logins==xju/linux/wtmp/monitor-logins
%installer.sh == ! <<
#!/bin/sh
set -x &&
hcpgentar="$1" && shift &&
idlgentar="$1" && shift &&
toolstar="$1" && shift &&
sourcedir="$(pwd)" &&
if ! test -n "$INST_BIN"
then
echo "ERROR: set INST_BIN environment variable to tools destination directory, e.g. /usr/local/bin" &&
false
fi &&
if ! test -n "$INST_SRC"
then
echo "ERROR: set INST_SRC environment variable to header destination directory, e.g. /usr/local/include" &&
false
fi &&
test -r "$hcpgentar" &&
test -r "$idlgentar" &&
test -r "$toolstar" &&
test -r "$sourcedir" &&
test -d "$sourcedir" &&
cat "$toolstar" | (cd "$INST_BIN" && tar xvf - ) &&
cat "$idlgentar" | (cd "$INST_SRC" && tar xvf - ) &&
cat "$hcpgentar" | (cd "$INST_SRC" && tar xvf - ) &&
sources=$(cd "$sourcedir" && find xju hcp \( -name __pycache__ -prune \) -o \( -name '*.idl' -o -name '*.hh' -o -name '*.cc' -o -name '*.h' -o -name '*.py' -o -name '*.html' -o -name '*.js' -o -name '*.css' \) -print ) &&
(cd "$sourcedir" && tar cf - $sources) | (cd "$INST_SRC" && tar xvf - ) &&
sources=$(cd "$sourcedir/omnicxy" && find cxy -name '*.idl' -o -name '*.hh' -o -name '*.cc' -o -name '*.h' && find omniidl_be -name '*.py' -o -name '*.sh' ) &&
(cd "$sourcedir/omnicxy" && tar cf - $sources) | (cd "$INST_SRC" && tar xvf - ) &&
headers=$(find "$INST_SRC" -name '*.hh' -print) &&
"$INST_BIN/hcp-tags" $headers > "$INST_SRC/hcp-tags.json" &&
set +x &&
echo "Installation Successfull"
%publish-xju-to-pypi! ==<<
(/tmp)+cmd=(%publish-xju-to-pypi.sh)+cmd=(%python3-xju.whl)+cmd=(%python3-xju-twine.tar.gz):run
%publish-xju-to-pypi.sh==!<<
#!/bin/sh -ex
whl="$1"
tgz="$2"
rm -rf dist && mkdir dist
cp $whl dist/xju-3.2.1-py3-none-any.whl
cp $tgz dist/xju-3.2.1.tar.gz
twine check dist/*
twine upload --verbose dist/*
%python3-xju.whl == %python3-xju-whl.exec.files+member='xju-3.2.1/dist/xju-3.2.1-py3-none-any.whl':extract_file
# you'd think that the .tar.gz that the .whl was built from would be exactly the right thing to
# put on pypi...
%python3-xju.tar.gz == %python3-xju-tgz.exec.files+member='xju-3.2.1.tar.gz':extract_file
# ... but no it needs the .tar.gz that it created when it created the wheel. It makes no sense
%python3-xju-twine.tar.gz == %python3-xju-whl.exec.files+member='xju-3.2.1/dist/xju-3.2.1.tar.gz':extract_file
%python3-xju-tgz.exec.files==()+cmd=(%build-python3-xju-tgz.sh)+cmd=(.) (MIT-LICENCE) (README.py.rst) '3.2.1'+need=(xju%pytest.tree:leaves) +need=(xju/cmc%all) +need=(mypy-plugins%all) :exec.files
%python3-xju==()+cmd=(%build-python3-xju.sh)+cmd=(.) (MIT-LICENCE) (README.py.rst) '3.2.1'+need=(xju%pytest.tree:leaves) +need=(xju/cmc%all):exec.files
%python3-xju-whl.exec.files==%build-python3-xju-whl.sh+cmd=(%build-python3-xju-whl.sh)+cmd=(%python3-xju.tar.gz):exec.files
%build-python3-xju-whl.sh==!<<YYYY
#!/bin/sh
set -ex
tgz="$1"
tar xzvf $tgz
cd xju-3.2.1
python3 -m build -n
YYYY
%build-python3-xju-tgz.sh==!<<XXXX
#!/bin/sh
set -ex
src_dir="$1"
licence="$2"
readme="$3"
rev="$4"
mkdir -p xju-$rev/src
(
cd $src_dir
tar cf - xju/*.py xju/*.py.test xju/cmc/*.py xju/cmc/*.py.test xju/cmc/io/*.py xju/cmc/io/*.py.test
) |
(cd xju-$rev/src && tar xvf - )
cp $src_dir/mypy-plugins/*mypy_plugin.py xju-$rev/src/xju
touch xju-$rev/src/xju/py.typed
tests=$(cd xju-$rev/src/xju && find . -name '*.py.test')
tests_package_data=$(for t in $tests; do echo -n "\"$t\","; done)
cat > xju-$rev/pyproject.toml <<EOF
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "xju"
version = "$rev"
description = "xju library"
readme = "README.rst"
authors = [{ name = "Trevor Taylor"}]
license = { file = "MIT-LICENCE" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable"
]
requires-python = ">=3.11"
[project.urls]
Homepage = "https://github.com/urnest/urnest"
[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = ["xju","xju.*","xju.cmc.*"] # package names should match these glob patterns (["*"] by default)
exclude = [] # exclude packages matching these glob patterns (empty by default)
namespaces = true # to disable scanning PEP 420 namespaces (true by default)
[tool.setuptools.package-data]
xju = [ $tests_package_data "py.typed"]
EOF
cp $licence xju-$rev/MIT-LICENCE
cp $readme xju-$rev/README.rst
tar czf xju-$rev.tar.gz xju-$rev
XXXX
# alas below robust way of creating a wheel doesn't suit the really dumb tools on the
# internet, which insist on having a pyproject.toml, so we have to use pyproject.toml
# as above. pyproject.toml is yet another undocumented, unusable, ill-conceived piece
# of crap, but hey that's how we do things these days
%build-python3-xju.sh==!<<XXXX
#!/bin/sh
set -ex
src_dir="$1"
licence="$2"
readme="$(cat $3)"
rev="$4"
mkdir xju-$rev
(
cd $src_dir &&
tar cf - xju/*.py xju/*.py.test xju/cmc/*.py xju/cmc/*.py.test xju/cmc/io/*.py xju/cmc/io/*.py.test
) |
(cd xju-$rev && tar xvf - )
touch xju-$rev/xju/py.typed
mkdir xju-$rev/xju-$rev.dist-info
cat > xju-$rev/xju-$rev.dist-info/METADATA <<EOF
Metadata-Version: 2.1
Name: xju
Version: $rev
Summary: xju library
Author: Trevor Taylor
Project-URL: Homepage, https://github.com/urnest/urnest
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.10
License-File: LICENCE
Description-Content-Type: text/x-rst
$readme
EOF
cp xju-$rev/xju-$rev.dist-info/METADATA xju-$rev/PKG-INFO
cp $licence xju-$rev/xju-$rev.dist-info/LICENCE
cat > xju-$rev/xju-$rev.dist-info/WHEEL <<EOF
Wheel-Version: 1.0
Generator: sh
Root-Is-Purelib: true
Tag: py3-none-any
EOF
cat > xju-$rev/xju-$rev.dist-info/top_level.txt <<EOF
xju
EOF
(
cd xju-$rev
find xju xju-$rev.dist-info -type f -print |
while read n
do
sum=$(sha256sum $n)
sum=$(echo $sum | awk '{print $1}')
size=$(cat $n | wc -c)
echo "$n,sha256=$sum,$size"
done > RECORD
echo "xju-$rev.dist-info/RECORD,," >> RECORD
mv RECORD xju-$rev.dist-info/
zip -r ../xju-$rev-py3-none-any.whl xju xju-$rev.dist-info
)
tar czf xju-$rev.tar.gz xju-$rev
XXXX