Skip to content

Commit b2c33f8

Browse files
authored
Merge pull request #507 from citrus-it/py313
pkg: ship python 3.13 modules
2 parents 1cb8ae2 + 8b32f43 commit b2c33f8

18 files changed

+3439
-165
lines changed

src/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,5 @@ $(TESTRESULTS): $(PYTESTS)
101101

102102
FRC:
103103

104+
.NO_PARALLEL: $(PYTESTS)
105+

src/Makefile.com

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ CFLAGS = -m64 -Wall -Werror -Wextra -gdwarf-2 -gstrict-dwarf \
3434
CPPFLAGS = -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
3535

3636
# Whitespace separated list of versions to build and test.
37-
PYVERSIONS = 3.12
37+
PYVERSIONS = 3.12 3.13
3838
# The single version used for shebang lines and packaging.
3939
PYVER = 3.12
4040

src/brand/bhyve/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
22
# This file was automatically produced by tools/updatereqs
3-
# Generated on Tue Nov 12 15:34:50 UTC 2024
3+
# Generated on Sun Dec 29 15:47:15 UTC 2024
44
# Do not edit directly
55
#
66
construct==2.10.70
77
PyYAML==6.0.2
8-
wheel==0.45.0
8+
wheel==0.45.1

src/modules/misc.py

-21
Original file line numberDiff line numberDiff line change
@@ -3212,27 +3212,6 @@ def cmp(a, b):
32123212
return NotImplemented
32133213

32143214

3215-
def set_memory_limit(bytes, allow_override=True):
3216-
"""Limit memory consumption of current process to 'bytes'.
3217-
This only limits the brk() and mmap() calls made by python."""
3218-
3219-
if allow_override:
3220-
try:
3221-
bytes = int(os.environ["PKG_CLIENT_MAX_PROCESS_SIZE"])
3222-
except (KeyError, ValueError):
3223-
pass
3224-
3225-
try:
3226-
resource.setrlimit(resource.RLIMIT_VMEM, (bytes, bytes))
3227-
except AttributeError:
3228-
# If platform doesn't support RLIMIT_VMEM, just ignore it.
3229-
pass
3230-
except ValueError:
3231-
# An unprivileged user can not raise a previously set limit,
3232-
# if that ever happens, just ignore it.
3233-
pass
3234-
3235-
32363215
def force_bytes(s, encoding="utf-8", errors="strict"):
32373216
"""Force the string into bytes."""
32383217

src/modules/p5p.py

-4
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,6 @@ def add(self, pathname, arcname=None):
598598
self.__queue_offset += entry_sz
599599
self.__queue.append((pathname, ti.name))
600600

601-
# Discard tarinfo; it would be more efficient to keep these in
602-
# memory, but at a significant memory footprint cost.
603-
ti.tarfile = None
604601
del ti
605602

