pycsw
pycsw copied to clipboard
pycsw 2.6.1 (latest release) requires the deprecated "imp" library which is no longer available in python 3.12
Description
PyCSW 2.6.1 (latest release, from oct/2021) requires the deprecated "imp" library which is no longer available in Python 3.12 The master branch has already dropped that dependency on the "server.py" file, so no patch is necessary. This issue will be solved with a release of 3.0 which seems to be in the works.
Environment
- operating system: all
- Python version: 3.12
- pycsw version: 2.6.1
- source/distribution
- [ ] git clone
- [ ] DebianGIS/UbuntuGIS
- [X] PyPI
- [ ] zip/tar.gz
- [ ] other (please specify):
- web server
- [ ] Apache/mod_wsgi
- [ ] CGI
- [X] other (please specify): geonode backend when trying to use python 3.12.
Steps to Reproduce
Run a container with the latest python version:
$ podman run -it --rm python:latest bash
Inside the container, install the required packages and launch a python console:
$ pip install setuptools pycsw==2.6.1 #latest version as of 2024-09-11
$ python
In the python shell run the following:
from pycsw import server
import os
os.environ['QUERY_STRING'] = "fake query"
# dummy configuration dictionary. It is important to have a "mappings" section in "repository" to trigger the invalid import.
config = {
'server': {
'home': '.',
'url': 'http://localhost:8000',
'mimetype': 'application/xml; charset=UTF-8',
'encoding': 'UTF-8',
'language': 'en-US',
'maxrecords': '10',
},
'repository': {
'database': 'sqlite:///data.db',
'table': 'records',
'mappings': 'path/to/your/mappings.py'
}
}
# Instantiate pycsw object
csw = server.Csw(rtconfig=config)
Running the code above will generate the following error message:
Could not load custom mappings: No module named 'imp'
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pycsw/server.py", line 194, in __init__
import imp
ModuleNotFoundError: No module named 'imp'
Additional Information
This issue will be solved with a release of 3.0 which seems to be in the works.