Skip to content

Commit 89d2d5f

Browse files
Update test_zlib and configure
1 parent 0f1090b commit 89d2d5f

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

Lib/test/test_zlib.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import random
88
import sys
99
from test.support import bigmemtest, _1G, _4G, is_s390x
10+
import importlib
1011

1112
# Building CPython without zlib is not supported except WASI.
1213
#
@@ -16,7 +17,12 @@
1617
#
1718
# For tests to pass without zlib, this file needs to be removed.
1819

19-
zlib = import_helper.import_module('zlib', required_on=('linux', 'android', 'ios', 'darwin', 'win32', 'cygwin'))
20+
try:
21+
zlib = importlib.import_module('zlib')
22+
except ImportError as msg:
23+
if sys.platform.startswith('wasi'):
24+
raise unittest.SkipTest(str(msg))
25+
raise ImportError("Building CPython without zlib is not supported")
2026

2127
requires_Compress_copy = unittest.skipUnless(
2228
hasattr(zlib.compressobj(), "copy"),

configure

Lines changed: 16 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,7 +5327,6 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib
53275327

53285328
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
53295329
have_zlib=yes
5330-
dnl zlib 1.2.0 (2003) added inflateCopy
53315330
AC_DEFINE([HAVE_ZLIB_COPY], [1])
53325331
], [
53335332
WITH_SAVE_ENV([
@@ -5339,18 +5338,27 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
53395338
AS_VAR_IF([have_zlib], [yes], [
53405339
ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
53415340
ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
5342-
BINASCII_CFLAGS="$ZLIB_CFLAGS"
5343-
BINASCII_LIBS="$ZLIB_LIBS"
53445341
PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
53455342
])
53465343
])
53475344
])
5348-
5349-
dnl wasi does not support zlib
5350-
AS_VAR_IF([have_zlib], [no], [
5351-
BINASCII_CFLAGS="-DNO_ZLIB_CRC32"
5352-
BINASCII_LIBS=""
5353-
])
5345+
dnl temporarily throw only errors on builds other than wasi until wasi supports zlib
5346+
AS_CASE([$ac_sys_system],
5347+
[WASI], [
5348+
BINASCII_CFLAGS="-DNO_ZLIB_CRC32"
5349+
BINASCII_LIBS=""
5350+
],
5351+
[*], [
5352+
if test "$have_zlib" != "yes"; then
5353+
AC_MSG_ERROR([m4_normalize([
5354+
zlib.h and libz are required. Install your OS's zlib-devel or
5355+
zlib1g-dev equivalent library or get it from https://zlib.net/.
5356+
])])
5357+
fi
5358+
BINASCII_CFLAGS="$ZLIB_CFLAGS"
5359+
BINASCII_LIBS="$ZLIB_LIBS"
5360+
]
5361+
)
53545362

53555363
dnl detect bzip2 from Emscripten emport
53565364
PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])

0 commit comments

Comments
 (0)