Skip to content

Commit

Permalink
Merge branch 'lxml-5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed May 11, 2024
2 parents 762d7bf + ddaa6ed commit bdd7183
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 70 deletions.
43 changes: 4 additions & 39 deletions .github/workflows/ci.yml
Expand Up @@ -129,6 +129,10 @@ jobs:
exclude:
- os: ubuntu-latest
python-version: "3.6"
- os: macos-latest
python-version: "3.6"
- os: macos-latest
python-version: "3.7"

# Windows sub-jobs
# ==============
Expand Down Expand Up @@ -213,42 +217,3 @@ jobs:
name: pycoverage_html
path: coverage*
if-no-files-found: ignore

- name: Upload Wheel
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: matrix.env.STATIC_DEPS && !matrix.extra_hash
with:
name: wheels-${{ runner.os }}-${{ matrix.python-version }}
path: dist/*.whl
if-no-files-found: ignore

collect-wheels:
needs: [ci]
runs-on: ubuntu-latest
steps:
- name: Collect wheels
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
path: ~/downloads
merge-multiple: true

- name: List downloaded artifacts
run: ls -la ~/downloads

- name: Upload Linux wheels
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: wheels-linux
path: ~/downloads/*linux*.whl

- name: Upload macOS wheels
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: wheels-macosx
path: ~/downloads/*macosx*.whl

- name: Upload Windows wheels
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: wheels-windows
path: ~/downloads/*-win*.whl
5 changes: 5 additions & 0 deletions CHANGES.txt
Expand Up @@ -25,6 +25,11 @@ Bugs fixed
* GH#417: The ``test_feed_parser`` test could fail if ``lxml_html_clean`` was not installed.
It is now skipped in that case.

* LP#2059910: The minimum CPU architecture for the Linux x86 binary wheels was set back to
"core2", without SSE 4.2.

* If libxml2 uses iconv, the compile time version is available as `etree.ICONV_COMPILED_VERSION`.


5.2.1 (2024-04-02)
==================
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -65,7 +65,7 @@ wheel_%: dist/lxml-$(LXMLVERSION).tar.gz
-e AR=gcc-ar \
-e NM=gcc-nm \
-e RANLIB=gcc-ranlib \
-e CFLAGS="$(MANYLINUX_CFLAGS) $(if $(patsubst %aarch64,,$@),-march=core2 -msse4.1 -msse4.2,-march=armv8-a -mtune=cortex-a72)" \
-e CFLAGS="$(MANYLINUX_CFLAGS) $(if $(patsubst %aarch64,,$@),-march=core2,-march=armv8-a -mtune=cortex-a72)" \
-e LDFLAGS="$(MANYLINUX_LDFLAGS)" \
-e STATIC_DEPS="${STATIC_DEPS}" \
-e LIBXML2_VERSION="$(MANYLINUX_LIBXML2_VERSION)" \
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Expand Up @@ -8,7 +8,7 @@ skip = [
"pp*-manylinux_i686",
"*-musllinux_i686",
# Py3.8 wheel for macos is not universal: https://bugs.launchpad.net/lxml/+bug/2055404
"cp38_macosx_universal2",
"cp38-macosx_universal2",
# Reduce job load and HTTP hit rate on library servers.
"cp36-manylinux_aarch64",
"cp37-manylinux_aarch64",
Expand Down Expand Up @@ -51,7 +51,7 @@ environment.CFLAGS = "-O3 -g1 -pipe -fPIC -flto -march=core2 -mtune=generic"
[[tool.cibuildwheel.overrides]]
select = "*linux_x86_64"
inherit.environment = "append"
environment.CFLAGS = "-O3 -g1 -pipe -fPIC -flto -march=core2 -msse4.1 -msse4.2 -mtune=generic"
environment.CFLAGS = "-O3 -g1 -pipe -fPIC -flto -march=core2 -mtune=generic"

[[tool.cibuildwheel.overrides]]
select = "*aarch64"
Expand Down
30 changes: 25 additions & 5 deletions src/lxml/etree.pyx
Expand Up @@ -232,7 +232,7 @@ cdef class C14NError(LxmlError):
"""

# version information
cdef __unpackDottedVersion(version):
cdef tuple __unpackDottedVersion(version):
version_list = []
l = (version.decode("ascii").replace('-', '.').split('.') + [0]*4)[:4]
for item in l:
Expand All @@ -255,11 +255,11 @@ cdef __unpackDottedVersion(version):
version_list.append(item)
return tuple(version_list)

cdef __unpackIntVersion(int c_version):
cdef tuple __unpackIntVersion(int c_version, int base=100):
return (
((c_version // (100*100)) % 100),
((c_version // 100) % 100),
(c_version % 100)
((c_version // (base*base)) % base),
((c_version // base) % base),
(c_version % base)
)

cdef int _LIBXML_VERSION_INT
Expand All @@ -276,6 +276,26 @@ LXML_VERSION = __unpackDottedVersion(tree.LXML_VERSION_STRING)

__version__ = tree.LXML_VERSION_STRING.decode("ascii")

cdef extern from *:
"""
#ifdef ZLIB_VERNUM
#define __lxml_zlib_version (ZLIB_VERNUM >> 4)
#else
#define __lxml_zlib_version 0
#endif
#ifdef _LIBICONV_VERSION
#define __lxml_iconv_version (_LIBICONV_VERSION << 8)
#else
#define __lxml_iconv_version 0
#endif
"""
# zlib isn't included automatically by libxml2's headers
#long ZLIB_HEX_VERSION "__lxml_zlib_version"
long LIBICONV_HEX_VERSION "__lxml_iconv_version"

#ZLIB_COMPILED_VERSION = __unpackIntVersion(ZLIB_HEX_VERSION, base=0x10)
ICONV_COMPILED_VERSION = __unpackIntVersion(LIBICONV_HEX_VERSION, base=0x100)[:2]


# class for temporary storage of Python references,
# used e.g. for XPath results
Expand Down
25 changes: 13 additions & 12 deletions src/tests/test_etree.py
Expand Up @@ -28,18 +28,19 @@
from .common_imports import canonicalize, _str, _bytes
from .common_imports import SimpleFSPath

print("""
TESTED VERSION: %s""" % etree.__version__ + """
Python: %r""" % (sys.version_info,) + """
lxml.etree: %r""" % (etree.LXML_VERSION,) + """
libxml used: %r""" % (etree.LIBXML_VERSION,) + """
libxml compiled: %r""" % (etree.LIBXML_COMPILED_VERSION,) + """
libxslt used: %r""" % (etree.LIBXSLT_VERSION,) + """
libxslt compiled: %r""" % (etree.LIBXSLT_COMPILED_VERSION,) + """
FS encoding: %s""" % (sys.getfilesystemencoding(),) + """
Default encoding: %s""" % (sys.getdefaultencoding(),) + """
Max Unicode: %s""" % (sys.maxunicode,) + """
PyUCS4 encoding: %s""" % (getattr(etree, '_pyucs4_encoding_name', ''),) + """
print(f"""
TESTED VERSION: {etree.__version__}
Python: {tuple(sys.version_info)!r}
lxml.etree: {etree.LXML_VERSION!r}
libxml used: {etree.LIBXML_VERSION!r}
libxml compiled: {etree.LIBXML_COMPILED_VERSION!r}
libxslt used: {etree.LIBXSLT_VERSION!r}
libxslt compiled: {etree.LIBXSLT_COMPILED_VERSION!r}
iconv compiled: {etree.ICONV_COMPILED_VERSION!r}
FS encoding: {sys.getfilesystemencoding()}
Default encoding: {sys.getdefaultencoding()}
Max Unicode: {sys.maxunicode}
PyUCS4 encoding: {getattr(etree, '_pyucs4_encoding_name', '')}
""")


Expand Down
13 changes: 2 additions & 11 deletions tools/ci-run.sh
Expand Up @@ -78,7 +78,8 @@ fi
if [ -z "${PYTHON_VERSION##2*}" ] || [ -z "${PYTHON_VERSION##pypy-2*}" ]; then
python -m pip install -U beautifulsoup4==4.9.3 cssselect==1.1.0 html5lib==1.1 rnc2rng==2.6.5 ${EXTRA_DEPS} || exit 1
else
python -m pip install -U beautifulsoup4 cssselect html5lib lxml_html_clean rnc2rng ${EXTRA_DEPS} || exit 1
python -m pip install -U beautifulsoup4 cssselect html5lib rnc2rng ${EXTRA_DEPS} || exit 1
python -m pip install --no-deps lxml_html_clean || exit 1
fi
if [[ "$COVERAGE" == "true" ]]; then
python -m pip install "coverage<5" || exit 1
Expand All @@ -93,8 +94,6 @@ GITHUB_API_TOKEN="${SAVED_GITHUB_API_TOKEN}" \
$(if [[ "$COVERAGE" == "true" ]]; then echo -n " --with-coverage"; fi ) \
|| exit 1

ccache -s || true

# Run tests
echo "Running the tests ..."
GITHUB_API_TOKEN="${SAVED_GITHUB_API_TOKEN}" \
Expand All @@ -103,12 +102,4 @@ GITHUB_API_TOKEN="${SAVED_GITHUB_API_TOKEN}" \
PYTHONUNBUFFERED=x \
make test || exit 1

if [[ "$COVERAGE" != "true" ]]; then
echo "Building a clean wheel ..."
GITHUB_API_TOKEN="${SAVED_GITHUB_API_TOKEN}" \
CFLAGS="$EXTRA_CFLAGS -O3 -g1 -mtune=generic -fPIC -flto" \
LDFLAGS="-flto $EXTRA_LDFLAGS" \
make clean wheel || exit 1
fi

ccache -s || true

0 comments on commit bdd7183

Please sign in to comment.