Skip to content

Commit

Permalink
Working on Python 3.9 and 3.10: qutip photutils
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Dec 18, 2023
1 parent 54fc40e commit 1ab5ecd
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 44 deletions.
6 changes: 0 additions & 6 deletions server/pypi/build-wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,6 @@ def get_python_env_vars(self, env, pypi_env):
# 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"] += " -DCYTHON_CCOMPLEX=0"

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

# Overrides sysconfig.get_platform and distutils.util.get_platform.
Expand Down
10 changes: 4 additions & 6 deletions server/pypi/packages/photutils/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{% if PY_VER == "3.8" %}
{% set numpy_version = "1.19.5" %}
{% else %}
{% 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: photutils
version: "1.1.0"
version: "1.10.0"

requirements:
build:
- cython 0.29.32
- extension-helpers 1.0.0
- setuptools-scm 7.1.0
host:
- numpy {{ numpy_version }}
9 changes: 5 additions & 4 deletions server/pypi/packages/photutils/patches/chaquopy.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
--- src-original/setup.py 2022-05-24 19:43:02.000000000 +0000
+++ src/setup.py 2023-04-06 16:08:59.631926941 +0000
@@ -4,5 +4,9 @@
# NOTE: The configuration for the package, including the name, version, and
# other information are set in the setup.cfg file.
@@ -1,6 +1,10 @@
#!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst

+# Chaquopy
+import builtins
+builtins.__NUMPY_SETUP__ = True # Prevent the compiled parts from being imported.
+
import sys
from setuptools import setup

from extension_helpers import get_extensions
20 changes: 14 additions & 6 deletions server/pypi/packages/qutip/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{% if PY_VER == "3.8" %}
{% set numpy_version = "1.19.5" %}
{% set scipy_version = "1.4.1" %}
{% elif PY_VER == "3.9" %}
{% set numpy_version = "1.23.3" %}
{% set scipy_version = "1.6.3" %}
{% elif PY_VER == "3.10" %}
{% set numpy_version = "1.23.3" %}
{% set scipy_version = "1.8.1" %}
{% endif %}

package:
name: qutip
version: "4.7.1"
version: "4.7.3"

requirements:
build:
- cython 0.29.34
- packaging 23.1
host:
- numpy 1.19.5
- scipy 1.4.1
- numpy {{ numpy_version }}
- scipy {{ scipy_version }}
19 changes: 0 additions & 19 deletions server/pypi/packages/qutip/patches/chaquopy.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,3 @@
import collections
import os
import pathlib
--- src-original/setup.cfg 2023-02-07 18:37:46.970661900 +0000
+++ src/setup.cfg 2023-04-20 02:53:18.745237940 +0000
@@ -34,11 +34,11 @@
numpy>=1.16.6
scipy>=1.0
packaging
-setup_requires =
- numpy>=1.13.3
- scipy>=1.0
- cython>=0.29.20
- packaging
+# setup_requires =
+# numpy>=1.13.3
+# scipy>=1.0
+# cython>=0.29.20
+# packaging

[options.packages.find]
include = qutip*
2 changes: 1 addition & 1 deletion server/pypi/packages/scikit-image/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package:
version: "0.18.3"

build:
number: 2
number: 3

requirements:
host:
Expand Down
19 changes: 17 additions & 2 deletions server/pypi/packages/scikit-image/patches/chaquopy.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
--- src-original/setup.py 2021-08-24 11:50:48.172484900 +0000
+++ src/setup.py 2023-12-08 20:34:03.384249653 +0000
@@ -11,6 +11,10 @@
+++ src/setup.py 2023-12-18 12:46:50.020340564 +0000
@@ -7,10 +7,25 @@
import builtins
import textwrap

+# Chaquopy: complex.h functions were introduced between API levels 23 and 26, so make
+# Cython use its own implementations instead.
+#
+# This isn't a problem with Cython's C++ mode, e.g. in qutip, presumably because libcxx
+# contains its own implementations of complex number functions in order to be compatible
+# with the minimum API level supported by the NDK. In fact, setting CYTHON_CCOMPLEX=0
+# for such a module causes Cython to generate code that passes Cython's own complex type
+# to C++ standard library functions, which obviously fails to compile. So that's why we
+# can't add this to the default CFLAGS.
+os.environ["CFLAGS"] += " -DCYTHON_CCOMPLEX=0"
+
import setuptools
from distutils.command.build_py import build_py
from distutils.command.sdist import sdist
from distutils.errors import CompileError, LinkError
Expand Down

0 comments on commit 1ab5ecd

Please sign in to comment.