[Osgeo4w-trac] [osgeo4w] #692: Python 3.9 on v2 installer breaks part of stdlib

OSGeo4W trac_osgeo4w at osgeo.org
Thu Sep 30 02:39:26 PDT 2021


#692: Python 3.9 on v2 installer breaks part of stdlib
-----------------------+----------------------------
Reporter:  akominlsfi  |       Owner:  osgeo4w-dev@…
    Type:  defect      |      Status:  new
Priority:  major       |   Component:  Installer
 Version:              |  Resolution:
Keywords:              |
-----------------------+----------------------------

Comment (by akominlsfi):

 I tested this theory on a fresh v2 network install with only qgis-ltr-full
 (3.16.11) selected.

 Creating a file `<osgeo-install>/apps/python39/sitecustomize.py` with
 these contents:

 {{{#!python
 import os

 os.add_dll_directory('<osgeo-install>/bin')
 os.add_dll_directory('<osgeo-install>/apps/qgis-ltr/bin')
 os.add_dll_directory('<osgeo-install>/apps/Qt5/bin')
 }}}

 and a file `<osgeo-install>/apps/python39/lib/site-packages/qgis.pth` with
 these contents:

 {{{#!python
 <osgeo-install>/apps/qgis-ltr/python
 }}}

 Then executing python directly from `<osgeo-
 install>/apps/python39/python.exe` works with all the imports I figured
 out to test
 (qgis,PyQt5,osgeo.gdal,osgeo.ogr,scipy,numpy,pandas,matplotlib,psycopg2,pyproj)
 that have .pyds and may have required dlls somewhere else in the install
 tree. Not sure about what can be best way to bake in the env variables
 that would be setup by `<osgeo-install>/etc/ini/*.bat` files, eg.
 GDAL_DATA, PROJ_LIB etc. that might be necessary for the environment to
 function in some cases? Could that be something that is also made in
 customization script, set variable if not already present?

 Also with this setup creating a venv works both without system site
 packages (qgis etc. not importable as would be expected), and with system
 site packages (qgis etc. importable), since the dll path patch is found
 also when executing the venv python exe.

-- 
Ticket URL: <https://trac.osgeo.org/osgeo4w/ticket/692#comment:2>
OSGeo4W <http://trac.osgeo.org/osgeo4w>
OSGeo4W is the Windows installer and package environment for the OSGeo stack.


More information about the Osgeo4w-trac mailing list