Skip to content

Commit

Permalink
Compatibility with python 3.12 (#1061)
Browse files Browse the repository at this point in the history
* cast to integer

* add wheels support for python 3.12

* Update Changes

* Spelling

* bump h5py and scipy

* update Changes

* Update Changes

* Preparing release 3.11.1

* Back to development: 3.12

* revert changes made to the Dockerfile

* revert Changes

* Support h5py for both python 3.9 and python 3.12

* Support scipy for both python 3.9 and 3.12
  • Loading branch information
hoanphungt authored Dec 10, 2024
1 parent 266f4ca commit 1139f9e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
3.12 (unreleased)
-----------------

- Compatibility with Python 3.12 (#1061)
- Bumped h5py to 3.10.0 and scipy to 1.13.0 for python 3.12 compatibility (#1061)
- Added Processing Algorithm "Extract structure control actions" (#926)
- Fixed attributeError when loading a QGIS project (#1063)
- Fix in Rasters to NetCDF algorithm to properly convert the units Enum to string (#1067)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qgis/qgis:final-3_28_4
FROM qgis/qgis:final-3_28_4
RUN apt-get update && apt-get install -y python3-pyqt5.qtwebsockets wget python3-scipy python3-h5py zip && apt-get clean
# RUN mkdir -p /tests_directory
COPY requirements-dev.txt /root
Expand All @@ -9,6 +9,6 @@ RUN qgis_setup.sh

# Copied the original PYTHONPATH and added the profile's python dir to
# imitate qgis' behaviour.
ENV PYTHONPATH /usr/share/qgis/python/:/usr/share/qgis/python/plugins:/usr/lib/python3/dist-packages/qgis:/usr/share/qgis/python/qgis:/root/.local/share/QGIS/QGIS3/profiles/default/python
ENV PYTHONPATH=/usr/share/qgis/python/:/usr/share/qgis/python/plugins:/usr/lib/python3/dist-packages/qgis:/usr/share/qgis/python/qgis:/root/.local/share/QGIS/QGIS3/profiles/default/python
# Note: we'll mount the current dir into this WORKDIR
WORKDIR /root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/threedi_results_analysis
18 changes: 14 additions & 4 deletions dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,24 @@
if QGIS_VERSION < 32806 and platform.system() == "Windows":
SUPPORTED_HDF5_VERSIONS = ["1.10.7"]
H5PY_DEPENDENCY = Dependency("h5py", "h5py", "==2.10.0", False)
elif QGIS_VERSION >= 34000 and platform.system() == "Windows":
SUPPORTED_HDF5_VERSIONS = ["1.14.0"]
H5PY_DEPENDENCY = Dependency("h5py", "h5py", "==3.10.0", False)
else:
SUPPORTED_HDF5_VERSIONS = ["1.14.0"]
H5PY_DEPENDENCY = Dependency("h5py", "h5py", "==3.8.0", True)

WINDOWS_PLATFORM_DEPENDENCIES = [Dependency("scipy", "scipy", "==1.6.2", False)]
if QGIS_VERSION >= 32811 and platform.system() == "Windows":
if QGIS_VERSION < 32811 and platform.system() == "Windows":
WINDOWS_PLATFORM_DEPENDENCIES = [
Dependency("scipy", "scipy", "==1.6.2", True),
]
elif QGIS_VERSION >= 34000 and platform.system() == "Windows":
WINDOWS_PLATFORM_DEPENDENCIES = [
Dependency("scipy", "scipy", "==1.13.0", True),
]
else:
WINDOWS_PLATFORM_DEPENDENCIES = [
Dependency("scipy", "scipy", "==1.10.1", True),
Dependency("scipy", "scipy", "==1.10.1", False),
]

# If you add a dependency, also adjust external-dependencies/populate.sh
Expand Down Expand Up @@ -524,7 +534,7 @@ def _install_dependencies(dependencies, target_dir):
# sticking around.

if bar:
bar.setValue((count / len(dependencies)) * 100)
bar.setValue(int((count / len(dependencies)) * 100))
bar.update()
QApplication.processEvents()

Expand Down
27 changes: 24 additions & 3 deletions external-dependencies/populate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,31 @@ mkdir build
cd build

# Download the custom compiled qgis version tar of h5py, create a tar from the distro subfolder
# Download h5py 3.8.0 for QGis versions before 3.40
wget http://download.osgeo.org/osgeo4w/v2/x86_64/release/python3/python3-h5py/python3-h5py-3.8.0-1.tar.bz2
tar -xvf python3-h5py-3.8.0-1.tar.bz2
tar -cf h5py-3.8.0.tar -C ./apps/Python39/Lib/site-packages/ .
cp h5py-3.8.0.tar ..

# Download h5py 3.10.0 for QGis versions after 3.40
wget http://download.osgeo.org/osgeo4w/v2/x86_64/release/python3/python3-h5py/python3-h5py-3.10.0-1.tar.bz2
tar -xvf python3-h5py-3.10.0-1.tar.bz2
tar -cf h5py-3.10.0.tar -C ./apps/Python312/Lib/site-packages/ .
cp h5py-3.10.0.tar ..

# as well as scipy
# Download scipy 1.6.2 for QGis versions before 3.40
wget http://download.osgeo.org/osgeo4w/v2/x86_64/release/python3/python3-scipy/python3-scipy-1.10.1-1.tar.bz2
tar -xvf python3-scipy-1.10.1-1.tar.bz2
tar -cf scipy-1.10.1.tar -C ./apps/Python39/Lib/site-packages/ .
cp scipy-1.10.1.tar ..

# Download scipy 1.13.0 for QGis versions after 3.40
wget http://download.osgeo.org/osgeo4w/v2/x86_64/release/python3/python3-scipy/python3-scipy-1.13.0-1.tar.bz2
tar -xvf python3-scipy-1.13.0-1.tar.bz2
tar -cf scipy-1.13.0.tar -C ./apps/Python312/Lib/site-packages/ .
cp scipy-1.13.0.tar ..

# Back up a level and clean up the build/ directory.
cd ..
rm -rf build
Expand All @@ -64,21 +78,28 @@ cp h5py/h5py-2.10.0-cp39-cp39-win_amd64.whl .
# Copy pure wheels to prevent pip in docker (or Windows) to select platform dependent version
wget https://files.pythonhosted.org/packages/cd/84/66072ee12c3e79061f183c09a24be24f45bb1286600589640363d9d416b0/SQLAlchemy-2.0.6-py3-none-any.whl#sha256=c5d754665edea1ecdc79e3023659cb5594372e10776f3b3734d75c2c3ce95013

# Download windows wheels (cp39, win, amd64)
# Download windows wheels (cp39, cp312, win, amd64)

wget https://files.pythonhosted.org/packages/b2/8e/83d9e3bff5c0ff7a0ec7e850c785916e616ab20d8793943f9e1d2a987fab/shapely-2.0.0-cp39-cp39-win_amd64.whl
wget https://files.pythonhosted.org/packages/7b/b3/857afd9dfbfc554f10d683ac412eac6fa260d1f4cd2967ecb655c57e831a/shapely-2.0.6-cp312-cp312-win_amd64.whl
wget https://files.pythonhosted.org/packages/75/b7/7849ad6f25e17f72f4c7e411b36b456205db2c501ad495bfc97c1cd3b813/threedigrid_builder-1.14.4-cp39-cp39-win_amd64.whl
wget https://files.pythonhosted.org/packages/6c/d8/e3d88ad1c2e46562585565f241dba53c089d9d7ab45aa20f51d14a01ee09/threedigrid_builder-1.14.4-cp312-cp312-win_amd64.whl
wget https://files.pythonhosted.org/packages/43/21/a5d9df1d21514883333fc86584c07c2b49ba7c602e670b174bd73cfc9c7f/greenlet-3.1.1-cp312-cp312-win_amd64.whl#sha256=7124e16b4c55d417577c2077be379514321916d5790fa287c9ed6f23bd2ffd01
wget https://files.pythonhosted.org/packages/b3/89/1d3b78577a6b2762cb254f6ce5faec9b7c7b23052d1cdb7237273ff37d10/greenlet-2.0.2-cp39-cp39-win_amd64.whl#sha256=db1a39669102a1d8d12b57de2bb7e2ec9066a6f2b3da35ae511ff93b01b5d564
wget https://files.pythonhosted.org/packages/5f/d6/5f59a5e5570c4414d94c6da4c97731deab832cbd14eaf23189d54a92d1e1/cftime-1.6.2-cp39-cp39-win_amd64.whl#sha256=86fe550b94525c327578a90b2e13418ca5ba6c636d5efe3edec310e631757eea
wget https://files.pythonhosted.org/packages/17/98/ba5b4a2f37c6c88454b696dd5c7a4e76fc8bfd014364b47ddd7e2cec0fcd/cftime-1.6.4-cp312-cp312-win_amd64.whl#sha256=5b5ad7559a16bedadb66af8e417b6805f758acb57aa38d2730844dfc63a1e667


# Download linux wheels (both cp38 and cp310)
# Download linux wheels (cp38, cp310, cp312)
wget https://files.pythonhosted.org/packages/d5/7d/9a57e187cbf2fbbbdfd4044a4f9ce141c8d221f9963750d3b001f0ec080d/shapely-2.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/06/07/0700e5e33c44bc87e19953244c29f73669cfb6f19868899170f9c7e34554/shapely-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/4e/03/f3bcb7d96aef6d56b62e2f25996f161c05f92a45d452165be2007b756e0f/shapely-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/0b/22/8868b2266baa2f8f9747100232807de4151fd720322ee5d5d724d6415d63/threedigrid_builder-1.14.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/bd/8c/db51b687ee80cf28787f7b862b62e77e096001513176252d824384d2739c/threedigrid_builder-1.14.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/da/86/6603905deeed966584c7b8d1367c03034d4bc347e45dad9989f8a0576112/threedigrid_builder-1.14.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
wget https://files.pythonhosted.org/packages/57/5c/7c6f50cb12be092e1dccb2599be5a942c3416dbcfb76efcf54b3f8be4d8d/greenlet-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl#sha256=99cfaa2110534e2cf3ba31a7abcac9d328d1d9f1b95beede58294a60348fba36
wget https://files.pythonhosted.org/packages/6e/11/a1f1af20b6a1a8069bc75012569d030acb89fd7ef70f888b6af2f85accc6/greenlet-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl#sha256=d75209eed723105f9596807495d58d10b3470fa6732dd6756595e89925ce2470
wget https://files.pythonhosted.org/packages/e1/17/d8042d82f44c08549b535bf2e7d1e87aa1863df5ed6cf1cf773eb2dfdf67/cftime-1.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl#sha256=acb294fdb80e33545ae54b4421df35c4e578708a5ffce1c00408b2294e70ecef
wget https://files.pythonhosted.org/packages/44/51/bc9d47beee47afda1d335f05efa848dc403bd183344f03d431281518e8ab/cftime-1.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl#sha256=7a820e16357dbdc9723b2059f7178451de626a8b2e5f80b9d91a77e3dac42133
wget https://files.pythonhosted.org/packages/04/56/233d817ef571d778281f3d639049b342f6ff0bb4de4c5ee630befbd55319/cftime-1.6.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl#sha256=f92f2e405eeda47b30ab6231d8b7d136a55f21034d394f93ade322d356948654

touch .generated.marker

0 comments on commit 1139f9e

Please sign in to comment.