Skip to content

Commit

Permalink
Working on Python 3.9 and 3.10: scikit-image (closes #1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Dec 9, 2023
1 parent e43f5fc commit 67988ec
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
10 changes: 8 additions & 2 deletions server/pypi/build-wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,15 @@ def get_python_env_vars(self, env, pypi_env):
assert_exists(self.python_lib)
self.standard_libs.append(libpython)

# Use -idirafter so that package-specified -I directories take priority (e.g.
# in grpcio and typed-ast).
# Use -idirafter so that package-specified -I directories take priority. For
# example, typed-ast provides its own Python headers.
env["CFLAGS"] += f" -idirafter {self.python_include_dir}"

# complex.h functions were introduced between API levels 23 and 26. Make Cython
# use its own implementations instead.
if self.api_level < 26:
env["CFLAGS"] += f" -DCYTHON_CCOMPLEX=0"

env["LDFLAGS"] += f" -lpython{self.python}"

# Overrides sysconfig.get_platform and distutils.util.get_platform.
Expand Down
15 changes: 12 additions & 3 deletions server/pypi/packages/scikit-image/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{% if PY_VER == "3.8" %}
{% set numpy_version = "1.17.4" %}
{% elif PY_VER in ["3.9", "3.10", "3.11"] %}
{% set numpy_version = "1.23.3" %}
{% elif PY_VER == "3.12" %}
{% set numpy_version = "1.26.2" %}
{% endif %}

package:
name: scikit-image
version: "0.18.3"

build:
number: 2

requirements:
build:
- cython 0.29.14
host:
- numpy 1.17.4
- numpy {{ numpy_version }}
9 changes: 4 additions & 5 deletions server/pypi/packages/scikit-image/patches/chaquopy.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
--- src-original/setup.py 2021-08-24 11:50:48.172484900 +0000
+++ src/setup.py 2022-07-11 22:15:55.179880743 +0000
@@ -11,6 +11,11 @@
+++ src/setup.py 2023-12-08 20:34:03.384249653 +0000
@@ -11,6 +11,10 @@
from distutils.command.build_py import build_py
from distutils.command.sdist import sdist
from distutils.errors import CompileError, LinkError
+
+# Chaquopy
+sys.path.insert(0, os.path.abspath("../requirements")) # For numpy.distutils
+builtins.__NUMPY_SETUP__ = True # Prevent the compiled parts from being imported.
+# Chaquopy: prevent the compiled parts of NumPy from being imported.
+builtins.__NUMPY_SETUP__ = True
+
from numpy.distutils.command.build_ext import build_ext

Expand Down
4 changes: 3 additions & 1 deletion target/build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ for path in "$AR" "$AS" "$CC" "$CXX" "$LD" "$NM" "$RANLIB" "$READELF" "$STRIP";
fi
done

export CFLAGS="-I${prefix:?}/include"
# Use -idirafter so that package-specified -I directories take priority. For example,
# grpcio provides its own BoringSSL headers which must be used rather than our OpenSSL.
export CFLAGS="-idirafter ${prefix:?}/include"
export LDFLAGS="-L${prefix:?}/lib \
-Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libunwind.a \
-Wl,--build-id=sha1 -Wl,--no-rosegment"
Expand Down

0 comments on commit 67988ec

Please sign in to comment.