pyven 117__tar.gz → 119__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyven-117 → pyven-119}/PKG-INFO +4 -4
- {pyven-117 → pyven-119}/pyven/Dockerfile.aridt +2 -1
- {pyven-117 → pyven-119}/pyven/bdist.py +8 -2
- {pyven-117 → pyven-119}/pyven/checks.py +12 -10
- {pyven-117 → pyven-119}/pyven/container.py +4 -3
- pyven-119/pyven/execcheck.py +23 -0
- {pyven-117 → pyven-119}/pyven/files.py +2 -2
- {pyven-117 → pyven-119}/pyven/licheck.py +2 -2
- {pyven-117 → pyven-119}/pyven/pipify.py +10 -8
- {pyven-117 → pyven-119}/pyven/projectinfo.arid +7 -3
- {pyven-117 → pyven-119}/pyven/projectinfo.py +25 -12
- pyven-119/pyven/release.arid +8 -0
- pyven-119/pyven/release.py +178 -0
- {pyven-117 → pyven-119}/pyven/tryinstall.py +4 -7
- {pyven-117 → pyven-119}/pyven.egg-info/PKG-INFO +4 -4
- {pyven-117 → pyven-119}/pyven.egg-info/requires.txt +3 -3
- {pyven-117 → pyven-119}/setup.py +2 -2
- pyven-117/pyven/execcheck.py +0 -21
- pyven-117/pyven/release.arid +0 -10
- pyven-117/pyven/release.py +0 -201
- {pyven-117 → pyven-119}/README.md +0 -0
- {pyven-117 → pyven-119}/pyven/README.md.aridt +0 -0
- {pyven-117 → pyven-119}/pyven/__init__.py +0 -0
- {pyven-117 → pyven-119}/pyven/functions.py +0 -0
- {pyven-117 → pyven-119}/pyven/mainmodules.py +0 -0
- {pyven-117 → pyven-119}/pyven/metacheck.py +0 -0
- {pyven-117 → pyven-119}/pyven/minreqs.py +0 -0
- {pyven-117 → pyven-119}/pyven/nlcheck.py +0 -0
- {pyven-117 → pyven-119}/pyven/patchpolicy.py +0 -0
- {pyven-117 → pyven-119}/pyven/pyproject.toml.aridt +0 -0
- {pyven-117 → pyven-119}/pyven/setup.py.aridt +0 -0
- {pyven-117 → pyven-119}/pyven/setuptools.arid +0 -0
- {pyven-117 → pyven-119}/pyven/sourceinfo.py +0 -0
- {pyven-117 → pyven-119}/pyven/tasks.py +0 -0
- {pyven-117 → pyven-119}/pyven/tests/__init__.py +0 -0
- {pyven-117 → pyven-119}/pyven/util.py +0 -0
- {pyven-117 → pyven-119}/pyven.egg-info/SOURCES.txt +0 -0
- {pyven-117 → pyven-119}/pyven.egg-info/dependency_links.txt +0 -0
- {pyven-117 → pyven-119}/pyven.egg-info/entry_points.txt +0 -0
- {pyven-117 → pyven-119}/pyven.egg-info/top_level.txt +0 -0
- {pyven-117 → pyven-119}/setup.cfg +0 -0
{pyven-117 → pyven-119}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pyven
|
|
3
|
-
Version:
|
|
3
|
+
Version: 119
|
|
4
4
|
Summary: Manage development of multiple Python projects
|
|
5
5
|
Home-page: https://pypi.org/project/pyven/
|
|
6
6
|
Author: Homsar
|
|
@@ -8,10 +8,10 @@ Author-email: homsar@foyono.com
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: aridity>=85
|
|
10
10
|
Requires-Dist: diapyr>=31
|
|
11
|
-
Requires-Dist: foyndation>=
|
|
12
|
-
Requires-Dist: lagoon>=
|
|
11
|
+
Requires-Dist: foyndation>=18
|
|
12
|
+
Requires-Dist: lagoon>=64
|
|
13
13
|
Requires-Dist: packaging>=25
|
|
14
|
-
Requires-Dist: pydoc-markdown>=
|
|
14
|
+
Requires-Dist: pydoc-markdown>=4.8.2
|
|
15
15
|
Requires-Dist: roman>=5
|
|
16
16
|
Requires-Dist: setuptools>=44.1.1
|
|
17
17
|
Requires-Dist: twine>=1.15.0
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
FROM python:$(pyversiontag)
|
|
2
|
-
RUN $'[
|
|
2
|
+
RUN $'[pip install uv && \
|
|
3
|
+
mkdir -pv /etc/apt/keyrings && \
|
|
3
4
|
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
|
|
4
5
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list && \
|
|
5
6
|
apt-get update && \
|
|
@@ -3,7 +3,7 @@ from glob import iglob
|
|
|
3
3
|
from shutil import copy2, rmtree
|
|
4
4
|
from subprocess import CalledProcessError, check_call
|
|
5
5
|
from tempfile import mkdtemp
|
|
6
|
-
import logging, os
|
|
6
|
+
import json, logging, os, re
|
|
7
7
|
|
|
8
8
|
log = logging.getLogger(__name__)
|
|
9
9
|
distdir = 'dist'
|
|
@@ -12,14 +12,20 @@ def main():
|
|
|
12
12
|
logging.basicConfig(format = "<%(levelname)s> %(message)s", level = logging.DEBUG)
|
|
13
13
|
parser = ArgumentParser()
|
|
14
14
|
parser.add_argument('--plat', required = True)
|
|
15
|
+
parser.add_argument('--accepttags', required = True, type = json.loads)
|
|
15
16
|
args = parser.parse_args()
|
|
17
|
+
acceptimpls = {f"cp{re.sub('[.]', '', t)}" for t in args.accepttags}
|
|
16
18
|
holder = mkdtemp()
|
|
17
19
|
try:
|
|
18
20
|
for pip in sorted(iglob('/opt/python/cp3*/bin/pip')):
|
|
19
21
|
compatibility = pip.split(os.sep)[3]
|
|
22
|
+
impl = compatibility.split('-')[0]
|
|
23
|
+
if impl not in acceptimpls:
|
|
24
|
+
log.info("Skip untested implementation: %s", impl)
|
|
25
|
+
continue
|
|
20
26
|
log.info("Make wheel(s) for implementation-ABI: %s", compatibility)
|
|
21
27
|
try:
|
|
22
|
-
check_call([pip, '--no-cache-dir', 'wheel', '--no-deps', '-w', holder, '.'])
|
|
28
|
+
check_call([pip, '--no-cache-dir', 'wheel', '-v', '--only-binary', ':all:', '--no-deps', '-w', holder, '.'])
|
|
23
29
|
except CalledProcessError:
|
|
24
30
|
log.warning('Skip compatibility:', exc_info = True)
|
|
25
31
|
continue
|
|
@@ -20,7 +20,7 @@ from subprocess import DEVNULL
|
|
|
20
20
|
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
|
21
21
|
from urllib.error import HTTPError
|
|
22
22
|
from urllib.parse import unquote
|
|
23
|
-
from venvpool import
|
|
23
|
+
from venvpool import CompactPool
|
|
24
24
|
from xml.sax.saxutils import escape as xml_escape
|
|
25
25
|
import xml.etree.ElementTree as ET, logging, os, re, sys
|
|
26
26
|
|
|
@@ -48,7 +48,7 @@ def _runcheck(variant, check, *args):
|
|
|
48
48
|
|
|
49
49
|
class EveryVersion:
|
|
50
50
|
|
|
51
|
-
def __init__(self, info, siblings, userepo, noseargs, docker, transient):
|
|
51
|
+
def __init__(self, info, siblings, userepo, noseargs, docker, transient, testregex):
|
|
52
52
|
self.files = Files(info.projectdir)
|
|
53
53
|
self.info = info
|
|
54
54
|
self.siblings = siblings
|
|
@@ -56,6 +56,7 @@ class EveryVersion:
|
|
|
56
56
|
self.noseargs = noseargs
|
|
57
57
|
self.docker = docker
|
|
58
58
|
self.transient = transient
|
|
59
|
+
self.testmatch = re.compile(f"(?:{testregex})_").match
|
|
59
60
|
|
|
60
61
|
def allchecks(self, exclude = ()):
|
|
61
62
|
for check in self.licheck, self.nlcheck, self.execcheck, self.metacheck, self.pyflakes, self.nose, self.readme, self.github, self.linktree, self.wiki:
|
|
@@ -90,7 +91,7 @@ class EveryVersion:
|
|
|
90
91
|
for path in self.files.pypaths if os.path.relpath(path, self.files.root) not in excludes]
|
|
91
92
|
def pyflakes():
|
|
92
93
|
if paths:
|
|
93
|
-
with
|
|
94
|
+
with CompactPool().readonly(SimpleInstallDeps(['pyflakes>=3.2'])) as venv:
|
|
94
95
|
venv.run('check_call', [], 'pyflakes', paths)
|
|
95
96
|
_runcheck(3, pyflakes)
|
|
96
97
|
|
|
@@ -122,26 +123,26 @@ class EveryVersion:
|
|
|
122
123
|
upstream_devel_packages = list(self.info.config.upstream.devel.packages)
|
|
123
124
|
upstream_devel_scripts = list(self.info.config.upstream.devel.scripts) if self.userepo else []
|
|
124
125
|
# TODO: Facility to freeze test requirements graph.
|
|
125
|
-
with InstallDeps(self.info, ('
|
|
126
|
+
with InstallDeps(self.info, (('pyvenose', *self.info.config.test.requires),), self.siblings, _localrepo(), self.userepo) as installdeps:
|
|
126
127
|
reportsdir = self.info.projectdir / 'var' / '3'
|
|
127
128
|
reportsdir.mkdir(exist_ok = True, parents = True)
|
|
128
129
|
xmlpath = reportsdir / 'nosetests.xml'
|
|
129
130
|
statspath = reportsdir / 'stats.dat'
|
|
130
|
-
testpaths = self.files.testpaths([doctestpath], xmlpath)
|
|
131
|
+
testpaths = self.files.testpaths(self.testmatch, [doctestpath], xmlpath)
|
|
131
132
|
if self.docker:
|
|
132
133
|
coveragepath = self.info.projectdir / '.coverage'
|
|
133
134
|
with bgcontainer('-v', "{0}:{0}".format('/var/run/docker.sock'), '--network', 'host', '-v', f"{os.path.abspath(self.info.projectdir)}:{Container.workdir}", pyimage(self.info.pyversiontags[0], upstream_devel_packages, upstream_devel_scripts, *installdeps.corereqslayers())) as container:
|
|
134
135
|
container.cp(installdeps.workspace, 'installdeps')
|
|
135
136
|
container.installasuser(installdeps.containerrequires())
|
|
136
137
|
cpath = lambda p: os.path.relpath(p, self.info.projectdir).replace(os.sep, '/')
|
|
137
|
-
status = container.inworkdir.
|
|
138
|
+
status = container.inworkdir.pyvenose[print](
|
|
138
139
|
*self.basenoseargs, '--xunit-file', cpath(xmlpath), '--cprofile-stats-file', cpath(statspath),
|
|
139
140
|
*chain.from_iterable(['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), *map(cpath, testpaths), *self.noseargs,
|
|
140
141
|
check = False)
|
|
141
142
|
else:
|
|
142
143
|
coveragepath = Path('.coverage')
|
|
143
|
-
with
|
|
144
|
-
status = venv.run('call', installdeps.localreqs, '
|
|
144
|
+
with CompactPool().readonlyortransient[self.transient](installdeps) as venv:
|
|
145
|
+
status = venv.run('call', installdeps.localreqs, 'pyvenose.pyvenose', [
|
|
145
146
|
*self.basenoseargs, '--xunit-file', xmlpath, '--cprofile-stats-file', statspath,
|
|
146
147
|
*chain.from_iterable(['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), *map(str, testpaths), *self.noseargs,
|
|
147
148
|
])
|
|
@@ -160,7 +161,7 @@ class EveryVersion:
|
|
|
160
161
|
def getpydoc(mainmodules):
|
|
161
162
|
with TemporaryDirectory() as pydocparent:
|
|
162
163
|
pydocdir = os.path.join(pydocparent, 'project')
|
|
163
|
-
copytree(self.info.projectdir, pydocdir, ignore = ignore_patterns('test_*'))
|
|
164
|
+
copytree(self.info.projectdir, pydocdir, ignore = ignore_patterns('test_*', 'stress_*'))
|
|
164
165
|
internal = {(os.path.dirname(mm.relpath) if '__init__.py' == os.path.basename(mm.relpath) else mm.relpath[:-len(dotpy)]).replace(os.sep, '.') for mm in mainmodules}
|
|
165
166
|
internal.update(self.info.config.internal_module)
|
|
166
167
|
modules = []
|
|
@@ -235,6 +236,7 @@ def main():
|
|
|
235
236
|
parser.add_argument('--docker', action = 'store_true')
|
|
236
237
|
parser.add_argument('--repo', type = yesno, default = True)
|
|
237
238
|
parser.add_argument('--siblings', type = yesno, default = True)
|
|
239
|
+
parser.add_argument('--test', default = 'test|stress')
|
|
238
240
|
parser.add_argument('--transient', action = 'store_true')
|
|
239
241
|
args, noseargs = parser.parse_known_args()
|
|
240
|
-
EveryVersion(ProjectInfo.seekany('.'), args.siblings, args.repo, noseargs, args.docker, args.transient).allchecks()
|
|
242
|
+
EveryVersion(ProjectInfo.seekany('.'), args.siblings, args.repo, noseargs, args.docker, args.transient, args.test).allchecks()
|
|
@@ -25,8 +25,9 @@ def pyimage(pyversiontag, packages, scripts, *requireslayers):
|
|
|
25
25
|
cc.w.docker_gid = Path('/var/run/docker.sock').stat().st_gid
|
|
26
26
|
for p in packages:
|
|
27
27
|
cc.w.package += p
|
|
28
|
+
cc.w.pipinstallsh += 'sudo -u pyvenuser uv --directory ~pyvenuser venv'
|
|
28
29
|
for requires in requireslayers:
|
|
29
|
-
cc.w.pipinstallsh += f"sudo -u pyvenuser pip install
|
|
30
|
+
cc.w.pipinstallsh += f"sudo -u pyvenuser uv --directory ~pyvenuser pip install {' '.join(map(shlex.quote, requires))}"
|
|
30
31
|
cc.w.pyven_gid = os.getegid()
|
|
31
32
|
cc.w.pyven_uid = os.geteuid()
|
|
32
33
|
cc.w.pyversiontag = pyversiontag
|
|
@@ -44,12 +45,12 @@ class Container:
|
|
|
44
45
|
workdir = '/io'
|
|
45
46
|
|
|
46
47
|
def __init__(self, cid):
|
|
47
|
-
self.inworkdir = docker.exec[partial]('-w', self.workdir, cid).sudo._u.pyvenuser[partial]('PATH=/home/pyvenuser/.
|
|
48
|
+
self.inworkdir = docker.exec[partial]('-w', self.workdir, cid).sudo._u.pyvenuser[partial]('PATH=/home/pyvenuser/.venv/bin:/usr/local/bin:/usr/bin:/bin').env
|
|
48
49
|
self.cid = cid
|
|
49
50
|
|
|
50
51
|
def installasuser(self, requires):
|
|
51
52
|
if requires:
|
|
52
|
-
docker.exec[print](self.cid, '
|
|
53
|
+
docker.exec[print](self.cid, 'sh', '-c', f"sudo -u pyvenuser uv --directory ~pyvenuser pip install {' '.join(map(shlex.quote, requires))}")
|
|
53
54
|
|
|
54
55
|
def cp(self, src, dest):
|
|
55
56
|
docker.cp[print](src, f"{self.cid}:{dest}")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
execmask = 0x49
|
|
4
|
+
magic = '#!'
|
|
5
|
+
|
|
6
|
+
def execcheck(paths):
|
|
7
|
+
for path in paths:
|
|
8
|
+
basename = os.path.basename(path)
|
|
9
|
+
executable = bool(os.stat(path).st_mode & execmask)
|
|
10
|
+
with open(path) as f:
|
|
11
|
+
hasmagic = f.readline().startswith(magic)
|
|
12
|
+
for prefix in 'test', 'stress':
|
|
13
|
+
if basename.lower().startswith(prefix):
|
|
14
|
+
if not basename.startswith(f"{prefix}_"):
|
|
15
|
+
raise Exception(f"Inconsistent name: {path}") # Note pyflakes already checks for duplicate method names.
|
|
16
|
+
if executable:
|
|
17
|
+
raise Exception(f"Should not be executable: {path}")
|
|
18
|
+
if hasmagic:
|
|
19
|
+
raise Exception(f"Using {magic} is obsolete: {path}")
|
|
20
|
+
break
|
|
21
|
+
else:
|
|
22
|
+
if executable != hasmagic:
|
|
23
|
+
raise Exception(path)
|
|
@@ -32,8 +32,8 @@ class Files:
|
|
|
32
32
|
self.pypaths = [p for p in self.allsrcpaths if p.name.endswith('.py')]
|
|
33
33
|
self.root = root
|
|
34
34
|
|
|
35
|
-
def testpaths(self, docpaths, reportpath):
|
|
36
|
-
paths = [p for p in self.pypaths if
|
|
35
|
+
def testpaths(self, testmatch, docpaths, reportpath):
|
|
36
|
+
paths = [p for p in self.pypaths if testmatch(p.name) is not None] + docpaths
|
|
37
37
|
if reportpath.exists():
|
|
38
38
|
with reportpath.open() as f:
|
|
39
39
|
doc = dom.parse(f)
|
|
@@ -46,8 +46,8 @@ def licheck(info, paths):
|
|
|
46
46
|
author = info.config.author,
|
|
47
47
|
name = info.config.name,
|
|
48
48
|
))
|
|
49
|
-
elif 'MIT'
|
|
50
|
-
with info.
|
|
49
|
+
elif name in {'BSD', 'MIT'}:
|
|
50
|
+
with info.licpath(name).open() as f:
|
|
51
51
|
sections.append(''.join(('# ' if l.rstrip() else '#') + l for l in f))
|
|
52
52
|
elif 'UNLICENSE' == name:
|
|
53
53
|
pass
|
|
@@ -12,7 +12,7 @@ from lagoon.text import git
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from shutil import copytree, rmtree
|
|
14
14
|
from tempfile import mkdtemp
|
|
15
|
-
from venvpool import
|
|
15
|
+
from venvpool import CompactPool
|
|
16
16
|
import logging, os
|
|
17
17
|
|
|
18
18
|
log = logging.getLogger(__name__)
|
|
@@ -74,7 +74,7 @@ def main():
|
|
|
74
74
|
setupcommand(info, args.transient, 'egg_info')
|
|
75
75
|
|
|
76
76
|
def setupcommand(info, transient, *command):
|
|
77
|
-
with
|
|
77
|
+
with CompactPool().readonlyortransient[transient](SimpleInstallDeps([*info.allbuildrequires, setuptoolsreq])) as venv:
|
|
78
78
|
Program.text(venv.programpath('python'))[print]('setup.py', *command, cwd = info.projectdir)
|
|
79
79
|
|
|
80
80
|
def _metaversion(info):
|
|
@@ -104,13 +104,15 @@ def _isreleased(r):
|
|
|
104
104
|
|
|
105
105
|
class InstallDeps:
|
|
106
106
|
|
|
107
|
+
uv = 'uv'
|
|
108
|
+
|
|
107
109
|
@property
|
|
108
110
|
def pypireqs(self):
|
|
109
111
|
return [VolatileReq(i) for i in self.volatileprojects] + self.fetchreqs
|
|
110
112
|
|
|
111
|
-
def __init__(self, info,
|
|
113
|
+
def __init__(self, info, morelayers, siblings, localrepo, userepo):
|
|
112
114
|
self.info = info
|
|
113
|
-
self.
|
|
115
|
+
self.morelayers = morelayers
|
|
114
116
|
self.siblings = siblings
|
|
115
117
|
self.localrepo = localrepo
|
|
116
118
|
self.userepo = userepo
|
|
@@ -121,7 +123,7 @@ class InstallDeps:
|
|
|
121
123
|
editableprojects = {}
|
|
122
124
|
volatileprojects = {}
|
|
123
125
|
pypireqs = []
|
|
124
|
-
@bfs([(self.info, self.
|
|
126
|
+
@bfs([(self.info, chain(*self.morelayers), True)])
|
|
125
127
|
class Proc:
|
|
126
128
|
def newdepth(self):
|
|
127
129
|
log.debug("Examine requires of: %s", ', '.join(t[0].config.name for t in self.currentkeys))
|
|
@@ -159,13 +161,13 @@ class InstallDeps:
|
|
|
159
161
|
|
|
160
162
|
def corereqslayers(self): # TODO: Also cache build-specific requirements for subsequent builds of that kind.
|
|
161
163
|
'PyPI requirements layers for Docker cache, where each is a subset of the next (and a subset of requirements of some build).'
|
|
162
|
-
yield self.
|
|
164
|
+
yield from self.morelayers
|
|
163
165
|
if git.status.__porcelain(cwd = self.info.projectdir):
|
|
164
166
|
return
|
|
165
167
|
(self.workspace / 'releases').mkdir()
|
|
166
168
|
volatileprojects = {}
|
|
167
169
|
corereqs = []
|
|
168
|
-
@bfs([(self.info, self.
|
|
170
|
+
@bfs([(self.info, chain(*self.morelayers))])
|
|
169
171
|
class Proc:
|
|
170
172
|
def newdepth(self):
|
|
171
173
|
log.debug("Examine requires of: %s", ', '.join(t[0].config.name for t in self.currentkeys))
|
|
@@ -200,7 +202,7 @@ class InstallDeps:
|
|
|
200
202
|
yield corereqs
|
|
201
203
|
|
|
202
204
|
def invoke(self, venv):
|
|
203
|
-
venv.install([str(i.projectdir) for i in self.volatileprojects] + [r.reqstr for r in self.fetchreqs])
|
|
205
|
+
venv.install([str(i.projectdir) for i in self.volatileprojects] + [r.reqstr for r in self.fetchreqs], self.uv)
|
|
204
206
|
|
|
205
207
|
def containerrequires(self):
|
|
206
208
|
return [f"/installdeps/{str(i.projectdir.relative_to(self.workspace)).replace(os.sep, '/')}" for i in self.volatileprojects] + [r.reqstr for r in self.fetchreqs]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
pyversiontag +=
|
|
2
|
-
3.9
|
|
3
|
-
3.10
|
|
4
2
|
3.11
|
|
5
3
|
3.12
|
|
6
4
|
3.13
|
|
5
|
+
3.14
|
|
6
|
+
3.15
|
|
7
7
|
fwrap = $pyref(.functions fwrap)
|
|
8
8
|
neq := $fwrap$pyref(operator ne)
|
|
9
9
|
requires := $list()
|
|
@@ -35,7 +35,11 @@ upstream devel
|
|
|
35
35
|
test requires := $list()
|
|
36
36
|
tagline = $(void)
|
|
37
37
|
cython_build_version = 3.0.11
|
|
38
|
-
|
|
38
|
+
numpy
|
|
39
|
+
build_requires +=
|
|
40
|
+
$(lower_bound)
|
|
41
|
+
numpy<=2.4.4
|
|
42
|
+
lower_bound = numpy>=2.2.6
|
|
39
43
|
pydoc_enabled = true
|
|
40
44
|
readme_verbose = $(github participant)
|
|
41
45
|
internal_module := $list()
|
|
@@ -6,7 +6,7 @@ from aridity.model import Entry, Resource
|
|
|
6
6
|
from foyndation import dotpy, rmsuffix, solo
|
|
7
7
|
from importlib.resources import files
|
|
8
8
|
from inspect import getsource
|
|
9
|
-
from lagoon.program import Program
|
|
9
|
+
from lagoon.program import NOEOL, Program
|
|
10
10
|
from lagoon.text import git
|
|
11
11
|
from packaging.requirements import Requirement
|
|
12
12
|
from roman import fromRoman, toRoman
|
|
@@ -79,6 +79,9 @@ class SimpleInstallDeps(ParsedRequires):
|
|
|
79
79
|
|
|
80
80
|
parselines = staticmethod(Req.parselines)
|
|
81
81
|
|
|
82
|
+
def __init__(self, requires):
|
|
83
|
+
super().__init__(requires, 'uv')
|
|
84
|
+
|
|
82
85
|
class ProjectInfo:
|
|
83
86
|
|
|
84
87
|
projectaridname = 'project.arid'
|
|
@@ -133,8 +136,8 @@ class ProjectInfo:
|
|
|
133
136
|
self.config = cc.node
|
|
134
137
|
self.projectdir = projectdir
|
|
135
138
|
|
|
136
|
-
def
|
|
137
|
-
return self.projectdir / self.config.
|
|
139
|
+
def licpath(self, name):
|
|
140
|
+
return self.projectdir / getattr(self.config, name).path
|
|
138
141
|
|
|
139
142
|
def contextworkspace(self):
|
|
140
143
|
return self.projectdir / '..'
|
|
@@ -158,7 +161,7 @@ class ProjectInfo:
|
|
|
158
161
|
time.sleep(60)
|
|
159
162
|
|
|
160
163
|
def py_modules(self):
|
|
161
|
-
return [stem for name in os.listdir(self.projectdir) if (stem := rmsuffix(name, dotpy)) is not None and 'setup.py' != name and not name.startswith('test_')]
|
|
164
|
+
return [stem for name in os.listdir(self.projectdir) if (stem := rmsuffix(name, dotpy)) is not None and 'setup.py' != name and not name.startswith(('test_', 'stress_'))]
|
|
162
165
|
|
|
163
166
|
def mainmodules(self):
|
|
164
167
|
paths = list(Files.relpaths(self.projectdir, [mainmodules.extension], []))
|
|
@@ -176,16 +179,26 @@ class ProjectInfo:
|
|
|
176
179
|
|
|
177
180
|
def releases(self):
|
|
178
181
|
for tag in git.tag(cwd = self.projectdir).splitlines():
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
versionstr = m.group(1)
|
|
182
|
-
try:
|
|
183
|
-
yield int(versionstr)
|
|
184
|
-
except ValueError:
|
|
185
|
-
yield fromRoman(versionstr)
|
|
182
|
+
if (versionno := versionnoornone(tag)) is not None:
|
|
183
|
+
yield versionno
|
|
186
184
|
|
|
187
185
|
def devversion(self):
|
|
188
|
-
|
|
186
|
+
def otherversions():
|
|
187
|
+
srcgit = git[...](cwd = self.projectdir)
|
|
188
|
+
commit = srcgit.rev_parse.HEAD[NOEOL]()
|
|
189
|
+
for tag in srcgit.tag().splitlines():
|
|
190
|
+
if (versionno := versionnoornone(tag)) is not None and srcgit.rev_parse[NOEOL](tag) != commit:
|
|
191
|
+
yield versionno
|
|
192
|
+
return f"{max(otherversions(), default = 0) + 1}.dev0"
|
|
193
|
+
|
|
194
|
+
def versionnoornone(tag):
|
|
195
|
+
m = re.fullmatch('release/(.+)', tag)
|
|
196
|
+
if m is not None:
|
|
197
|
+
versionstr = m.group(1)
|
|
198
|
+
try:
|
|
199
|
+
return int(versionstr)
|
|
200
|
+
except ValueError:
|
|
201
|
+
return fromRoman(versionstr)
|
|
189
202
|
|
|
190
203
|
class MainModule:
|
|
191
204
|
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
'Release project to PyPI, with manylinux wheels as needed.'
|
|
2
|
+
from .checks import EveryVersion
|
|
3
|
+
from .container import bgcontainer
|
|
4
|
+
from .pipify import InstallDeps, pipify, setuptoolsreq
|
|
5
|
+
from .projectinfo import ProjectInfo, SimpleInstallDeps, toreleasetag, versionnoornone
|
|
6
|
+
from .sourceinfo import SourceInfo
|
|
7
|
+
from argparse import ArgumentParser
|
|
8
|
+
from aridity.config import ConfigCtrl
|
|
9
|
+
from foyndation import dotpy, initlogging, rmprefix, rmsuffix, singleton, solo
|
|
10
|
+
from importlib.resources import as_file, files
|
|
11
|
+
from itertools import chain
|
|
12
|
+
from lagoon.program import NOEOL, Program
|
|
13
|
+
from lagoon.text import docker, git
|
|
14
|
+
from packaging.version import Version
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from shutil import rmtree
|
|
17
|
+
from tempfile import NamedTemporaryFile
|
|
18
|
+
from venvpool import CompactPool, Pip
|
|
19
|
+
import json, logging, os, re, sys, sysconfig
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
distrelpath = Path('dist')
|
|
23
|
+
|
|
24
|
+
class Arch:
|
|
25
|
+
|
|
26
|
+
def __init__(self, entrypointornone):
|
|
27
|
+
self.entrypoint = [] if entrypointornone is None else [entrypointornone]
|
|
28
|
+
|
|
29
|
+
def _images():
|
|
30
|
+
archlookup = dict(
|
|
31
|
+
i686 = Arch('linux32'),
|
|
32
|
+
x86_64 = Arch(None),
|
|
33
|
+
)
|
|
34
|
+
archmatch = re.compile(f"_({'|'.join(map(re.escape, archlookup))})$").search
|
|
35
|
+
images = {
|
|
36
|
+
'manylinux_2_28_x86_64': '2026.03.14-2',
|
|
37
|
+
'manylinux2014_x86_64': '2026.03.14-2',
|
|
38
|
+
}
|
|
39
|
+
for plat, imagetag in images.items():
|
|
40
|
+
yield Image(imagetag, plat, archlookup[archmatch(plat).group(1)])
|
|
41
|
+
|
|
42
|
+
class Image:
|
|
43
|
+
|
|
44
|
+
prefix = 'quay.io/pypa/'
|
|
45
|
+
|
|
46
|
+
@singleton
|
|
47
|
+
def pythonexe():
|
|
48
|
+
impl = f"cp{sysconfig.get_config_var('py_version_nodot')}"
|
|
49
|
+
return f"/opt/python/{impl}-{impl}{sys.abiflags}/bin/python"
|
|
50
|
+
|
|
51
|
+
def __init__(self, imagetag, plat, arch):
|
|
52
|
+
self.imagetag = imagetag
|
|
53
|
+
self.plat = plat
|
|
54
|
+
self.arch = arch
|
|
55
|
+
|
|
56
|
+
def makewheels(self, info): # TODO: This code would benefit from modern syntax.
|
|
57
|
+
log.info("Make wheels for platform: %s", self.plat)
|
|
58
|
+
scripts = list(info.config.devel.scripts)
|
|
59
|
+
packages = list(info.config.devel.packages)
|
|
60
|
+
# TODO: Copy not mount so we can run containers in parallel.
|
|
61
|
+
with bgcontainer('-v', f"{info.projectdir}:/io", f"{self.prefix}{self.plat}:{self.imagetag}") as container, as_file(files(__spec__.parent)) as parent:
|
|
62
|
+
def run(execargs, command):
|
|
63
|
+
docker.exec[print](*execargs, container.cid, *self.arch.entrypoint, *command)
|
|
64
|
+
if packages:
|
|
65
|
+
run([], chain(['yum', 'install', '-y'], packages))
|
|
66
|
+
for script in scripts:
|
|
67
|
+
# TODO LATER: Run as ordinary sudo-capable user.
|
|
68
|
+
dirpath = docker.exec[NOEOL](container.cid, 'mktemp', '-d') # No need to cleanup, will die with container.
|
|
69
|
+
log.debug("In container dir %s run script: %s", dirpath, script)
|
|
70
|
+
run(['-w', dirpath, '-t'], ['sh', '-c', script])
|
|
71
|
+
docker.cp[print](parent / 'patchpolicy.py', f"{container.cid}:/patchpolicy.py")
|
|
72
|
+
run([], [self.pythonexe, '/patchpolicy.py'])
|
|
73
|
+
docker.cp[print](parent / 'bdist.py', f"{container.cid}:/bdist.py")
|
|
74
|
+
run(['-u', f"{os.geteuid()}:{os.getegid()}", '-w', '/io'], [self.pythonexe, '/bdist.py', '--plat', self.plat, '--accepttags', json.dumps(info.pyversiontags)])
|
|
75
|
+
|
|
76
|
+
def _uploadableartifacts(artifactrelpaths):
|
|
77
|
+
def acceptplatform(platform):
|
|
78
|
+
return 'any' == platform or platform.startswith('manylinux')
|
|
79
|
+
platformmatch = re.compile('-([^-]+)[.]whl$').search
|
|
80
|
+
for p in artifactrelpaths:
|
|
81
|
+
if not p.name.endswith('.whl') or acceptplatform(platformmatch(p.name).group(1)):
|
|
82
|
+
yield p
|
|
83
|
+
else:
|
|
84
|
+
log.debug("Not uploadable: %s", p)
|
|
85
|
+
|
|
86
|
+
class Project:
|
|
87
|
+
|
|
88
|
+
def __init__(self, info):
|
|
89
|
+
self.info = info
|
|
90
|
+
|
|
91
|
+
def _warmups(self):
|
|
92
|
+
warmups = [w.split(':') for w in self.info.config.warmups]
|
|
93
|
+
if warmups:
|
|
94
|
+
# XXX: Use the same transient venv as used for running tests?
|
|
95
|
+
with InstallDeps(self.info, (), False, None, False) as installdeps, CompactPool().readonlyortransient[True](installdeps) as venv:
|
|
96
|
+
for m, f in warmups:
|
|
97
|
+
with NamedTemporaryFile('w', suffix = dotpy, dir = '.') as script:
|
|
98
|
+
script.write(f"from {m} import {f.split('.')[0]}\n{f}()")
|
|
99
|
+
script.flush()
|
|
100
|
+
venv.run('check_call', ['.'] + installdeps.localreqs, rmsuffix(Path(script.name).name, dotpy), [])
|
|
101
|
+
|
|
102
|
+
def _runsetup(self, commands):
|
|
103
|
+
with CompactPool().readonly(SimpleInstallDeps([*self.info.allbuildrequires, setuptoolsreq])) as venv:
|
|
104
|
+
venv.run('check_call', ['.'], 'setup', commands) # XXX: Should venvpool automatically include current dir?
|
|
105
|
+
|
|
106
|
+
def release(self, version):
|
|
107
|
+
scrub = git.clean._xdi[..., print](input = 'c')
|
|
108
|
+
scrub()
|
|
109
|
+
pipify(self.info, version)
|
|
110
|
+
EveryVersion(self.info, False, False, [], False, True, 'test|stress').allchecks() # TODO: Require successful builds of this commit instead.
|
|
111
|
+
scrub()
|
|
112
|
+
for dirpath, dirnames, filenames in os.walk('.'):
|
|
113
|
+
for name in chain(filenames, dirnames):
|
|
114
|
+
if name.startswith(('test_', 'stress_')): # TODO LATER: Allow project to add globs to exclude.
|
|
115
|
+
path = Path(dirpath, name)
|
|
116
|
+
log.debug("Delete: %s", path)
|
|
117
|
+
(os.remove if name.endswith('.py') else rmtree)(path)
|
|
118
|
+
self._warmups()
|
|
119
|
+
pipify(self.info, version)
|
|
120
|
+
rmtree('.git')
|
|
121
|
+
setupcommands = []
|
|
122
|
+
if SourceInfo('.').extpaths:
|
|
123
|
+
for image in _images():
|
|
124
|
+
image.makewheels(self.info)
|
|
125
|
+
else:
|
|
126
|
+
setupcommands.append('bdist_wheel')
|
|
127
|
+
self._runsetup(setupcommands + ['sdist'])
|
|
128
|
+
return sorted(distrelpath.iterdir())
|
|
129
|
+
|
|
130
|
+
def bump(self, email, versionno):
|
|
131
|
+
prefix = 'refs/remotes/origin/'
|
|
132
|
+
git.checkout[print](rmprefix(git.symbolic_ref[NOEOL](f"{prefix}HEAD"), prefix))
|
|
133
|
+
pkginfo, = Path().glob('*.egg-info/PKG-INFO')
|
|
134
|
+
lines = pkginfo.read_text('utf-8').splitlines(True)
|
|
135
|
+
vcs = 'Version: '
|
|
136
|
+
index = solo(i for i, l in enumerate(lines) if l.startswith(vcs))
|
|
137
|
+
if Version(str(versionno)) < Version(rmprefix(lines[index], vcs)):
|
|
138
|
+
log.info('Version already exceeds this release.')
|
|
139
|
+
return
|
|
140
|
+
lines[index] = f"Version: {versionno + 1}.dev0\n"
|
|
141
|
+
pkginfo.write_text(''.join(lines), 'utf-8')
|
|
142
|
+
git.add[print](pkginfo)
|
|
143
|
+
git.commit[print]('-m', 'bump', EMAIL = email)
|
|
144
|
+
git.push[print]()
|
|
145
|
+
|
|
146
|
+
def newtag(self):
|
|
147
|
+
lastrelease = max(self.info.releases(), default = 0)
|
|
148
|
+
git.tag[print](toreleasetag(max(10, lastrelease + 1)))
|
|
149
|
+
git.push.__tags[print]()
|
|
150
|
+
|
|
151
|
+
def main():
|
|
152
|
+
initlogging()
|
|
153
|
+
config = ConfigCtrl().loadappconfig(main, 'release.arid')
|
|
154
|
+
parser = ArgumentParser()
|
|
155
|
+
parser.add_argument('--bump', action = 'store_true')
|
|
156
|
+
parser.add_argument('--tag')
|
|
157
|
+
parser.parse_args(namespace = config.cli)
|
|
158
|
+
project = Project(ProjectInfo.seek('.'))
|
|
159
|
+
if git.status.__porcelain():
|
|
160
|
+
raise Exception('Uncommitted changes!')
|
|
161
|
+
log.debug('No uncommitted changes.')
|
|
162
|
+
if config.tag is None:
|
|
163
|
+
assert not config.bump
|
|
164
|
+
project.newtag()
|
|
165
|
+
return
|
|
166
|
+
commit = git.rev_parse.HEAD[NOEOL]()
|
|
167
|
+
if git.rev_parse[NOEOL](config.tag) != commit:
|
|
168
|
+
raise Exception(f"Expected {config.tag} but got: {commit}")
|
|
169
|
+
versionno = versionnoornone(config.tag)
|
|
170
|
+
if config.bump:
|
|
171
|
+
project.bump(config.email, versionno)
|
|
172
|
+
else:
|
|
173
|
+
allrelpaths = project.release(str(versionno))
|
|
174
|
+
config.account = project.info.config.pypi.account # XXX: Load info config to a scope in our config?
|
|
175
|
+
Program.text(sys.executable)._m.twine.upload[print]('-u', '__token__', '-p', config.token, *_uploadableartifacts(allrelpaths), env = Pip.envpatch)
|
|
176
|
+
|
|
177
|
+
if '__main__' == __name__:
|
|
178
|
+
main()
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'Check last release can be installed from PyPI and its tests still pass, for use by CI.'
|
|
2
|
-
from .checks import EveryVersion
|
|
3
2
|
from .container import bgcontainer, pyimage
|
|
4
|
-
from .projectinfo import ProjectInfo, toreleasetag
|
|
3
|
+
from .projectinfo import ProjectInfo, toreleasetag, versionnoornone
|
|
5
4
|
from argparse import ArgumentParser
|
|
6
5
|
from foyndation import initlogging
|
|
7
6
|
from lagoon.text import git
|
|
8
|
-
|
|
9
|
-
import logging, re
|
|
7
|
+
import logging
|
|
10
8
|
|
|
11
9
|
log = logging.getLogger(__name__)
|
|
12
10
|
|
|
@@ -20,8 +18,8 @@ def main():
|
|
|
20
18
|
log.info('Not user-installable.')
|
|
21
19
|
return
|
|
22
20
|
project = headinfo.config.name
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
if (versionno := versionnoornone(branch)) is None:
|
|
22
|
+
versionno = max(headinfo.releases())
|
|
25
23
|
req = f"{project}=={versionno}"
|
|
26
24
|
upstream_devel_packages = list(headinfo.config.upstream.devel.packages)
|
|
27
25
|
for pyversion in reversed(headinfo.pyversiontags):
|
|
@@ -29,7 +27,6 @@ def main():
|
|
|
29
27
|
with bgcontainer(pyimage(pyversion, upstream_devel_packages, [])) as container:
|
|
30
28
|
container.installasuser([req])
|
|
31
29
|
git.checkout[print](toreleasetag(versionno))
|
|
32
|
-
EveryVersion(ProjectInfo.seek('.'), False, False, [], True, True).nose()
|
|
33
30
|
|
|
34
31
|
if '__main__' == __name__:
|
|
35
32
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pyven
|
|
3
|
-
Version:
|
|
3
|
+
Version: 119
|
|
4
4
|
Summary: Manage development of multiple Python projects
|
|
5
5
|
Home-page: https://pypi.org/project/pyven/
|
|
6
6
|
Author: Homsar
|
|
@@ -8,10 +8,10 @@ Author-email: homsar@foyono.com
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: aridity>=85
|
|
10
10
|
Requires-Dist: diapyr>=31
|
|
11
|
-
Requires-Dist: foyndation>=
|
|
12
|
-
Requires-Dist: lagoon>=
|
|
11
|
+
Requires-Dist: foyndation>=18
|
|
12
|
+
Requires-Dist: lagoon>=64
|
|
13
13
|
Requires-Dist: packaging>=25
|
|
14
|
-
Requires-Dist: pydoc-markdown>=
|
|
14
|
+
Requires-Dist: pydoc-markdown>=4.8.2
|
|
15
15
|
Requires-Dist: roman>=5
|
|
16
16
|
Requires-Dist: setuptools>=44.1.1
|
|
17
17
|
Requires-Dist: twine>=1.15.0
|
{pyven-117 → pyven-119}/setup.py
RENAMED
|
@@ -49,13 +49,13 @@ class SourceInfo:
|
|
|
49
49
|
sourceinfo = SourceInfo('.')
|
|
50
50
|
setup(
|
|
51
51
|
name = 'pyven',
|
|
52
|
-
version = '
|
|
52
|
+
version = '119',
|
|
53
53
|
description = 'Manage development of multiple Python projects',
|
|
54
54
|
url = 'https://pypi.org/project/pyven/',
|
|
55
55
|
author = 'Homsar',
|
|
56
56
|
author_email = 'homsar@foyono.com',
|
|
57
57
|
py_modules = [],
|
|
58
|
-
install_requires = ['aridity>=85', 'diapyr>=31', 'foyndation>=
|
|
58
|
+
install_requires = ['aridity>=85', 'diapyr>=31', 'foyndation>=18', 'lagoon>=64', 'packaging>=25', 'pydoc-markdown>=4.8.2', 'roman>=5', 'setuptools>=44.1.1', 'twine>=1.15.0', 'venvpool>=18'],
|
|
59
59
|
package_data = {'': ['*.pxd', '*.pyx', '*.pyxbld', '*.arid', '*.aridt']},
|
|
60
60
|
entry_points = {'console_scripts': ['minreqs=pyven.minreqs:main', 'pipify=pyven.pipify:main', 'release=pyven.release:main', 'tasks=pyven.tasks:main', 'tryinstall=pyven.tryinstall:main', 'tests=pyven.tests.__init__:main']},
|
|
61
61
|
**sourceinfo.setup_kwargs(),
|
pyven-117/pyven/execcheck.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
execmask = 0x49
|
|
4
|
-
magic = '#!'
|
|
5
|
-
|
|
6
|
-
def execcheck(paths):
|
|
7
|
-
for path in paths:
|
|
8
|
-
basename = os.path.basename(path)
|
|
9
|
-
executable = bool(os.stat(path).st_mode & execmask)
|
|
10
|
-
with open(path) as f:
|
|
11
|
-
hasmagic = f.readline().startswith(magic)
|
|
12
|
-
if basename.lower().startswith('test'):
|
|
13
|
-
if not basename.startswith('test_'):
|
|
14
|
-
raise Exception(f"Inconsistent name: {path}") # Note pyflakes already checks for duplicate method names.
|
|
15
|
-
if executable:
|
|
16
|
-
raise Exception(f"Should not be executable: {path}")
|
|
17
|
-
if hasmagic:
|
|
18
|
-
raise Exception(f"Using {magic} is obsolete: {path}")
|
|
19
|
-
else:
|
|
20
|
-
if executable != hasmagic:
|
|
21
|
-
raise Exception(path)
|
pyven-117/pyven/release.arid
DELETED
pyven-117/pyven/release.py
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'Release project to PyPI, with manylinux wheels as needed.'
|
|
2
|
-
from .checks import EveryVersion
|
|
3
|
-
from .container import bgcontainer
|
|
4
|
-
from .pipify import InstallDeps, pipify, setuptoolsreq
|
|
5
|
-
from .projectinfo import ProjectInfo, SimpleInstallDeps, toreleasetag
|
|
6
|
-
from .sourceinfo import SourceInfo
|
|
7
|
-
from argparse import ArgumentParser
|
|
8
|
-
from aridity.config import ConfigCtrl
|
|
9
|
-
from foyndation import dotpy, initlogging, singleton, solo
|
|
10
|
-
from importlib.resources import as_file, files
|
|
11
|
-
from itertools import chain
|
|
12
|
-
from lagoon.binary import tidy
|
|
13
|
-
from lagoon.program import NOEOL, partial, Program
|
|
14
|
-
from lagoon.text import docker, git
|
|
15
|
-
from shutil import copy2, copytree, rmtree
|
|
16
|
-
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
|
17
|
-
from urllib.error import HTTPError
|
|
18
|
-
from urllib.request import urlopen
|
|
19
|
-
from venvpool import Pip, Pool
|
|
20
|
-
import xml.dom.minidom as dom, logging, os, re, sys, sysconfig
|
|
21
|
-
|
|
22
|
-
log = logging.getLogger(__name__)
|
|
23
|
-
distrelpath = 'dist'
|
|
24
|
-
|
|
25
|
-
class Arch:
|
|
26
|
-
|
|
27
|
-
def __init__(self, entrypointornone):
|
|
28
|
-
self.entrypoint = [] if entrypointornone is None else [entrypointornone]
|
|
29
|
-
|
|
30
|
-
def _images():
|
|
31
|
-
archlookup = dict(
|
|
32
|
-
i686 = Arch('linux32'),
|
|
33
|
-
x86_64 = Arch(None),
|
|
34
|
-
)
|
|
35
|
-
archmatch = re.compile(f"_({'|'.join(map(re.escape, archlookup))})$").search
|
|
36
|
-
images = {
|
|
37
|
-
'manylinux_2_34_x86_64': '2024-11-23-da4547b',
|
|
38
|
-
'manylinux_2_28_x86_64': '2024-11-30-fa0d298',
|
|
39
|
-
'manylinux2014_x86_64': '2024-11-24-a3012f3',
|
|
40
|
-
'manylinux2014_i686': '2024-11-23-da4547b',
|
|
41
|
-
}
|
|
42
|
-
for plat, imagetag in images.items():
|
|
43
|
-
yield Image(imagetag, plat, archlookup[archmatch(plat).group(1)])
|
|
44
|
-
|
|
45
|
-
class Image:
|
|
46
|
-
|
|
47
|
-
prefix = 'quay.io/pypa/'
|
|
48
|
-
|
|
49
|
-
@singleton
|
|
50
|
-
def pythonexe():
|
|
51
|
-
impl = f"cp{sysconfig.get_config_var('py_version_nodot')}"
|
|
52
|
-
return f"/opt/python/{impl}-{impl}{sys.abiflags}/bin/python"
|
|
53
|
-
|
|
54
|
-
def __init__(self, imagetag, plat, arch):
|
|
55
|
-
self.imagetag = imagetag
|
|
56
|
-
self.plat = plat
|
|
57
|
-
self.arch = arch
|
|
58
|
-
|
|
59
|
-
def makewheels(self, info): # TODO: This code would benefit from modern syntax.
|
|
60
|
-
log.info("Make wheels for platform: %s", self.plat)
|
|
61
|
-
scripts = list(info.config.devel.scripts)
|
|
62
|
-
packages = list(info.config.devel.packages)
|
|
63
|
-
# TODO: Copy not mount so we can run containers in parallel.
|
|
64
|
-
with bgcontainer('-v', f"{info.projectdir}:/io", f"{self.prefix}{self.plat}:{self.imagetag}") as container, as_file(files(__spec__.parent)) as parent:
|
|
65
|
-
def run(execargs, command):
|
|
66
|
-
docker.exec[print](*execargs, container.cid, *self.arch.entrypoint, *command)
|
|
67
|
-
if packages:
|
|
68
|
-
run([], chain(['yum', 'install', '-y'], packages))
|
|
69
|
-
for script in scripts:
|
|
70
|
-
# TODO LATER: Run as ordinary sudo-capable user.
|
|
71
|
-
dirpath = docker.exec[NOEOL](container.cid, 'mktemp', '-d') # No need to cleanup, will die with container.
|
|
72
|
-
log.debug("In container dir %s run script: %s", dirpath, script)
|
|
73
|
-
run(['-w', dirpath, '-t'], ['sh', '-c', script])
|
|
74
|
-
docker.cp[print](parent / 'patchpolicy.py', f"{container.cid}:/patchpolicy.py")
|
|
75
|
-
run([], [self.pythonexe, '/patchpolicy.py'])
|
|
76
|
-
docker.cp[print](parent / 'bdist.py', f"{container.cid}:/bdist.py")
|
|
77
|
-
run(['-u', f"{os.geteuid()}:{os.getegid()}", '-w', '/io'], [self.pythonexe, '/bdist.py', '--plat', self.plat])
|
|
78
|
-
|
|
79
|
-
def _uploadableartifacts(artifactrelpaths):
|
|
80
|
-
def acceptplatform(platform):
|
|
81
|
-
return 'any' == platform or platform.startswith('manylinux')
|
|
82
|
-
platformmatch = re.compile('-([^-]+)[.]whl$').search
|
|
83
|
-
for p in artifactrelpaths:
|
|
84
|
-
name = os.path.basename(p)
|
|
85
|
-
if not name.endswith('.whl') or acceptplatform(platformmatch(name).group(1)):
|
|
86
|
-
yield p
|
|
87
|
-
else:
|
|
88
|
-
log.debug("Not uploadable: %s", p)
|
|
89
|
-
|
|
90
|
-
def _textcontent(node):
|
|
91
|
-
def iterparts(node):
|
|
92
|
-
value = node.nodeValue
|
|
93
|
-
if value is None:
|
|
94
|
-
for child in node.childNodes:
|
|
95
|
-
for text in iterparts(child):
|
|
96
|
-
yield text
|
|
97
|
-
else:
|
|
98
|
-
yield value
|
|
99
|
-
return ''.join(iterparts(node))
|
|
100
|
-
|
|
101
|
-
def _nextversionno(name):
|
|
102
|
-
pattern = re.compile('-([0-9]+)[-.]')
|
|
103
|
-
log.debug('Check PyPI for existing release.')
|
|
104
|
-
try:
|
|
105
|
-
with urlopen(f"https://pypi.org/simple/{name}/") as f:
|
|
106
|
-
doc = dom.parseString(tidy._asxml(input = f.read()))
|
|
107
|
-
last = max(int(pattern.search(_textcontent(a)).group(1)) for a in doc.getElementsByTagName('a'))
|
|
108
|
-
except HTTPError as e:
|
|
109
|
-
if 404 != e.code:
|
|
110
|
-
raise
|
|
111
|
-
last = 0
|
|
112
|
-
return max(10, last + 1)
|
|
113
|
-
|
|
114
|
-
def _warmups(info):
|
|
115
|
-
warmups = [w.split(':') for w in info.config.warmups]
|
|
116
|
-
if warmups:
|
|
117
|
-
# XXX: Use the same transient venv as used for running tests?
|
|
118
|
-
with InstallDeps(info, (), False, None, False) as installdeps, Pool().readonlyortransient[True](installdeps) as venv:
|
|
119
|
-
for m, f in warmups:
|
|
120
|
-
with NamedTemporaryFile('w', suffix = dotpy, dir = info.projectdir) as script:
|
|
121
|
-
script.write(f"from {m} import {f.split('.')[0]}\n{f}()")
|
|
122
|
-
script.flush()
|
|
123
|
-
venv.run('check_call', ['.'] + installdeps.localreqs, os.path.basename(script.name)[:-len(dotpy)], [], cwd = info.projectdir)
|
|
124
|
-
|
|
125
|
-
def _runsetup(info, commands):
|
|
126
|
-
with Pool().readonly(SimpleInstallDeps([*info.allbuildrequires, setuptoolsreq])) as venv:
|
|
127
|
-
venv.run('check_call', ['.'], 'setup', commands, cwd = info.projectdir) # XXX: Should venvpool automatically include current dir?
|
|
128
|
-
|
|
129
|
-
def _release(config, srcgit, versionno, info):
|
|
130
|
-
(info.projectdir / '.git' / 'hooks' / 'post-commit').unlink()
|
|
131
|
-
copygit = git[partial](cwd = info.projectdir)
|
|
132
|
-
scrub = copygit.clean._xdi[partial, print](input = 'c')
|
|
133
|
-
scrub()
|
|
134
|
-
releasetag = toreleasetag(versionno)
|
|
135
|
-
if releasetag not in copygit.tag.__points_at().splitlines():
|
|
136
|
-
pkginfo, = info.projectdir.glob('*.egg-info/PKG-INFO')
|
|
137
|
-
lines = pkginfo.read_text('utf-8').splitlines(True)
|
|
138
|
-
lines[solo(i for i, l in enumerate(lines) if l.startswith('Version: '))] = f"Version: {versionno + 1}.dev0\n"
|
|
139
|
-
pkginfo.write_text(''.join(lines), 'utf-8')
|
|
140
|
-
copygit.add[print](pkginfo)
|
|
141
|
-
copygit.commit[print]('-m', 'release')
|
|
142
|
-
copygit.tag[print](releasetag)
|
|
143
|
-
copygit.push[print](config.golden_remote, 'HEAD', releasetag)
|
|
144
|
-
pipify(info, str(versionno))
|
|
145
|
-
EveryVersion(info, False, False, [], False, True).allchecks(exclude = ['metacheck'])
|
|
146
|
-
scrub()
|
|
147
|
-
for dirpath, dirnames, filenames in os.walk(info.projectdir):
|
|
148
|
-
for name in chain(filenames, dirnames):
|
|
149
|
-
if name.startswith('test_'): # TODO LATER: Allow project to add globs to exclude.
|
|
150
|
-
path = os.path.join(dirpath, name)
|
|
151
|
-
log.debug("Delete: %s", path)
|
|
152
|
-
(os.remove if name.endswith('.py') else rmtree)(path)
|
|
153
|
-
_warmups(info)
|
|
154
|
-
pipify(info, str(versionno))
|
|
155
|
-
rmtree(info.projectdir / '.git')
|
|
156
|
-
setupcommands = []
|
|
157
|
-
if SourceInfo(info.projectdir).extpaths:
|
|
158
|
-
for image in _images():
|
|
159
|
-
image.makewheels(info)
|
|
160
|
-
else:
|
|
161
|
-
setupcommands.append('bdist_wheel')
|
|
162
|
-
_runsetup(info, setupcommands + ['sdist'])
|
|
163
|
-
return [os.path.join(distrelpath, name) for name in sorted(os.listdir(info.projectdir / distrelpath))]
|
|
164
|
-
|
|
165
|
-
def main():
|
|
166
|
-
initlogging()
|
|
167
|
-
config = ConfigCtrl().loadappconfig(main, 'release.arid')
|
|
168
|
-
parser = ArgumentParser()
|
|
169
|
-
parser.add_argument('--retry', action = 'store_true', help = 'use artifacts in dist dir')
|
|
170
|
-
parser.add_argument('--upload', action = 'store_true')
|
|
171
|
-
parser.add_argument('path', nargs = '?', default = '.')
|
|
172
|
-
parser.parse_args(namespace = config.cli)
|
|
173
|
-
info = ProjectInfo.seek(config.path)
|
|
174
|
-
config.account = info.config.pypi.account # XXX: Load info config to a scope in our config?
|
|
175
|
-
srcgit = git[partial](cwd = info.projectdir)
|
|
176
|
-
if srcgit.status.__porcelain():
|
|
177
|
-
raise Exception('Uncommitted changes!')
|
|
178
|
-
log.debug('No uncommitted changes.')
|
|
179
|
-
versionno = _nextversionno(info.config.name)
|
|
180
|
-
if config.retry:
|
|
181
|
-
allrelpaths = sorted(p.relative_to(info.projectdir) for p in (info.projectdir / distrelpath).iterdir() if re.match(f"[^-]+-{re.escape(str(versionno))}[-.]", p.name) is not None)
|
|
182
|
-
else:
|
|
183
|
-
with TemporaryDirectory() as tempdir:
|
|
184
|
-
copydir = os.path.join(tempdir, os.path.basename(os.path.abspath(info.projectdir)))
|
|
185
|
-
log.info("Copying project to: %s", copydir)
|
|
186
|
-
copytree(info.projectdir, copydir)
|
|
187
|
-
allrelpaths = _release(config, srcgit, versionno, ProjectInfo.seek(copydir))
|
|
188
|
-
for relpath in allrelpaths:
|
|
189
|
-
log.info("Replace artifact: %s", relpath)
|
|
190
|
-
destpath = info.projectdir / relpath
|
|
191
|
-
destpath.parent.mkdir(exist_ok = True, parents = True)
|
|
192
|
-
copy2(os.path.join(copydir, relpath), destpath)
|
|
193
|
-
uploadablerelpaths = _uploadableartifacts(allrelpaths)
|
|
194
|
-
if config.upload:
|
|
195
|
-
with config.token as token:
|
|
196
|
-
Program.text(sys.executable)._m.twine.upload[print]('-u', '__token__', '-p', token, *uploadablerelpaths, cwd = info.projectdir, env = Pip.envpatch)
|
|
197
|
-
else:
|
|
198
|
-
log.warning("Upload skipped, use --upload to upload: %s", ' '.join(map(str, uploadablerelpaths)))
|
|
199
|
-
|
|
200
|
-
if '__main__' == __name__:
|
|
201
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|