conda-forge / qgis-feedstock

A conda-smithy repository for qgis.
BSD 3-Clause "New" or "Revised" License
41 stars 26 forks source link

TypeError: QgsSingleSymbolRenderer(): not enough arguments #346

Closed danschef closed 11 months ago

danschef commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

I am not entirely sure if that is related to the conda-forge builds of QGIS but I would guess so, so I report it here:

We are currently facing issues in the EnMAP-Box (https://github.com/EnMAP-Box/enmap-box/issues/488) that we narrowed down to the following code snippet:

from qgis.core import QgsMarkerSymbol, QgsSingleSymbolRenderer, QgsFeatureRenderer
symbol = QgsMarkerSymbol.createSimple({'name': 'square', 'color': 'white'})
renderer = QgsSingleSymbolRenderer(symbol)

This fails fails with a TypeError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: QgsSingleSymbolRenderer(): not enough arguments

We tested this with the following QGIS versions:

QGIS Python Distribution Fail?
3.32.0 3.11  mamba fail
3.30.3 3.11  mamba fail
3.30.0 3.11  mamba works
3.28.8 3.11  mamba fail
3.28.8 3.9.16  mamba fail
3.33.0 3.9.5 OSGeo works
3.32.0 3.9.5 OSGeo works
3.28.8 3.9.5 OSGeo works

Just use mamba create -n test "qgis=3.32.0" "python=3.11" to create an environment to reproduce it.

Installed packages

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
alsa-lib                  1.2.9                hd590300_0    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
blosc                     1.21.4               h0f2a231_0    conda-forge
boost-cpp                 1.78.0               h6582d0a_3    conda-forge
brotli                    1.0.9                h166bdaf_9    conda-forge
brotli-bin                1.0.9                h166bdaf_9    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
c-ares                    1.19.1               hd590300_0    conda-forge
ca-certificates           2023.5.7             hbcca054_0    conda-forge
cairo                     1.16.0            hbbf8b49_1016    conda-forge
ceres-solver              2.1.0                hf302a74_1    conda-forge
certifi                   2023.5.7           pyhd8ed1ab_0    conda-forge
cfitsio                   4.2.0                hd9d235c_0    conda-forge
charset-normalizer        3.1.0              pyhd8ed1ab_0    conda-forge
coverage                  7.2.7           py311h459d7ec_0    conda-forge
curl                      8.1.2                h409715c_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
draco                     1.5.6                hf52228f_0    conda-forge
eigen                     3.4.0                h4bd325d_0    conda-forge
exiv2                     0.27.6               hb9a316c_1    conda-forge
expat                     2.5.0                hcb278e6_1    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.2               h14ed4e7_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.12.1               hca18f0e_1    conda-forge
freexl                    1.0.6                h166bdaf_1    conda-forge
future                    0.18.3             pyhd8ed1ab_0    conda-forge
gdal                      3.7.0           py311h281082f_1    conda-forge
geos                      3.11.2               hcb278e6_0    conda-forge
geotiff                   1.7.1                h480ec47_8    conda-forge
gettext                   0.21.1               h27087fc_0    conda-forge
gflags                    2.2.2             he1b5a44_1004    conda-forge
giflib                    5.2.1                h0b41bf4_3    conda-forge
glib                      2.76.3               hfc55251_0    conda-forge
glib-tools                2.76.3               hfc55251_0    conda-forge
glog                      0.6.0                h6f12383_0    conda-forge
gmp                       6.2.1                h58526e2_0    conda-forge
graphite2                 1.3.13            h58526e2_1001    conda-forge
gsl                       2.7                  he838d99_0    conda-forge
gst-plugins-base          1.22.4               hf7dbed1_0    conda-forge
gstreamer                 1.22.4               h98fc4e7_0    conda-forge
harfbuzz                  7.3.0                hdb3a94d_0    conda-forge
hdf4                      4.2.15               h501b40f_6    conda-forge
hdf5                      1.14.0          nompi_hb72d44e_103    conda-forge
httplib2                  0.22.0             pyhd8ed1ab_0    conda-forge
icu                       72.1                 hcb278e6_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
json-c                    0.16                 hc379101_0    conda-forge
kealib                    1.5.1                h3845be2_3    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.20.1               h81ceb04_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
laz-perf                  3.3.0                hf52228f_0    conda-forge
lcms2                     2.15                 haa2dc70_1    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libaec                    1.0.6                hcb278e6_1    conda-forge
libarchive                3.6.2                h039dbb9_1    conda-forge
libblas                   3.9.0           17_linux64_openblas    conda-forge
libbrotlicommon           1.0.9                h166bdaf_9    conda-forge
libbrotlidec              1.0.9                h166bdaf_9    conda-forge
libbrotlienc              1.0.9                h166bdaf_9    conda-forge
libcap                    2.67                 he9d0100_0    conda-forge
libcblas                  3.9.0           17_linux64_openblas    conda-forge
libclang                  15.0.7          default_h7634d5b_2    conda-forge
libclang13                15.0.7          default_h9986a30_2    conda-forge
libcups                   2.3.3                h36d4200_3    conda-forge
libcurl                   8.1.2                h409715c_0    conda-forge
libdeflate                1.18                 h0b41bf4_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 h516909a_1    conda-forge
libevent                  2.1.12               hf998b51_1    conda-forge
libexpat                  2.5.0                hcb278e6_1    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.3                h59595ed_0    conda-forge
libgcc-ng                 13.1.0               he5830b7_0    conda-forge
libgcrypt                 1.10.1               h166bdaf_0    conda-forge
libgdal                   3.7.0                h9f4e061_1    conda-forge
libgfortran-ng            13.1.0               h69a702a_0    conda-forge
libgfortran5              13.1.0               h15d22d2_0    conda-forge
libglib                   2.76.3               hebfc3b9_0    conda-forge
libgomp                   13.1.0               he5830b7_0    conda-forge
libgpg-error              1.47                 h71f35ed_0    conda-forge
libhwloc                  2.9.1           nocuda_h7313eea_6    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
libjpeg-turbo             2.1.5.1              h0b41bf4_0    conda-forge
libkml                    1.3.0             h37653c0_1015    conda-forge
liblapack                 3.9.0           17_linux64_openblas    conda-forge
libllvm15                 15.0.7               h5cf9203_2    conda-forge
libnetcdf                 4.9.2           nompi_h0f3d0bb_105    conda-forge
libnghttp2                1.52.0               h61bc06f_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.23          pthreads_h80387f5_0    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.39               h753d276_0    conda-forge
libpq                     15.3                 hbcd7760_1    conda-forge
libprotobuf               3.21.12              h3eb15da_0    conda-forge
librttopo                 1.1.0               h0d5128d_13    conda-forge
libsecret                 0.18.8               h329b89f_2    conda-forge
libsndfile                1.2.0                hb75c966_0    conda-forge
libspatialindex           1.9.3                h9c3ff4c_4    conda-forge
libspatialite             5.0.1               hb46c372_26    conda-forge
libsqlite                 3.42.0               h2797004_0    conda-forge
libssh2                   1.11.0               h0841786_0    conda-forge
libstdcxx-ng              13.1.0               hfd8a6a1_0    conda-forge
libsystemd0               253                  h8c4010b_1    conda-forge
libtiff                   4.5.1                h8b53f26_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp                   1.3.0                hb47c5f0_0    conda-forge
libwebp-base              1.3.0                h0b41bf4_0    conda-forge
libxcb                    1.15                 h0b41bf4_0    conda-forge
libxkbcommon              1.5.0                h5d7e998_3    conda-forge
libxml2                   2.11.4               h0d562d8_0    conda-forge
libxslt                   1.1.37               h0054252_1    conda-forge
libzip                    1.9.2                hc929e4a_1    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
lxml                      4.9.2           py311h1a07684_1    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
lzo                       2.10              h516909a_1000    conda-forge
markupsafe                2.1.3           py311h459d7ec_0    conda-forge
metis                     5.1.0             h58526e2_1006    conda-forge
mock                      5.0.2              pyhd8ed1ab_0    conda-forge
mpfr                      4.2.0                hb012696_0    conda-forge
mpg123                    1.31.3               hcb278e6_0    conda-forge
mysql-common              8.0.33               hf1915f5_0    conda-forge
mysql-libs                8.0.33               hca2cd23_0    conda-forge
ncurses                   6.4                  hcb278e6_0    conda-forge
nitro                     2.7.dev8             h59595ed_0    conda-forge
nose2                     0.9.2                      py_0    conda-forge
nspr                      4.35                 h27087fc_0    conda-forge
nss                       3.89                 he45b914_0    conda-forge
numpy                     1.25.0          py311h64a7726_0    conda-forge
openjpeg                  2.5.0                hfec8fc6_2    conda-forge
openssl                   3.1.1                hd590300_1    conda-forge
owslib                    0.29.2             pyhd8ed1ab_0    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
pcre2                     10.40                hc3806b6_0    conda-forge
pdal                      2.5.5                hee5d408_0    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h36c2ea0_0    conda-forge
plotly                    5.15.0             pyhd8ed1ab_0    conda-forge
ply                       3.11                       py_1    conda-forge
poppler                   23.05.0              hd18248d_1    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
postgresql                15.3                 hd458b1d_1    conda-forge
proj                      9.2.0                h8ffa02c_0    conda-forge
psycopg2                  2.9.3           py311h968e94b_2    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pulseaudio-client         16.1                 hb77b528_4    conda-forge
pygments                  2.15.1             pyhd8ed1ab_0    conda-forge
pyparsing                 3.1.0              pyhd8ed1ab_0    conda-forge
pyproj                    3.6.0           py311h331fe15_0    conda-forge
pyqt                      5.15.7          py311ha74522f_3    conda-forge
pyqt5-sip                 12.11.0         py311hcafe171_3    conda-forge
pyqtwebkit                5.15.9          py311ha10a086_1    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.4          hab00c5b_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py311hd4cff14_5    conda-forge
qca                       2.3.6                h4a6f7a0_0    conda-forge
qgis                      3.32.0          py311h66b4bf9_0    conda-forge
qjson                     0.9.0             h0c700ba_1009    conda-forge
qscintilla2               2.14.0          py311hd529140_0    conda-forge
qt-main                   5.15.8              hf9e2b05_14    conda-forge
qtkeychain                0.14.1               hbc31b07_0    conda-forge
qtwebkit                  5.212               h0396763_12    conda-forge
qwt                       6.2.0                h16b76b2_6    conda-forge
readline                  8.2                  h8228510_1    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
setuptools                68.0.0             pyhd8ed1ab_0    conda-forge
sip                       6.7.9           py311hb755f60_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.10               h9fff704_0    conda-forge
sqlite                    3.42.0               h2c6b66d_0    conda-forge
suitesparse               5.10.1               h9e50725_1    conda-forge
tbb                       2021.9.0             hf52228f_0    conda-forge
tenacity                  8.2.2              pyhd8ed1ab_0    conda-forge
tiledb                    2.13.2               hd532e3d_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tzcode                    2023c                h0b41bf4_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urllib3                   2.0.3              pyhd8ed1ab_0    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
xcb-util                  0.4.0                hd590300_1    conda-forge
xcb-util-image            0.4.0                h8ee46fc_1    conda-forge
xcb-util-keysyms          0.4.0                h8ee46fc_1    conda-forge
xcb-util-renderutil       0.3.9                hd590300_1    conda-forge
xcb-util-wm               0.4.1                h8ee46fc_1    conda-forge
xerces-c                  3.2.4                h8d71039_2    conda-forge
xkeyboard-config          2.39                 hd590300_0    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.1.1                hd590300_0    conda-forge
xorg-libsm                1.2.4                h7391055_0    conda-forge
xorg-libx11               1.8.6                h8ee46fc_0    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxext              1.3.4                h0b41bf4_2    conda-forge
xorg-libxrender           0.9.10            h7f98852_1003    conda-forge
xorg-renderproto          0.11.1            h7f98852_1002    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xf86vidmodeproto     2.3.1             h7f98852_1002    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
zlib                      1.2.13               hd590300_5    conda-forge
zstd                      1.5.2                h3eb15da_6    conda-forge

Environment info

active environment : qgis3320_py311
    active env location : /home/me/mambaforge/envs/qgis3320_py311
            shell level : 7
       user config file : /home/me/.condarc
 populated config files : /home/me/mambaforge/.condarc
                          /home/me/.condarc
          conda version : 23.3.1
    conda-build version : not installed
         python version : 3.10.11.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.35=0
                          __linux=5.15.0=0
                          __unix=0=0
       base environment : /home/me/mambaforge  (writable)
      conda av data dir : /home/me/mambaforge/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/me/mambaforge/pkgs
                          /home/me/.conda/pkgs
       envs directories : /home/me/mambaforge/envs
                          /home/me/.conda/envs
               platform : linux-64
             user-agent : conda/23.3.1 requests/2.31.0 CPython/3.10.11 Linux/5.15.0-58-generic ubuntu/22.04.2 glibc/2.35
                UID:GID : 1009:38755
             netrc file : None
           offline mode : False
danschef commented 1 year ago

@jakimowb

SrNetoChan commented 1 year ago

So... I have tried 3.28.8 on linux and I was able to replicate the issue.

Then I have installed 3.28.3 (which is about the same time as 3.30.0 ) and it worked. 3.22 latest version also works fine.

So, something has happened after 3.30.0 and 3.28.3

jakimowb commented 1 year ago

I don't know why, but calling the constructor with an additional "None"

QgsSingleSymbolRenderer(symbol, None) will let the code run through.

SrNetoChan commented 1 year ago

Still, the api only expects one argument

https://api.qgis.org/api/classQgsSingleSymbolRenderer.html

SrNetoChan commented 1 year ago

My guess is that has something to do with pyqt or sip versions

danschef commented 1 year ago

3.22 latest version also works fine.

Note that in my case above, it did not work for QGIS 3.32 (py311h66b4bf9_0). If it worked for you, it might be worth to compare the rest of the environment (conda list output above). In the above environment, pyqt 5.15.7 (py311ha74522f_3) and sip 6.7.9 (py311hb755f60_0) are installed.

SrNetoChan commented 1 year ago

@danschef It works on 3.22, not on 3.32

danschef commented 1 year ago

Sorry, I was confused because you wrote "3.22 latest version" but the latest version is actually 3.32.

SrNetoChan commented 1 year ago

I mean the last 3.22.x patch

SrNetoChan commented 1 year ago

So, I kept digging in this issue. I believe the problems go deeper than this snippet. I am getting another error and crash doing another task (adding a input in the model builder)

So, the snippet works fine in 3.28.4, and the installation between 3.28.3 and 3.28.4 was just an update on the qgis package.

Then I have installed 3.28.5, and it forced lots of updates in all dependencies (see below).

Now, the script gives the error, and I also starts getting the error with the model builder. So, whatever happened started in this version.

Looking for: ['qgis=3.28.5']

conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.11.*

Transaction

  Prefix: /home/aneto/mambaforge/envs/qgis3.8.3

  Updating specs:

   - qgis=3.28.5
   - ca-certificates
   - certifi
   - openssl

  Package          Version  Build               Channel                    Size
─────────────────────────────────────────────────────────────────────────────────
  Install:
─────────────────────────────────────────────────────────────────────────────────

  + libllvm16       16.0.3  hbf9e925_1          conda-forge/linux-64     Cached

  Change:
─────────────────────────────────────────────────────────────────────────────────

  - boost-cpp       1.78.0  h5adbc97_2          conda-forge                    
  + boost-cpp       1.78.0  h6582d0a_3          conda-forge/linux-64     Cached
  - cairo           1.16.0  ha61ee94_1014       conda-forge                    
  + cairo           1.16.0  h35add3b_1015       conda-forge/linux-64     Cached
  - geotiff          1.7.1  hb963b44_7          conda-forge                    
  + geotiff          1.7.1  h480ec47_8          conda-forge/linux-64     Cached
  - harfbuzz         6.0.0  h8e241bc_0          conda-forge                    
  + harfbuzz         6.0.0  h3ff4399_1          conda-forge/linux-64     Cached
  - librttopo        1.1.0  ha49c73b_12         conda-forge                    
  + librttopo        1.1.0  h0d5128d_13         conda-forge/linux-64     Cached
  - libspatialite    5.0.1  h221c8f1_23         conda-forge                    
  + libspatialite    5.0.1  h7d1ca68_25         conda-forge/linux-64     Cached
  - qt-main         5.15.8  h67dfc38_7          conda-forge                    
  + qt-main         5.15.8  h5c52f38_10         conda-forge/linux-64     Cached
  - qtwebkit         5.212  he984d69_9          conda-forge                    
  + qtwebkit         5.212  h7b3bce5_10         conda-forge/linux-64     Cached
  - xerces-c         3.2.4  h55805fa_1          conda-forge                    
  + xerces-c         3.2.4  h8d71039_2          conda-forge/linux-64     Cached

  Upgrade:
─────────────────────────────────────────────────────────────────────────────────

  - gdal             3.6.3  py311hadb6153_0     conda-forge                    
  + gdal             3.6.4  py311h6122507_2     conda-forge/linux-64     Cached
  - geos            3.11.1  h27087fc_0          conda-forge                    
  + geos            3.11.2  hcb278e6_0          conda-forge/linux-64     Cached
  - hdf5            1.12.2  nompi_h4df4325_101  conda-forge                    
  + hdf5            1.14.0  nompi_hb72d44e_103  conda-forge/linux-64     Cached
  - icu               70.1  h27087fc_0          conda-forge                    
  + icu               72.1  hcb278e6_0          conda-forge/linux-64     Cached
  - kealib           1.5.0  ha7026e8_0          conda-forge                    
  + kealib           1.5.1  h3845be2_3          conda-forge/linux-64     Cached
  - libclang        15.0.7  default_h7634d5b_2  conda-forge                    
  + libclang        16.0.3  default_h1cdf331_2  conda-forge/linux-64       21kB
  - libclang13      15.0.7  default_h9986a30_2  conda-forge                    
  + libclang13      16.0.3  default_h4d60ac6_2  conda-forge/linux-64       10MB
  - libdeflate        1.17  h0b41bf4_0          conda-forge                    
  + libdeflate        1.18  h0b41bf4_0          conda-forge/linux-64     Cached
  - libgdal          3.6.3  hb7af45b_0          conda-forge                    
  + libgdal          3.6.4  hada8d5e_2          conda-forge/linux-64     Cached
  - libnetcdf        4.9.1  nompi_hd2e9713_102  conda-forge                    
  + libnetcdf        4.9.2  nompi_hdf9a29f_104  conda-forge/linux-64     Cached
  - libtiff          4.5.0  hddfeb54_5          conda-forge                    
  + libtiff          4.5.1  h8b53f26_0          conda-forge/linux-64     Cached
  - libxml2         2.10.3  hca2bb57_4          conda-forge                    
  + libxml2         2.10.4  hfdac1af_0          conda-forge/linux-64     Cached
  - pdal             2.5.2  h0ea1e05_1          conda-forge                    
  + pdal             2.5.3  h09aa857_0          conda-forge/linux-64     Cached
  - poppler        23.03.0  hf052cbe_1          conda-forge                    
  + poppler        23.05.0  hd18248d_1          conda-forge/linux-64     Cached
  - proj             9.1.1  h8ffa02c_2          conda-forge                    
  + proj             9.2.0  h8ffa02c_0          conda-forge/linux-64     Cached
  - pyproj           3.5.0  py311h945b3ca_0     conda-forge                    
  + pyproj           3.6.0  py311h331fe15_0     conda-forge/linux-64     Cached
  - qgis            3.28.4  py311hc4a2dbe_0     conda-forge                    
  + qgis            3.28.5  py311hc7474de_2     conda-forge/linux-64       88MB

  Summary:

  Install: 1 packages
  Change: 9 packages
  Upgrade: 17 packages

  Total download: 98MB
SrNetoChan commented 1 year ago

@gillins any idea?

gillins commented 1 year ago

Sorry, no. My instinct tells me there may be a subtle memory corruption type error that's causing some weird behaviour. Perhaps worth running a script that crashes through valgrind but you are likely to get a lot of info to sift through... Do the qgis.org packages show the same error?

SrNetoChan commented 1 year ago

@gillins no they don't. Using the installers prepared by qgis.org you are not able to replicate the error.

The change happened from 3.28.4 to 3.28.5. today I will hunt down which build cause it, because build 0 was just a bump in version.

Then I will try to rebuild pining some dependencies to match what qgis.org is using.

SrNetoChan commented 1 year ago

Ok, I kept investigating.

version 3.28.5 had several builds. I have tried installing build_0 and it works fine, both the code snippet and the issue I mentioned earlier.

Then I installed the next build qgis==3.28.5=py39hc0d3e04_1 and that's when the bug appears for the first time. In terms of dependencies, from build 0 to build 1 there were this diferences:

Updating specs:

So the only actual change in dependecies was geos, which I don't think is related to this.

Talking with @alexbruy he mentioned that the thing that could cause this kind of problems could be SIP, so I went to see what SIP version was used in each build, but according to what I saw, both used sip 6.6.2 ...

SrNetoChan commented 1 year ago

This seem to have been the one causing the problem:

https://github.com/conda-forge/qgis-feedstock/pull/317/files (Rebuilt for geos3.11.2) and it actually only seems to have changed the GEOS version from 3.11.1 to 3.11.2. QGIS 3.28.8 on Windows from osgeo4w also uses GEOS 3.11.2 without the issue... So... another deadend.

jakimowb commented 1 year ago

Some more examples that fail on conda installations (QGIS 3.30) but not OSGeo4W (python 3.9) or QGIS dev on ubuntu (20.04, python 3.10)

from qgis.core import *
from qgis.gui import *

QgsFillSymbol()
QgsMarkerSymbol()
QgsFillSymbol()
QgsLineSymbol()
QgsExpressionContext([]) 
QgsRendererCategory(1, QgsFillSymbol(), 'name', render=False)
gillins commented 1 year ago

Can you install Python 3.11 with OSGeo4W or is it fixed on 3.9? I have seen weird things with sip and more recent Python...

jakimowb commented 1 year ago

OSGeo4W is still on 3.9., but the errors [updated] do not occur on Ubuntu 20.04 with python 3.10 as well (I updated my previous comment)

SrNetoChan commented 1 year ago

Indeed osgeo4w is fixed on 3.9, but I have tested also with 3.9 in conda, unless it's a specific version of 3.9.

But notice that the first build of qgis 3.28.5 didn't have the bug, and I have tested it with the same python.

Same source, just an update of geos, and some build updates of a few dependencies.

Something have changed meanwhile, but it's very hard to say what.

gillins commented 1 year ago

Do we know what versions of pyqt and pyqt5-sip qgis.org use? Nothing useful with valgrind I'm afraid.

SrNetoChan commented 1 year ago

@gillins said:

Do we know what versions of pyqt and pyqt5-sip qgis.org use? Nothing useful with valgrind I'm afraid.

In QGIS 3.28.8 installed from OSGeo4W on windows, this is what we have.

Qt version: 5.15.2 SIP version: 5.4.0 PyQt version: 5.15.4

Nevertheless, both builds 0 and 1 of qgis=3.28.5 in conda-forge use SIP 6.6.2 (and I believe that the same version of Qt and PyQt)

gillins commented 1 year ago

OK this is very weird... I can't explain the GEOS thing. But, I do notice that every class that has the problem also uses SIP_TRANSFER in the C++ constructor definition. For some reason I suspect that a) SIP_TRANSFER is causing the code to expect another parameter and b) it isn't actually causing the C++ ownership to be transferred hence the random crashes. @alexbruy do you have any idea what could be causing this? I see sipify.pl should do some replacement before compilation.

SrNetoChan commented 1 year ago

@gillins yesterday I have built locally (using docker). But then I was not able to install it. How can I do that? Get the built package from the docker machine?

alexbruy commented 1 year ago

SIP_TRANSFER is just an annotation needed for SIP to generate correct bindings. Also there is no need to run sipify.pl before the build, as sip files are kept updated.

gillins commented 1 year ago

@SrNetoChan see https://conda-forge.org/docs/maintainer/updating_pkgs.html#testing-changes-locally: Once built, you can find the finished package in the build_artifacts directory in your feedstock, which can be used as a channel. To create a new environment my-new-env using conda, and which will contain the new built package my-package, run: conda create -n my-new-env -c "file://${PWD}/build_artifacts" my-package

gillins commented 1 year ago

Thanks @alexbruy, any pointers on where we should look for the source of this problem?

gillins commented 12 months ago

Hi guys, I'm going to have to leave this for now. I suspect this is being caused by the rather large difference in versions between pyqt5-sip (used at runtime - uses sip version 6.6.2) and sip (used when building the bindings - version 6.7.9), but cannot prove this. Unfortunately we cannot build qgis easily with an older sip and there seems to be some problem building more recent versions of the PyQt5 stack (https://github.com/conda-forge/pyqt-feedstock/pulls)....

SrNetoChan commented 11 months ago

@gillins is there any path to fix this? This really screws our efforts to make our builds viable to large usage. What can we try to do?

gillins commented 11 months ago

I did mean to mention that I found this: https://riverbankcomputing.com/news/SIP_v6.7.9_Released (we are on sip 6.7.9) which does mention "API v12.12.1" and I'm guessing this corresponds to PyQt5-sip 12.12.1 (https://pypi.org/project/PyQt5-sip/). Since conda-forge's pyqt5-sip is still stuck on 12.11.0 I think this is the problem. sip is updated in conda-forge very often but pyqt5/pyqt5-sip is not. When I get some time I'll try bumping the version and see what happens, but this will mean fixing the mysterious build problem with more recent pyqt5 versions which may be hard.

SrNetoChan commented 11 months ago

@gillins I decided to give it a go (not for you to feel any pressure) I used 12.12.2 because it seems to be the last version available on pypi... but maybe I should have used 12.12.1 Let's see how it goes.

gillins commented 11 months ago

12.12.2 corresponds to sip 6.7.10 (https://riverbankcomputing.com/news/SIP_v6.7.10_Released) which has just been merged into conda-forge (https://github.com/conda-forge/sip-feedstock/pull/70) so I think we are all good...

SrNetoChan commented 11 months ago

Do we know what versions of pyqt and pyqt5-sip qgis.org use? Nothing useful with valgrind I'm afraid.

@gillins I have asked and it seems that OSGeo4w uses 12.8.1, while ubuntu is providing 12.9.1 for pyqt-sip. I wonder is the problem is conda-forge being jumping ahead.

gillins commented 11 months ago

Yeah sounds like everybody is using older sip and pyqt5-sip. conda-forge always has the latest of everything, but things fell apart when sip was updated but pyqt5-sip wasn't. Hopefully that will now be fixed and we can try again... Always a bit risky using recent versions but if there is a problem with new sip would be good to feed that back to qgis.

gillins commented 11 months ago

Fixed by #358

SrNetoChan commented 11 months ago

I have tested 3.32.1 with the new build and it's fixed. I will do the same in the LTR branch.

SrNetoChan commented 11 months ago

Tested the new build of QGIS 3.28.9 and it's fixed! Thanks @gillins !!

danschef commented 11 months ago

@gillins @SrNetoChan

Many thanks for your work here, I can confirm that our downstream issue is fixed with the new builds.