[Bug 277700] Numpy support should be enabled by default with the graphics/py-gdal port

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 14 Mar 2024 17:41:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277700

            Bug ID: 277700
           Summary: Numpy support should be enabled by default with the
                    graphics/py-gdal port
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: Individual Port(s)
          Assignee: sunpoet@FreeBSD.org
          Reporter: kyle.a.taylor@gmail.com
             Flags: maintainer-feedback?(sunpoet@FreeBSD.org)
          Assignee: sunpoet@FreeBSD.org

Hey All - I'm running into an issue with GDAL utilities packaged with the gdal
and pygdal utilities in ports (installed via pkg). This library is used to
read/write geospatial datasets and includes a number of utility scripts for
transforming raster data from the command line. If I run one of the gdal
utility commands... e.g.:

> gdal_calc.py -A 2023_30m_cdls.tif --outfile=2023_30m_cdls_greyscale.tif --calc="A*1" --NoDataValue=0 --co="compress=lzw"
Traceback (most recent call last):
  File "/usr/local/bin/gdal_calc.py", line 8, in <module>
    from osgeo_utils.gdal_calc import *  # noqa
  File "/usr/local/lib/python3.9/site-packages/osgeo_utils/gdal_calc.py", line
46, in <module>
    from osgeo import gdal, gdal_array
  File "/usr/local/lib/python3.9/site-packages/osgeo/gdal_array.py", line 10,
in <module>
    from . import _gdal_array
ImportError: cannot import name '_gdal_array' from 'osgeo'
(/usr/local/lib/python3.9/site-packages/osgeo/__init__.py)

I get errors from _gdal_array in the osgeo python library. I did some
searching, and people report this issue with the version of numpy that gdal was
built against. E.g., Gentoo folks report this same error when you build gdal
from source without having numpy available. When I search for gdal and pygdal
in pkg to check the version I have installed, it's compiled without the numpy
flag by default:

> uname -a 
FreeBSD *** 14.0-RELEASE-p5 FreeBSD 14.0-RELEASE-p5 #0: Tue Feb 13 23:37:36 UTC
2024    
root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
amd64

> pkg info py39-gdal
py39-gdal-3.8.2
Name           : py39-gdal
Version        : 3.8.2
Installed on   : Tue Jan 16 08:27:46 2024 MST
Origin         : graphics/py-gdal
Architecture   : FreeBSD:14:amd64
Prefix         : /usr/local
Categories     : python graphics
Licenses       : MIT
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://gdal.org/
Comment        : Python binding for GDAL
Options        :
        NUMPY          : off
Shared Libs required:
        libgdal.so.34
Annotations    :
        FreeBSD_version: 1400097
        build_timestamp: 2024-01-06T14:44:54+0000
        built_by       : poudriere-git-3.4.0
        cpe            : cpe:2.3:a:osgeo:gdal:3.8.2:::::freebsd14:x64
        flavor         : py39
        port_checkout_unclean: no
        port_git_hash  : 756e18783
        ports_top_checkout_unclean: no
        ports_top_git_hash: 756e18783
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 6.26MiB
Description    :
This port is the Python binding for GDAL (Geospatial Data Abstraction Library).

> pkg info gdal-3.8.2_1
gdal-3.8.2_1
Name           : gdal
Version        : 3.8.2_1
Installed on   : Thu Feb  1 08:46:53 2024 MST
Origin         : graphics/gdal
Architecture   : FreeBSD:14:amd64
Prefix         : /usr/local
Categories     : graphics geography
Licenses       : MIT
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://gdal.org/
Comment        : Translator library for raster geospatial data formats
Options        :

I can't imagine a situation where a developer would want to work with py-gdal
without numpy support. And omitting this flag breaks the several of the python
utilities distributed with gdal. Can we change this so that numpy array support
is included by default when building py-gdal.

-- 
You are receiving this mail because:
You are the assignee for the bug.