Skip to content

Commit

Permalink
Working on Python 3.9 - 3.13: lxml (closes #1258, closes #1092, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Oct 18, 2024
1 parent 13c1fce commit 424cf78
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
40 changes: 22 additions & 18 deletions server/pypi/compiler-wrapper.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
#!/usr/bin/env python3
#
# Filter compiler command line to remove include and library directories which are not
# in known safe locations.
# Filter compiler command line to work around various issues.
#
# Usage: compiler-wrapper.py <path-to-compiler> <args...>

import os
from os.path import abspath, commonpath, dirname
import shlex
import sys


# This covers the source directory, the host environment and the build environment.
# Remove include and library directories which are not in known safe locations, such as
# the source directory, the host environment and the build environment.
valid_dirs = [abspath(f"{dirname(sys.argv[0])}/../..")]

def is_valid(dir, prefix):
def is_valid(dir):
absdir = abspath(dir)
if (
return (
any(commonpath([vd, absdir]) == vd for vd in valid_dirs)
or (".cargo" in absdir) or (".rustup" in absdir)
):
return True
else:
print(f"Chaquopy: ignored invalid {prefix} directory: {dir!r}", file=sys.stderr)
return False
)


def main():
args_in = sys.argv[1:]
args_out = []
args_removed = []

def extend_if(valid, args):
(args_out if valid else args_removed).extend(args)

i = 0
while i < len(args_in):
arg = args_in[i]
for prefix in ["-I", "-L"]:
if arg.startswith(prefix):
if arg == prefix:
if arg == prefix: # e.g. `-I path`
i += 1
dir = args_in[i]
if is_valid(dir, prefix):
args_out += [arg, dir]
else:
dir = arg[2:]
if is_valid(dir, prefix):
args_out.append(arg)
extend_if(is_valid(dir), [arg, dir])
else: # e.g. `-Ipath`
extend_if(is_valid(arg[2:]), [arg])
break
else:
args_out.append(arg)
# Debugging information will be stripped by build-wheel anyway, and in some
# cases (e.g. lxml) can cause the compiler to use excessive memory.
extend_if(arg != "-g", [arg])

i += 1

if args_removed:
print("Chaquopy: removed arguments: " + shlex.join(args_removed))
os.execv(args_out[0], args_out)


Expand Down
2 changes: 1 addition & 1 deletion server/pypi/packages/lxml/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: lxml
version: "4.6.3"
version: "5.3.0"

requirements:
host:
Expand Down
8 changes: 6 additions & 2 deletions target/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ must be released under a different build number.

When building wheels for other packages:

* Try to build all the packages we currently have in the repository for the previous
Python version.
* For each package, in dependency order:
* Update to the current stable version, unless it's been updated recently, or updating
would take a lot of work which wouldn't be justified by user demand.
* Check whether there are any existing notes in issues or PRs.
* Update to the current stable version, unless this would take a lot of work which
isn't justified by user demand.
* Review patches and build scripts to see if there are any workarounds which are no
longer necessary.
* In the commit message, close any issues which are now resolved.
* When finished:
* Clear out any bad builds before copying them to the public repository.
* Notify any users who requested new versions.
Expand Down

0 comments on commit 424cf78

Please sign in to comment.