606603
def __add_publisher_files(
@@ -1311,7 +1308,6 @@ def close(self, progtrack=None):
13111308
ti = tfile.members.pop()
13121309
if progtrack:
13131310
progtrack.archive_add_progress(1, tfile.offset - start_offset)
1314-
ti.tarfile = None
13151311
del ti
13161312

13171313
# Cleanup temporary files.

src/pkg/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ INCORP = consolidation\:ips\:ips-incorporation
108108

109109
PM_TRANSFORMS = defaults
110110
# For python version migrations
111-
#PM_TRANSFORMS += pynext
111+
PM_TRANSFORMS += pynext
112112

113113
i386_DEFINES = \
114114
i386_ONLY='' \

src/pkg/external_deps.txt

+13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
pkg:/library/python-3/rapidjson-312
1212
pkg:/library/python-3/setuptools-312
1313
#
14+
pkg:/runtime/python-313
15+
pkg:/library/python-3/cffi-313
16+
pkg:/library/python-3/coverage-313
17+
pkg:/library/python-3/cryptography-313
18+
pkg:/library/python-3/jsonrpclib-313
19+
pkg:/library/python-3/jsonschema-313
20+
pkg:/library/python-3/pybonjour-313
21+
pkg:/library/python-3/pycurl-313
22+
pkg:/library/python-3/pyopenssl-313
23+
pkg:/library/python-3/rapidjson-313
24+
pkg:/library/python-3/setuptools-313
25+
#
1426
pkg:/system/library/python/libbe-312
27+
pkg:/system/library/python/libbe-313
1528
#
1629
pkg:/SUNWcs
1730
pkg:/archiver/gnu-tar

src/pkg/manifests/package:pkg-35.p5m

-26
This file was deleted.

src/pkg/manifests/package:pkg.p5m

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#
2929
<include bundledlicences.3.12.core.p5m>
3030
<include bundledmodules.3.12.core.p5m>
31+
<include bundledmodules.3.13.core.p5m>
3132
set name=pkg.fmri value=pkg:/package/pkg@$(PKGVERS)
3233
set name=pkg.summary value="Image Packaging System - pkg(7)"
3334
set name=pkg.description \

src/pkg/manifests/system:zones:brand:bhyve.p5m

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
<include bundledlicences.3.12.bhyve.p5m>
1717
<include bundledmodules.3.12.bhyve.p5m>
18+
<include bundledmodules.3.13.bhyve.p5m>
1819
set name=pkg.fmri value=pkg:/system/zones/brand/bhyve@$(PKGVERS)
1920
set name=pkg.summary value="Image Packaging System branded zone - bhyve zones"
2021
set name=pkg.description value="Support for bhyve branded zones"

src/pkg/transforms/pynext

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
# version of python alongside the existing ones to aid transition or
1616
# testing
1717

18+
<transform dir path=$(PYDIR)$ -> emit %(action.name) path=TBD%(path) >
19+
1820
<transform file dir path=$(PYDIRVP) -> \
1921
emit %(action.name) path=TBD%(path) \
2022
pkg.depend.bypass-generate=%(pkg.depend.bypass-generate;notfound='notfound')>
2123

22-
<transform path=TBD -> delete pkg.depend.bypass-generate notfound>
24+
<transform file path=usr/lib/brand/bhyve/(uefi/)?__pycache__/ -> \
25+
emit %(action.name) path=TBD%(path) \
26+
pkg.depend.bypass-generate=%(pkg.depend.bypass-generate;notfound='notfound')>
2327

24-
# Deliver 3.12 modules alongside the 3.11 ones (temporary, during migration)
25-
<transform path=TBD -> edit path 312 311>
26-
<transform path=TBD -> edit path 3.12 3.11>
28+
<transform path=TBD -> delete pkg.depend.bypass-generate notfound>
2729

28-
# During the 3.11 to 3.12 upgrade, we need to also translate the loadable
29-
# module names as they were unqualified with 3.11
30-
<transform path=TBD -> edit path cpython-311-$(TRIPLE) cpython-311>
30+
# Deliver new modules alongside the old ones (temporary, during migration)
31+
<transform path=TBD -> edit path 312 313>
32+
<transform path=TBD -> edit path 3.12 3.13>
3133

3234
<transform path=TBD -> edit path TBD ''>
3335

src/pull.py

-3
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ def main_func():
464464

465465
temp_root = misc.config_temp_root()
466466

467-
# set process limits for memory consumption to 8GB
468-
misc.set_memory_limit(8 * 1024 * 1024 * 1024)
469-
470467
global_settings.client_name = "pkgrecv"
471468
target = os.environ.get("PKG_DEST", None)
472469
src_uri = os.environ.get("PKG_SRC", None)

src/requirements-aarch64.txt

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ ply==3.11
1818
portend==3.1.0
1919
prettytable==3.7.0
2020
pybonjour @ https://mirrors.omnios.org/pymodules/pybonjour/pybonjour-1.1.1-python3.tar.gz#sha256
21-
pycurl==7.44.1 # stuck on 7.44.1 - https://github.com/pycurl/pycurl/issues/748
2221
pydantic==1.10.18
2322
pytz==2023.3
2423
tempora==5.2.2

src/requirements.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# This file was automatically produced by tools/updatereqs
3-
# Generated on Tue Nov 12 15:34:30 UTC 2024
3+
# Generated on Sun Dec 29 15:46:58 UTC 2024
44
# Do not edit directly
55
#
66
autocommand==2.2.2
@@ -10,18 +10,17 @@ jaraco.collections==5.1.0
1010
jaraco.context==6.0.1
1111
jaraco.functools==4.1.0
1212
jaraco.text==4.0.0
13-
Mako==1.3.6
13+
Mako==1.3.8
1414
MarkupSafe==3.0.2
1515
more-itertools==10.5.0
1616
ply==3.11
1717
portend==3.2.0
1818
prettytable==3.12.0
1919
pybonjour @ https://mirrors.omnios.org/pymodules/pybonjour/pybonjour-1.1.1-python3.tar.gz#sha256
20-
pycurl==7.44.1 # stuck on 7.44.1 - https://github.com/pycurl/pycurl/issues/748
2120
python-dateutil==2.9.0.post0
22-
setuptools==75.4.0
23-
six==1.16.0
21+
setuptools==75.6.0
22+
six==1.17.0
2423
tempora==5.7.0
2524
wcwidth==0.2.13
26-
wheel==0.45.0
25+
wheel==0.45.1
2726
zc.lockfile==3.0.post1

src/tests/api/t_misc.py

-88
Original file line numberDiff line numberDiff line change
@@ -115,94 +115,6 @@ def test_psinfo(self):
115115
libc = ctypes.CDLL("libc.so")
116116
self.assertEqual(psinfo.pr_zoneid, libc.getzoneid())
117117

118-
def test_memory_limit(self):
119-
"""Verify that set_memory_limit works."""
120-
121-
# memory limit to test, keep small to avoid test slowdown
122-
mem_cap = 100 * 1024 * 1024
123-
# measured process resources. Note, that we have a static
124-
# overhead in waste.py for the forking of ps, so while 20M seems
125-
# large compared to a 100M limit, in a real world example with
126-
# 8G limit it's fairly small.
127-
mem_tol = 20 * 1024 * 1024
128-
129-
waste_mem_py = """
130-
import os
131-
import resource
132-
import subprocess
133-
134-
import pkg.misc as misc
135-
136-
misc.set_memory_limit({0})
137-
i = 0
138-
x = {{}}
139-
try:
140-
while True:
141-
i += 1
142-
x[i] = range(i)
143-
except MemoryError:
144-
# give us some breathing room (enough so the test with env var works)
145-
misc.set_memory_limit({0} * 3, allow_override=False)
146-
print(subprocess.check_output(['ps', '-o', 'rss=', '-p',
147-
str(os.getpid())], universal_newlines=True).strip())
148-
""".format(
149-
str(mem_cap)
150-
)
151-
152-
# Re-setting limits which are higher than original limit can
153-
# only be done by root.
154-
self.assertTrue(os.geteuid() == 0, "must be root to run this test")
155-
156-
tmpdir = tempfile.mkdtemp(dir=self.test_root)
157-
tmpfile = os.path.join(tmpdir, "waste.py")
158-
with open(tmpfile, "w") as f:
159-
f.write(waste_mem_py)
160-
161-
pyv = ".".join(platform.python_version_tuple()[:2])
162-
163-
res = int(subprocess.check_output([f"python{pyv}", tmpfile]))
164-
# convert from kB to bytes
165-
res *= 1024
166-
167-
self.debug("mem_cap: " + str(mem_cap))
168-
self.debug("proc size: " + str(res))
169-
170-
self.assertTrue(
171-
res < mem_cap + mem_tol, "process mem consumption too high"
172-
)
173-
self.assertTrue(
174-
res > mem_cap - mem_tol, "process mem consumption too low"
175-
)
176-
177-
# test if env var works
178-
os.environ["PKG_CLIENT_MAX_PROCESS_SIZE"] = str(mem_cap * 2)
179-
res = int(subprocess.check_output([f"python{pyv}", tmpfile]))
180-
res *= 1024
181-
182-
self.debug("mem_cap: " + str(mem_cap))
183-
self.debug("proc size: " + str(res))
184-
185-
self.assertTrue(
186-
res < mem_cap * 2 + mem_tol, "process mem consumption too high"
187-
)
188-
# self.assertTrue(res > mem_cap * 2 - mem_tol,
189-
# "process mem consumption too low")
190-
191-
# test if invalid env var is handled correctly
192-
os.environ["PKG_CLIENT_MAX_PROCESS_SIZE"] = "octopus"
193-
res = int(subprocess.check_output([f"python{pyv}", tmpfile]))
194-
res *= 1024
195-
196-
self.debug("mem_cap: " + str(mem_cap))
197-
self.debug("proc size: " + str(res))
198-
199-
self.assertTrue(
200-
res < mem_cap + mem_tol, "process mem consumption too high"
201-
)
202-
self.assertTrue(
203-
res > mem_cap - mem_tol, "process mem consumption too low"
204-
)
205-
206118

207119
if __name__ == "__main__":
208120
unittest.main()

0 commit comments

Comments
 (0)