pyven 108__tar.gz → 110__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.
Files changed (40) hide show
  1. {pyven-108 → pyven-110}/PKG-INFO +2 -1
  2. pyven-110/pyven/Dockerfile.aridt +12 -0
  3. {pyven-108 → pyven-110}/pyven/README.md.aridt +2 -2
  4. {pyven-108 → pyven-110}/pyven/checks.py +35 -77
  5. pyven-110/pyven/container.py +54 -0
  6. pyven-110/pyven/metacheck.py +39 -0
  7. {pyven-108 → pyven-110}/pyven/pipify.py +6 -10
  8. {pyven-108 → pyven-110}/pyven/projectinfo.py +17 -8
  9. {pyven-108 → pyven-110}/pyven/release.arid +2 -0
  10. {pyven-108 → pyven-110}/pyven/release.py +45 -41
  11. pyven-110/pyven/tryinstall.py +35 -0
  12. {pyven-108 → pyven-110}/pyven/util.py +0 -16
  13. {pyven-108 → pyven-110}/pyven.egg-info/PKG-INFO +2 -1
  14. {pyven-108 → pyven-110}/pyven.egg-info/SOURCES.txt +2 -0
  15. {pyven-108 → pyven-110}/pyven.egg-info/requires.txt +1 -0
  16. {pyven-108 → pyven-110}/setup.py +2 -2
  17. pyven-108/pyven/metacheck.py +0 -53
  18. pyven-108/pyven/tryinstall.py +0 -38
  19. {pyven-108 → pyven-110}/README.md +0 -0
  20. {pyven-108 → pyven-110}/pyven/__init__.py +0 -0
  21. {pyven-108 → pyven-110}/pyven/bdist.py +0 -0
  22. {pyven-108 → pyven-110}/pyven/execcheck.py +0 -0
  23. {pyven-108 → pyven-110}/pyven/files.py +0 -0
  24. {pyven-108 → pyven-110}/pyven/functions.py +0 -0
  25. {pyven-108 → pyven-110}/pyven/licheck.py +0 -0
  26. {pyven-108 → pyven-110}/pyven/mainmodules.py +0 -0
  27. {pyven-108 → pyven-110}/pyven/minreqs.py +0 -0
  28. {pyven-108 → pyven-110}/pyven/nlcheck.py +0 -0
  29. {pyven-108 → pyven-110}/pyven/patchpolicy.py +0 -0
  30. {pyven-108 → pyven-110}/pyven/projectinfo.arid +0 -0
  31. {pyven-108 → pyven-110}/pyven/pyproject.toml.aridt +0 -0
  32. {pyven-108 → pyven-110}/pyven/setup.py.aridt +0 -0
  33. {pyven-108 → pyven-110}/pyven/setuptools.arid +0 -0
  34. {pyven-108 → pyven-110}/pyven/sourceinfo.py +0 -0
  35. {pyven-108 → pyven-110}/pyven/tasks.py +0 -0
  36. {pyven-108 → pyven-110}/pyven/tests/__init__.py +0 -0
  37. {pyven-108 → pyven-110}/pyven.egg-info/dependency_links.txt +0 -0
  38. {pyven-108 → pyven-110}/pyven.egg-info/entry_points.txt +0 -0
  39. {pyven-108 → pyven-110}/pyven.egg-info/top_level.txt +0 -0
  40. {pyven-108 → pyven-110}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyven
3
- Version: 108
3
+ Version: 110
4
4
  Summary: Manage development of multiple Python projects
5
5
  Home-page: https://pypi.org/project/pyven/
6
6
  Author: Homsar
@@ -10,6 +10,7 @@ Requires-Dist: aridity>=77
10
10
  Requires-Dist: diapyr>=31
11
11
  Requires-Dist: lagoon>=49
12
12
  Requires-Dist: pydoc-markdown>=3.3
13
+ Requires-Dist: roman>=5
13
14
  Requires-Dist: setuptools>=44.1.1
14
15
  Requires-Dist: twine>=1.15.0
15
16
  Requires-Dist: venvpool>=14
@@ -0,0 +1,12 @@
1
+ FROM python:$(pyversiontag)
2
+ RUN $'[mkdir -pv /etc/apt/keyrings && \
3
+ curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \
4
+ 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
+ apt-get update && \
6
+ apt-get install -y sudo]
7
+ RUN groupadd -g $str$(docker_gid) docker && \
8
+ groupadd -g $str$(pyven_gid) pyvengroup && \
9
+ useradd -g $str$(pyven_gid) -G docker -u $str$(pyven_uid) -m pyvenuser
10
+ RUN apt-get install -y$join$map($(package) $.( $shstr$()))
11
+ RUN $join$map($(script) $.(cd $'[$(mktemp -d)] && ($()) && rm -rfv $'[$PWD] && )):
12
+ RUN $(pipinstallsh)
@@ -15,14 +15,14 @@ venvname/bin/pip install $(name)
15
15
 
16
16
  ### To use, permanently
17
17
  ```
18
- pip3 install --user $(name)
18
+ pip3 install --break-system-packages --user $(name)
19
19
  ```
20
20
  See `~/.local/bin` for executables.
21
21
 
22
22
  ### To develop
23
23
  First install venvpool to get the `motivate` command:
24
24
  ```
25
- pip3 install --user venvpool
25
+ pip3 install --break-system-packages --user venvpool
26
26
  ```
27
27
  Get codebase and install executables:
