gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Doc: Conda environments on Windows

Open geographika opened this issue 8 months ago • 2 comments

What is the bug?

The current docs Building on Windows with Conda dependencies and Visual Studio no longer work with newer versions of Python (3.13).

Steps to reproduce the issue

cd c:\dev
conda create --name gdal
conda activate gdal
conda install --yes --quiet curl libiconv icu git python swig numpy pytest zlib
conda install --yes --quiet -c conda-forge compilers clcache
conda install --yes --quiet -c conda-forge \
    cmake proj geos hdf4 hdf5 \
    libnetcdf openjpeg poppler libtiff libpng xerces-c expat libxml2 kealib json-c \
    cfitsio freexl geotiff jpeg libpq libspatialite libwebp-base pcre postgresql \
    sqlite tiledb zstd charls cryptopp cgal librttopo libkml openssl xz

Versions and provenance

(gdal) PS C:\dev> python --version
Python 3.13.2

Pinning Python to an older version would be fine, but some of the dependencies are only available up to Python 3.10:

conda search -c conda-forge clcache
...
clcache                        4.2.0 py310h5588dad_1  conda-forge
clcache                        4.2.0  py36h57928b3_0  conda-forge
clcache                        4.2.0  py38haa244fe_1  conda-forge
clcache                        4.2.0  py39hcbf5309_1  conda-forge

Using Python 3.10 results in:

warning  libmamba Problem type not implemented SOLVER_RULE_STRICT_REPO_PRIORITY
warning  libmamba Problem type not implemented SOLVER_RULE_STRICT_REPO_PRIORITY
LibMambaUnsatisfiableError: Encountered problems while solving:
  - cannot install both pin-1-1 and pin-1-1
  - nothing provides libcurl 7.79.0 h789b8ee_0 needed by curl-7.79.0-h789b8ee_0

And further errors.

Additional context

A working minimal Conda setup for Windows to build the documentation, using PowerShell, is shown below.

md c:\dev
cd c:\dev
conda create --name gdal
conda activate gdal

conda install --yes --quiet -c conda-forge pip doxygen cmake proj ca-certificates swig

git clone https://github.com/OSGeo/gdal/
pip install -r C:\dev\gdal\doc\requirements.txt

cd C:\dev\gdal
md build
cd build
cmake -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF .. 
cmake --build . --target html --config Release

python -m http.server -d C:\dev\gdal\build\doc\build\html

It may need to be run with admin privileges or the following errors may be encountered:

	Warning: using menuinst v1 shortcuts
Please update menuinst in the base environment and reinstall git.

- Insufficient permissions to write menu folder.  Falling back to user location

There are passing Conda-based workflows at https://github.com/OSGeo/gdal/blob/master/.github/workflows/conda.yml and scripts https://github.com/OSGeo/gdal/blob/master/ci/travis/conda/setup.sh - however these are difficult to follow if wanting to setup a basic dev environment.

A possible improvement would be to have a simple CI workflow and script, and include this in the docs output so if it breaks it can be updated.

geographika avatar Apr 07 '25 20:04 geographika

It looks like the command works fine if pinning to Python 3.10 - it just has to remove python from the install list, or it updates it back to 3.13.

md c:\dev
cd c:\dev
conda create --name gdal python=3.10 -c conda-forge
conda activate gdal

conda activate gdal
python --version
# Python 3.10.16

conda install --yes -c conda-forge curl git libiconv icu swig numpy pytest zlib
conda install --yes -c conda-forge compilers clcache

conda install --yes -c conda-forge `
    cmake proj geos hdf4 hdf5 `
    libnetcdf openjpeg poppler libtiff libpng xerces-c expat libxml2 kealib json-c `
    cfitsio freexl geotiff jpeg libpq libspatialite libwebp-base pcre postgresql `
    sqlite tiledb zstd charls cryptopp cgal librttopo libkml openssl xz

git clone https://github.com/OSGeo/gdal/
pip install -r c:\dev\gdal\doc\requirements.txt

cd c:\dev\gdal
md build
cd build
cmake -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF .. 
cmake --build . --config Release

geographika avatar Apr 07 '25 21:04 geographika

instead of listing all dependent libraries, the use of the --only-deps flag might help. Something like: "conda install -c conda-forge --only-deps libgdal libgdal-hdf4 libgdal-hdf5 libgdal-netcdf libgdal-pdf libgdal-openjpeg"

rouault avatar Apr 07 '25 21:04 rouault