28
28
  ```
@@ -1,20 +1,20 @@
1
+ from .container import bgcontainer, Container, pyimage
1
2
  from .files import Files
2
3
  from .pipify import InstallDeps
3
4
  from .projectinfo import ProjectInfo, SimpleInstallDeps
4
- from .util import bgcontainer, Excludes, initapt, stderr
5
+ from .util import Excludes, stderr
5
6
  from argparse import ArgumentParser
6
7
  from aridity.config import ConfigCtrl
7
8
  from aridity.util import NoSuchPathException, openresource
8
9
  from diapyr.util import singleton
9
10
  from itertools import chain
10
- from lagoon.program import NOEOL, partial
11
- from lagoon.text import diff, docker, id, pydoc_markdown
11
+ from lagoon.text import diff, pydoc_markdown
12
12
  from pathlib import Path
13
13
  from setuptools import find_packages
14
14
  from shutil import copy2, copytree, ignore_patterns
15
15
  from tempfile import NamedTemporaryFile
16
16
  from urllib.request import urlopen
17
- from venvpool import dotpy, initlogging, Pool, Task, TemporaryDirectory
17
+ from venvpool import dotpy, initlogging, Pool, TemporaryDirectory
18
18
  from xml.sax.saxutils import escape as xml_escape
19
19
  import logging, os, re, sys
20
20
 
@@ -77,14 +77,14 @@ class EveryVersion:
77
77
 
78
78
  def metacheck(self):
79
79
  from .metacheck import metacheck
80
- _runcheck('*', metacheck, self.info.projectdir, self.info.devversion(), self.docker)
80
+ _runcheck('*', metacheck, self.info.projectdir, self.info.devversion(), self.docker) # FIXME: Expect devversion specific to commit being built.
81
81
 
82
82
  def pyflakes(self):
83
83
  paths = [str(path) for excludes in [Excludes(self.info.config.flakes.exclude.globs)]
84
84
  for path in self.files.pypaths if os.path.relpath(path, self.files.root) not in excludes]
85
85
  def pyflakes():
86
86
  if paths:
87
- with Pool(3).readonlyortransient[self.transient](SimpleInstallDeps(['pyflakes'])) as venv:
87
+ with Pool(3).readonly(SimpleInstallDeps(['pyflakes>=3.2'])) as venv:
88
88
  venv.run('check_call', [], 'pyflakes', paths)
89
89
  _runcheck(3, pyflakes)
90
90
 
@@ -92,50 +92,35 @@ class EveryVersion:
92
92
  upstream_devel_packages = list(self.info.config.upstream.devel.packages)
93
93
  upstream_devel_scripts = list(self.info.config.upstream.devel.scripts) if self.userepo else []
94
94
  with InstallDeps(self.info, self.siblings, _localrepo() if self.userepo else None) as installdeps:
95
- installdeps.add('nose-cov', *self.info.config.test.requires) # TODO: Facility to freeze test requires tree.
96
- reportsdir = self.info.projectdir / 'var' / '3'
97
- reportsdir.mkdir(exist_ok = True, parents = True)
98
- xmlpath = reportsdir / 'nosetests.xml'
99
- if self.docker:
100
- coveragepath = self.info.projectdir / '.coverage'
101
- with bgcontainer('-v', "{0}:{0}".format('/var/run/docker.sock'), '--network', 'host', '-v', f"{os.path.abspath(self.info.projectdir)}:{Container.workdir}", f"python:{self.info.pyversiontags[0]}") as container:
102
- container = Container(container)
103
- container.cp(installdeps.workspace, 'installdeps')
104
- container.inituser()
105
- if upstream_devel_packages:
106
- container.initapt()
107
- for command in ['apt-get', 'update'], ['apt-get', 'install', '-y', 'sudo'] + upstream_devel_packages:
108
- container.call(command, check = True, root = True)
109
- for script in upstream_devel_scripts:
110
- dirpath = docker.exec[NOEOL](container.container, 'mktemp', '-d') # No need to cleanup, will die with container.
111
- log.debug("In container dir %s run script: %s", dirpath, script)
112
- docker.exec[print]('-w', dirpath, '-t', container.container, 'sh', '-c', script)
113
- installdeps.cinvoke(container)
114
- cpath = lambda p: os.path.relpath(p, self.info.projectdir).replace(os.sep, '/')
115
- status = container.call([
116
- 'nosetests', '--exe', '-v',
117
- '--with-doctest', '--doctest-extension', '.md',
118
- '--with-xunit', '--xunit-file', cpath(xmlpath),
119
- '--with-cov', '--cov-report', 'term-missing',
120
- ] + sum((['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), []) + [cpath(p) for p in self.files.testpaths(xmlpath)] + self.noseargs)
121
- else:
122
- coveragepath = Path('.coverage')
123
- with Pool(3).readonlyortransient[self.transient](installdeps) as venv:
124
- status = venv.run('call', installdeps.localreqs, Task('''import collections
125
- try:
126
- collections.Callable
127
- except AttributeError:
128
- from collections.abc import Callable
129
- collections.Callable = Callable''', 'nose'), [
130
- '--exe', '-v',
131
- '--with-doctest', '--doctest-extension', '.md',
132
- '--with-xunit', '--xunit-file', xmlpath,
133
- '--with-cov', '--cov-report', 'term-missing',
134
- ] + sum((['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), []) + [str(p) for p in self.files.testpaths(xmlpath)] + self.noseargs)
135
- if coveragepath.exists():
136
- copy2(coveragepath, reportsdir / 'coverage') # Replace whatever the status, as if we configured the location.
137
- coveragepath.unlink() # Can't simply use rename cross-device in release case.
138
- assert not status
95
+ installdeps.add('nose-cov', 'pynose', *self.info.config.test.requires) # TODO: Facility to freeze test requires tree.
96
+ reportsdir = self.info.projectdir / 'var' / '3'
97
+ reportsdir.mkdir(exist_ok = True, parents = True)
98
+ xmlpath = reportsdir / 'nosetests.xml'
99
+ if self.docker:
100
+ coveragepath = self.info.projectdir / '.coverage'
101
+ 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, [])) as container:
102
+ container.cp(installdeps.workspace, 'installdeps')
103
+ container.installasuser(installdeps.containerrequires())
104
+ cpath = lambda p: os.path.relpath(p, self.info.projectdir).replace(os.sep, '/')
105
+ status = container.inworkdir.nosetests[print](
106
+ '--exe', '-v',
107
+ '--with-doctest', '--doctest-extension', '.md',
108
+ '--with-xunit', '--xunit-file', cpath(xmlpath),
109
+ '--with-cov', '--cov-report', 'term-missing',
110
+ *sum((['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), []), *map(cpath, self.files.testpaths(xmlpath)), *self.noseargs, check = False)
111
+ else:
112
+ coveragepath = Path('.coverage')
113
+ with Pool(3).readonlyortransient[self.transient](installdeps) as venv:
114
+ status = venv.run('call', installdeps.localreqs, 'nose', [
115
+ '--exe', '-v',
116
+ '--with-doctest', '--doctest-extension', '.md',
117
+ '--with-xunit', '--xunit-file', xmlpath,
118
+ '--with-cov', '--cov-report', 'term-missing',
119
+ ] + sum((['--cov', p] for p in chain(find_packages(self.info.projectdir), self.info.py_modules())), []) + [str(p) for p in self.files.testpaths(xmlpath)] + self.noseargs)
120
+ if coveragepath.exists():
121
+ copy2(coveragepath, reportsdir / 'coverage') # Replace whatever the status, as if we configured the location.
122
+ coveragepath.unlink() # Can't simply use rename cross-device in release case.
123
+ assert not status
139
124
 
140
125
  def readme(self):
141
126
  def first(scope, resolvable):
@@ -207,33 +192,6 @@ except AttributeError:
207
192
  assert f">{xml_escape(self.info.config.name)} \N{BULLET} {xml_escape(self.info.config.tagline)}<" in f.read().decode('utf-8') # TODO: Deduce encoding, consider lagoon URL.
208
193
  _runcheck('*', linktree)
209
194
 
210
- class Container:
211
-
212
- workdir = '/io'
213
-
214
- def __init__(self, container):
215
- self.uid = int(id._u())
216
- self.gid = int(id._g())
217
- self.container = container
218
-
219
- def inituser(self):
220
- docker.exec[print](self.container, 'groupadd', '-g', os.stat('/var/run/docker.sock').st_gid, 'docker')
221
- docker.exec[print](self.container, 'groupadd', '-g', self.gid, 'pyvengroup')
222
- docker.exec[print](self.container, 'useradd', '-g', self.gid, '-G', 'docker', '-u', self.uid, '-m', 'pyvenuser')
223
-
224
- def initapt(self):
225
- initapt(docker.exec[partial, print](self.container))
226
-
227
- def install(self, args):
228
- if args:
229
- self.call(['pip', 'install', '--user', *args], check = True)
230
-
231
- def call(self, args, check = False, root = False):
232
- return docker.exec[print]('-w', self.workdir, self.container, *[] if root else ['sudo', '-u', 'pyvenuser', 'PATH=/home/pyvenuser/.local/bin:/usr/local/bin:/usr/bin:/bin', 'env'], *args, check = check)
233
-
234
- def cp(self, src, dest):
235
- docker.cp[print](src, f"{self.container}:{dest}")
236
-
237
195
  def main():
238
196
  initlogging()
239
197
  parser = ArgumentParser()
@@ -0,0 +1,54 @@
1
+ from aridity.config import ConfigCtrl
2
+ from contextlib import contextmanager
3
+ from dkrcache.util import iidfile
4
+ from importlib.resources import files
5
+ from lagoon.program import NOEOL, partial
6
+ from lagoon.text import docker
7
+ from lagoon.util import mapcm
8
+ from pathlib import Path
9
+ from tempfile import TemporaryDirectory
10
+ import os, shlex
11
+
12
+ @contextmanager
13
+ def bgcontainer(*dockerrunargs):
14
+ cid = docker.run._d[NOEOL](*dockerrunargs, 'sleep', 'inf')
15
+ try:
16
+ yield Container(cid)
17
+ finally:
18
+ docker.rm._f[print](cid)
19
+
20
+ def pyimage(pyversiontag, packages, scripts, requires):
21
+ cc = ConfigCtrl()
22
+ cc.execute('package := $list()')
23
+ cc.execute('script := $list()')
24
+ cc.w.docker_gid = Path('/var/run/docker.sock').stat().st_gid
25
+ for p in packages:
26
+ cc.w.package += p
27
+ requires_sh = ' '.join(map(shlex.quote, requires))
28
+ cc.w.pipinstallsh = f"sudo -u pyvenuser pip install --user --no-warn-script-location {requires_sh}" if requires_sh else ':'
29
+ cc.w.pyven_gid = os.getegid()
30
+ cc.w.pyven_uid = os.geteuid()
31
+ cc.w.pyversiontag = pyversiontag
32
+ for script in scripts:
33
+ cc.w.script += script
34
+ with mapcm(Path, TemporaryDirectory()) as tempdir:
35
+ with (files() / 'Dockerfile.aridt').open() as f, (tempdir / 'Dockerfile').open('w') as g:
36
+ cc.processtemplate(f, g)
37
+ with iidfile() as iid:
38
+ docker.build[print](*iid.args, tempdir)
39
+ return iid.read()
40
+
41
+ class Container:
42
+
43
+ workdir = '/io'
44
+
45
+ def __init__(self, cid):
46
+ self.inworkdir = docker.exec[partial]('-w', self.workdir, cid).sudo._u.pyvenuser[partial]('PATH=/home/pyvenuser/.local/bin:/usr/local/bin:/usr/bin:/bin').env
47
+ self.cid = cid
48
+
49
+ def installasuser(self, requires):
50
+ if requires:
51
+ docker.exec[print](self.cid, 'sudo', '-u', 'pyvenuser', 'pip', 'install', '--user', *requires)
52
+
53
+ def cp(self, src, dest):
54
+ docker.cp[print](src, f"{self.cid}:{dest}")
@@ -0,0 +1,39 @@
1
+ from .checks import skip
2
+ from .container import bgcontainer, Container, pyimage
3
+ from .pipify import pipify, setupcommand, setuptoolsreq
4
+ from .projectinfo import ProjectInfo
5
+ from contextlib import contextmanager
6
+ from lagoon.text import diff
7
+ from pathlib import Path
8
+ from shutil import copy2
9
+ from tempfile import TemporaryDirectory
10
+
11
+ @contextmanager
12
+ def egginfodir(projectdir, version, dockerenabled):
13
+ with TemporaryDirectory() as tempdir:
14
+ copy2(projectdir / ProjectInfo.projectaridname, tempdir)
15
+ for glob in 'README.md', 'LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*':
16
+ for p in projectdir.glob(glob):
17
+ copy2(p, tempdir)
18
+ copyinfo = ProjectInfo.seek(tempdir)
19
+ pipify(copyinfo, version)
20
+ if dockerenabled and {'setuptools', 'wheel'} != set(copyinfo.allbuildrequires):
21
+ with bgcontainer('-v', f"{tempdir}:{Container.workdir}", pyimage(copyinfo.pyversiontags[0], [], [], [*copyinfo.allbuildrequires, setuptoolsreq])) as container:
22
+ container.inworkdir.python[print]('setup.py', 'egg_info')
23
+ else:
24
+ setupcommand(copyinfo, False, 'egg_info')
25
+ d, = Path(tempdir).glob('*.egg-info')
26
+ yield tempdir, d
27
+
28
+ def metacheck(projectdir, version, dockerenabled):
29
+ if not (projectdir / ProjectInfo.projectaridname).exists():
30
+ return skip
31
+ with egginfodir(projectdir, version, dockerenabled) as (tempdir, d):
32
+ p = d / 'requires.txt'
33
+ q = projectdir / p.relative_to(tempdir)
34
+ if p.exists():
35
+ diff[print](p, q)
36
+ else:
37
+ assert not q.exists()
38
+ p = d / 'PKG-INFO'
39
+ diff[print](p, projectdir / p.relative_to(tempdir))
@@ -12,9 +12,10 @@ from pkg_resources import resource_filename
12
12
  from shutil import rmtree
13
13
  from tempfile import mkdtemp
14
14
  from venvpool import initlogging, Pool
15
- import logging, os, sys
15
+ import logging, os
16
16
 
17
17
  log = logging.getLogger(__name__)
18
+ setuptoolsreq = 'setuptools>=69.3,<75.8'
18
19
 
19
20
  def pipify(info, version):
20
21
  # Allow release of project without origin:
@@ -73,13 +74,8 @@ def main():
73
74
  setupcommand(info, args.transient, 'egg_info')
74
75
 
75
76
  def setupcommand(info, transient, *command):
76
- def setup(absexecutable):
77
- Program.text(absexecutable)[print]('setup.py', *command, cwd = info.projectdir)
78
- if {'setuptools', 'wheel'} == set(info.allbuildrequires):
79
- setup(sys.executable)
80
- else:
81
- with Pool(3).readonlyortransient[transient](SimpleInstallDeps(info.allbuildrequires)) as venv:
82
- setup(venv.programpath('python'))
77
+ with Pool(3).readonlyortransient[transient](SimpleInstallDeps([*info.allbuildrequires, setuptoolsreq])) as venv:
78
+ Program.text(venv.programpath('python'))[print]('setup.py', *command, cwd = info.projectdir)
83
79
 
84
80
  def _metaversion(info):
85
81
  with solo(info.projectdir.glob('*.egg-info/PKG-INFO')).open(encoding = 'utf-8') as f:
@@ -157,8 +153,8 @@ class InstallDeps:
157
153
  def invoke(self, venv):
158
154
  venv.install([str(i.projectdir) for i in self.volatileprojects] + [r.reqstr for r in self.fetchreqs])
159
155
 
160
- def cinvoke(self, container):
161
- container.install([f"/installdeps/{os.path.relpath(i.projectdir, self.workspace).replace(os.sep, '/')}" for i in self.volatileprojects] + [r.reqstr for r in self.fetchreqs])
156
+ def containerrequires(self):
157
+ 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]
162
158
 
163
159
  def __exit__(self, *exc_info):
164
160
  rmtree(self.workspace)
@@ -9,6 +9,7 @@ from inspect import getsource
9
9
  from lagoon.program import Program
10
10
  from lagoon.text import git
11
11
  from pkg_resources import parse_requirements
12
+ from roman import fromRoman, toRoman
12
13
  from setuphacks import getsetupkwargs
13
14
  from urllib.error import HTTPError
14
15
  from urllib.parse import quote as url_quote
@@ -18,6 +19,9 @@ import json, logging, os, re, time, venvpool
18
19
 
19
20
  log = logging.getLogger(__name__)
20
21
 
22
+ def toreleasetag(versionno):
23
+ return f"release/{toRoman(versionno).lower()}"
24
+
21
25
  class ProjectInfoNotFoundException(Exception): pass
22
26
 
23
27
  class Req:
@@ -137,11 +141,11 @@ class ProjectInfo:
137
141
 
138
142
  def __init__(self, projectdir, infopathorstream):
139
143
  cc = ConfigCtrl()
140
- Resource(__name__, 'projectinfo.arid', 'utf-8').source(cc.scope(), Entry([]))
144
+ Resource(__name__, 'projectinfo.arid', 'utf-8').source(cc.scope(), Entry([])) # TODO: Should be explicit project.arid include.
141
145
  cc.load(infopathorstream)
142
146
  self.allbuildrequires = list(cc.r.build.requires)
143
147
  self.allrequires = list(cc.r.requires)
144
- self.pyversiontags = list(cc.r.pyversiontag)
148
+ self.pyversiontags = list(map(str, cc.r.pyversiontag)) # TODO: API to unparse instead of best scalar.
145
149
  self.config = cc.node
146
150
  self.projectdir = projectdir
147
151
 
@@ -187,13 +191,18 @@ class ProjectInfo:
187
191
  def console_scripts(self):
188
192
  return [mm.console_script for mm in self.mainmodules()]
189
193
 
194
+ def releases(self):
195
+ for tag in git.tag(cwd = self.projectdir).splitlines():
196
+ m = re.fullmatch('release/(.+)', tag)
197
+ if m is not None:
198
+ versionstr = m.group(1)
199
+ try:
200
+ yield int(versionstr)
201
+ except ValueError:
202
+ yield fromRoman(versionstr)
203
+
190
204
  def devversion(self):
191
- def releases():
192
- for tag in git.tag(cwd = self.projectdir).splitlines():
193
- m = re.fullmatch('release/(.+)', tag)
194
- if m is not None:
195
- yield int(m.group(1))
196
- return f"{max(releases(), default = 0) + 1}.dev0"
205
+ return f"{max(self.releases(), default = 0) + 1}.dev0"
197
206
 
198
207
  class MainModule:
199
208
 
@@ -1,8 +1,10 @@
1
1
  account = $(void)
2
2
  cli
3
3
  path = $(void)
4
+ retry = $(void)
4
5
  upload = $(void)
5
6
  golden_remote = $(void)
6
7
  path = $(cli path)
8
+ retry = $(cli retry)
7
9
  token = $gpg$(token_gpg $(account))
8
10
  upload = $(cli upload)
@@ -1,9 +1,9 @@
1
1
  'Release project to PyPI, with manylinux wheels as needed.'
2
2
  from .checks import EveryVersion
3
- from .pipify import InstallDeps, pipify
4
- from .projectinfo import ProjectInfo, SimpleInstallDeps
3
+ from .container import bgcontainer
4
+ from .pipify import InstallDeps, pipify, setuptoolsreq
5
+ from .projectinfo import ProjectInfo, SimpleInstallDeps, toreleasetag
5
6
  from .sourceinfo import SourceInfo
6
- from .util import bgcontainer
7
7
  from argparse import ArgumentParser
8
8
  from aridity.config import ConfigCtrl
9
9
  from diapyr.util import singleton
@@ -63,44 +63,20 @@ class Image:
63
63
  # TODO: Copy not mount so we can run containers in parallel.
64
64
  with bgcontainer('-v', f"{info.projectdir}:/io", f"{self.prefix}{self.plat}:{self.imagetag}") as container:
65
65
  def run(execargs, command):
66
- docker.exec[print](*execargs, container, *self.arch.entrypoint, *command)
66
+ docker.exec[print](*execargs, container.cid, *self.arch.entrypoint, *command)
67
67
  if packages:
68
68
  run([], chain(['yum', 'install', '-y'], packages))
69
69
  for script in scripts:
70
70
  # TODO LATER: Run as ordinary sudo-capable user.
71
- dirpath = docker.exec[NOEOL](container, 'mktemp', '-d') # No need to cleanup, will die with container.
71
+ dirpath = docker.exec[NOEOL](container.cid, 'mktemp', '-d') # No need to cleanup, will die with container.
72
72
  log.debug("In container dir %s run script: %s", dirpath, script)
73
73
  run(['-w', dirpath, '-t'], ['sh', '-c', script])
74
- docker.cp[print](resource_filename(__name__, 'patchpolicy.py'), f"{container}:/patchpolicy.py")
74
+ docker.cp[print](resource_filename(__name__, 'patchpolicy.py'), f"{container.cid}:/patchpolicy.py")
75
75
  run([], [self.pythonexe, '/patchpolicy.py'])
76
- docker.cp[print](resource_filename(__name__, 'bdist.py'), f"{container}:/bdist.py")
76
+ docker.cp[print](resource_filename(__name__, 'bdist.py'), f"{container.cid}:/bdist.py")
77
77
  run(['-u', f"{os.geteuid()}:{os.getegid()}", '-w', '/io'], [self.pythonexe, '/bdist.py', '--plat', self.plat])
78
78
 
79
- def main():
80
- initlogging()
81
- config = ConfigCtrl().loadappconfig(main, 'release.arid')
82
- parser = ArgumentParser()
83
- parser.add_argument('--upload', action = 'store_true')
84
- parser.add_argument('path', nargs = '?', default = '.')
85
- parser.parse_args(namespace = config.cli)
86
- # XXX: Load info config to a scope in our config?
87
- info = ProjectInfo.seek(config.path)
88
- config.account = info.config.pypi.account
89
- srcgit = git[partial](cwd = info.projectdir)
90
- if srcgit.status.__porcelain():
91
- raise Exception('Uncommitted changes!')
92
- log.debug('No uncommitted changes.')
93
- with TemporaryDirectory() as tempdir:
94
- copydir = os.path.join(tempdir, os.path.basename(os.path.abspath(info.projectdir)))
95
- log.info("Copying project to: %s", copydir)
96
- copytree(info.projectdir, copydir)
97
- for relpath in _release(config, srcgit, ProjectInfo.seek(copydir)):
98
- log.info("Replace artifact: %s", relpath)
99
- destpath = info.projectdir / relpath
100
- destpath.parent.mkdir(exist_ok = True, parents = True)
101
- copy2(os.path.join(copydir, relpath), destpath)
102
-
103
- def uploadableartifacts(artifactrelpaths):
79
+ def _uploadableartifacts(artifactrelpaths):
104
80
  def acceptplatform(platform):
105
81
  return 'any' == platform or platform.startswith('manylinux')
106
82
  platformmatch = re.compile('-([^-]+)[.]whl$').search
@@ -122,7 +98,7 @@ def _textcontent(node):
122
98
  yield value
123
99
  return ''.join(iterparts(node))
124
100
 
125
- def _nextversionno(name): # XXX: Deduce from tags instead?
101
+ def _nextversionno(name):
126
102
  pattern = re.compile('-([0-9]+)[-.]')
127
103
  try:
128
104
  with urlopen(f"https://pypi.org/simple/{name}/") as f:
@@ -146,16 +122,15 @@ def _warmups(info):
146
122
  venv.run('check_call', ['.'] + installdeps.localreqs, os.path.basename(script.name)[:-len(dotpy)], [], cwd = info.projectdir)
147
123
 
148
124
  def _runsetup(info, commands):
149
- with Pool(3).readonly(SimpleInstallDeps(info.allbuildrequires)) as venv: # TODO: Newer setuptools for PEP 625.
125
+ with Pool(3).readonly(SimpleInstallDeps([*info.allbuildrequires, setuptoolsreq])) as venv:
150
126
  venv.run('check_call', ['.'], 'setup', commands, cwd = info.projectdir) # XXX: Should venvpool automatically include current dir?
151
127
 
152
- def _release(config, srcgit, info):
128
+ def _release(config, srcgit, versionno, info):
153
129
  (info.projectdir / '.git' / 'hooks' / 'post-commit').unlink()
154
130
  copygit = git[partial](cwd = info.projectdir)
155
131
  scrub = copygit.clean._xdi[partial, print](input = 'c')
156
132
  scrub()
157
- versionno = _nextversionno(info.config.name)
158
- releasetag = f"release/{versionno}"
133
+ releasetag = toreleasetag(versionno)
159
134
  if releasetag not in copygit.tag.__points_at().splitlines():
160
135
  pkginfo, = info.projectdir.glob('*.egg-info/PKG-INFO')
161
136
  lines = pkginfo.read_text('utf-8').splitlines(True)
@@ -184,13 +159,42 @@ def _release(config, srcgit, info):
184
159
  else:
185
160
  setupcommands.append('bdist_wheel')
186
161
  _runsetup(info, setupcommands + ['sdist'])
187
- artifactrelpaths = [os.path.join(distrelpath, name) for name in sorted(os.listdir(info.projectdir / distrelpath))]
162
+ return [os.path.join(distrelpath, name) for name in sorted(os.listdir(info.projectdir / distrelpath))]
163
+
164
+ def main():
165
+ initlogging()
166
+ config = ConfigCtrl().loadappconfig(main, 'release.arid')
167
+ parser = ArgumentParser()
168
+ parser.add_argument('--retry', action = 'store_true')
169
+ parser.add_argument('--upload', action = 'store_true')
170
+ parser.add_argument('path', nargs = '?', default = '.')
171
+ parser.parse_args(namespace = config.cli)
172
+ info = ProjectInfo.seek(config.path)
173
+ config.account = info.config.pypi.account # XXX: Load info config to a scope in our config?
174
+ srcgit = git[partial](cwd = info.projectdir)
175
+ if srcgit.status.__porcelain():
176
+ raise Exception('Uncommitted changes!')
177
+ log.debug('No uncommitted changes.')
178
+ versionno = _nextversionno(info.config.name)
179
+ if config.retry:
180
+ 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)
181
+ else:
182
+ with TemporaryDirectory() as tempdir:
183
+ copydir = os.path.join(tempdir, os.path.basename(os.path.abspath(info.projectdir)))
184
+ log.info("Copying project to: %s", copydir)
185
+ copytree(info.projectdir, copydir)
186
+ allrelpaths = _release(config, srcgit, versionno, ProjectInfo.seek(copydir))
187
+ for relpath in allrelpaths:
188
+ log.info("Replace artifact: %s", relpath)
189
+ destpath = info.projectdir / relpath
190
+ destpath.parent.mkdir(exist_ok = True, parents = True)
191
+ copy2(os.path.join(copydir, relpath), destpath)
192
+ uploadablerelpaths = _uploadableartifacts(allrelpaths)
188
193
  if config.upload:
189
194
  with config.token as token:
190
- Program.text(sys.executable)._m.twine.upload[print]('-u', '__token__', '-p', token, *uploadableartifacts(artifactrelpaths), cwd = info.projectdir, env = Pip.envpatch)
195
+ Program.text(sys.executable)._m.twine.upload[print]('-u', '__token__', '-p', token, *uploadablerelpaths, cwd = info.projectdir, env = Pip.envpatch)
191
196
  else:
192
- log.warning("Upload skipped, use --upload to upload: %s", ' '.join(uploadableartifacts(artifactrelpaths)))
193
- return artifactrelpaths
197
+ log.warning("Upload skipped, use --upload to upload: %s", ' '.join(map(str, uploadablerelpaths)))
194
198
 
195
199
  if '__main__' == __name__:
196
200
  main()
@@ -0,0 +1,35 @@
1
+ 'Check last release can be installed from PyPI and its tests still pass, for use by CI.'
2
+ from .checks import EveryVersion
3
+ from .container import bgcontainer, pyimage
4
+ from .projectinfo import ProjectInfo, toreleasetag
5
+ from argparse import ArgumentParser
6
+ from lagoon.text import git
7
+ from roman import fromRoman
8
+ from venvpool import initlogging
9
+ import logging, re
10
+
11
+ log = logging.getLogger(__name__)
12
+
13
+ def main():
14
+ initlogging()
15
+ parser = ArgumentParser()
16
+ parser.add_argument('branch')
17
+ branch = parser.parse_args().branch
18
+ headinfo = ProjectInfo.seek('.')
19
+ if not headinfo.config.pypi.participant: # XXX: Or look for tags?
20
+ log.info('Not user-installable.')
21
+ return
22
+ project = headinfo.config.name
23
+ releasematch = re.fullmatch('release/(.+)', branch)
24
+ versionno = max(headinfo.releases()) if releasematch is None else fromRoman(releasematch.group(1))
25
+ req = f"{project}=={versionno}"
26
+ upstream_devel_packages = list(headinfo.config.upstream.devel.packages)
27
+ for pyversion in reversed(headinfo.pyversiontags):
28
+ log.info("Python version: %s", pyversion)
29
+ with bgcontainer(pyimage(pyversion, upstream_devel_packages, [], [])) as container:
30
+ container.installasuser([req])
31
+ git.checkout[print](toreleasetag(versionno))
32
+ EveryVersion(ProjectInfo.seek('.'), False, False, [], True, True).nose()
33
+
34
+ if '__main__' == __name__:
35
+ main()
@@ -1,6 +1,3 @@
1
- from contextlib import contextmanager
2
- from lagoon.program import NOEOL
3
- from lagoon.text import docker
4
1
  from pathlib import Path
5
2
  import os, re, sys
6
3
 
@@ -46,16 +43,3 @@ class Seek:
46
43
  if os.path.abspath(parent) == os.path.abspath(dirpath):
47
44
  break
48
45
  dirpath = parent
49
-
50
- @contextmanager
51
- def bgcontainer(*dockerrunargs):
52
- container = docker.run._d[NOEOL](*dockerrunargs + ('sleep', 'inf'))
53
- try:
54
- yield container
55
- finally:
56
- docker.rm._f[print](container)
57
-
58
- def initapt(dockerexec):
59
- dockerexec('mkdir', '-pv', '/etc/apt/keyrings')
60
- dockerexec('curl', '-fsSL', 'https://download.docker.com/linux/debian/gpg', '-o', '/etc/apt/keyrings/docker.asc')
61
- dockerexec('sh', '-c', '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')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyven
3
- Version: 108
3
+ Version: 110
4
4
  Summary: Manage development of multiple Python projects
5
5
  Home-page: https://pypi.org/project/pyven/
6
6
  Author: Homsar
@@ -10,6 +10,7 @@ Requires-Dist: aridity>=77
10
10
  Requires-Dist: diapyr>=31
11
11
  Requires-Dist: lagoon>=49
12
12
  Requires-Dist: pydoc-markdown>=3.3
13
+ Requires-Dist: roman>=5
13
14
  Requires-Dist: setuptools>=44.1.1
14
15
  Requires-Dist: twine>=1.15.0
15
16
  Requires-Dist: venvpool>=14
@@ -1,9 +1,11 @@
1
1
  README.md
2
2
  setup.py
3
+ pyven/Dockerfile.aridt
3
4
  pyven/README.md.aridt
4
5
  pyven/__init__.py
5
6
  pyven/bdist.py
6
7
  pyven/checks.py
8
+ pyven/container.py
7
9
  pyven/execcheck.py
8
10
  pyven/files.py
9
11
  pyven/functions.py
@@ -2,6 +2,7 @@ aridity>=77
2
2
  diapyr>=31
3
3
  lagoon>=49
4
4
  pydoc-markdown>=3.3
5
+ roman>=5
5
6
  setuptools>=44.1.1
6
7
  twine>=1.15.0
7
8
  venvpool>=14
@@ -49,13 +49,13 @@ class SourceInfo:
49
49
  sourceinfo = SourceInfo('.')
50
50
  setup(
51
51
  name = 'pyven',
52
- version = '108',
52
+ version = '110',
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>=77', 'diapyr>=31', 'lagoon>=49', 'pydoc-markdown>=3.3', 'setuptools>=44.1.1', 'twine>=1.15.0', 'venvpool>=14'],
58
+ install_requires = ['aridity>=77', 'diapyr>=31', 'lagoon>=49', 'pydoc-markdown>=3.3', 'roman>=5', 'setuptools>=44.1.1', 'twine>=1.15.0', 'venvpool>=14'],
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(),
@@ -1,53 +0,0 @@
1
- from .checks import Container, skip
2
- from .pipify import pipify, setupcommand
3
- from .projectinfo import ProjectInfo
4
- from .util import bgcontainer
5
- from contextlib import contextmanager
6
- from lagoon.text import diff
7
- from pathlib import Path
8
- from shutil import copy2
9
- from tempfile import TemporaryDirectory
10
- import re, sys
11
-
12
- @contextmanager
13
- def egginfodir(projectdir, version, dockerenabled):
14
- with TemporaryDirectory() as tempdir:
15
- copy2(projectdir / ProjectInfo.projectaridname, tempdir)
16
- try:
17
- copy2(projectdir / 'README.md', tempdir)
18
- except FileNotFoundError:
19
- pass
20
- copyinfo = ProjectInfo.seek(tempdir)
21
- pipify(copyinfo, version)
22
- if dockerenabled and {'setuptools', 'wheel'} != set(copyinfo.allbuildrequires):
23
- with bgcontainer('-v', f"{tempdir}:{Container.workdir}", f"python:{copyinfo.pyversiontags[0]}") as container:
24
- container = Container(container)
25
- container.inituser()
26
- for command in ['apt-get', 'update'], ['apt-get', 'install', '-y', 'sudo']:
27
- container.call(command, check = True, root = True)
28
- container.call(['pip', 'install', '--upgrade', 'setuptools'], check = True, root = True)
29
- container.call(['pip', 'install', *copyinfo.allbuildrequires], check = True, root = True)
30
- container.call(['python', 'setup.py', 'egg_info'], check = True)
31
- else:
32
- setupcommand(copyinfo, False, 'egg_info')
33
- d, = Path(tempdir).glob('*.egg-info')
34
- yield tempdir, d
35
-
36
- linematch = re.compile('[^<>]|(?:> Requires-Dist|> License-File|[<>] Metadata-Version|< Dynamic): ').match
37
-
38
- def metacheck(projectdir, version, dockerenabled):
39
- if not (projectdir / ProjectInfo.projectaridname).exists():
40
- return skip
41
- with egginfodir(projectdir, version, dockerenabled) as (tempdir, d):
42
- p = d / 'requires.txt'
43
- q = projectdir / p.relative_to(tempdir)
44
- if p.exists():
45
- diff[print](p, q)
46
- else:
47
- assert not q.exists()
48
- p = d / 'PKG-INFO'
49
- q = projectdir / p.relative_to(tempdir)
50
- assert q.exists()
51
- text = diff(p, q, check = False).stdout
52
- sys.stdout.write(text)
53
- assert all(linematch(l) is not None for l in text.splitlines())
@@ -1,38 +0,0 @@
1
- 'Check last release can be installed from PyPI and its tests still pass, for use by CI.'
2
- from .checks import EveryVersion
3
- from .projectinfo import ProjectInfo
4
- from .util import bgcontainer, initapt
5
- from lagoon.program import partial
6
- from lagoon.text import docker, git
7
- from urllib.request import urlopen
8
- from venvpool import initlogging
9
- import logging, xml.etree.ElementTree as ET
10
-
11
- log = logging.getLogger(__name__)
12
-
13
- def main():
14
- initlogging()
15
- headinfo = ProjectInfo.seek('.')
16
- if not headinfo.config.pypi.participant: # XXX: Or look for tags?
17
- log.info('Not user-installable.')
18
- return
19
- project = headinfo.config.name
20
- # XXX: When building a tag use that same version?
21
- with urlopen(f"https://pypi.org/rss/project/{project}/releases.xml") as f:
22
- version = ET.parse(f).find('./channel/item/title').text
23
- req = f"{project}=={version}"
24
- upstream_devel_packages = list(headinfo.config.upstream.devel.packages)
25
- for pyversion in reversed(headinfo.pyversiontags):
26
- log.info("Python version: %s", pyversion)
27
- with bgcontainer(f"python:{pyversion}") as container:
28
- containerexec = docker.exec[partial, print](container)
29
- if upstream_devel_packages:
30
- initapt(containerexec)
31
- containerexec('apt-get', 'update')
32
- containerexec('apt-get', 'install', '-y', *upstream_devel_packages)
33
- containerexec('pip', 'install', req)
34
- git.checkout[print](f"release/{version}")
35
- EveryVersion(ProjectInfo.seek('.'), False, False, [], True, True).nose()
36
-
37
- if '__main__' == __name__:
38
- 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