FEniCS / ufl

UFL - Unified Form Language
https://fenicsproject.org
GNU Lesser General Public License v3.0
104 stars 64 forks source link

Replace `pkg_resources` with `importlib.metadata` #157

Closed jorgensd closed 1 year ago

jorgensd commented 1 year ago

Built-in functionality to use with Python>=3.8, ref: https://docs.python.org/3/library/importlib.metadata.html

Context Python 3.7 EOL is happening in 2 months: https://endoflife.date/python and the usage of pkg_resources with ufl causes a lot of deprecation warnings:

 python3 -Wd -c "import pkg_resources"    
/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
  warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
/usr/local/lib/python3.10/dist-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)

As Legacy DOLFIN does not support main branch of UFL, this is safe from a DOLFIN perspective, as DOLFINx, requires Python>=3.8 (https://github.com/FEniCS/dolfinx/blob/main/python/setup.py). As far as I can tell, Firedrake still supports Python 3.7.

dham commented 1 year ago

Drop it. Firedrake policy is to support Python for its designated lifetime. However since we're only a couple of months off dropping 3.7 anyway, there is nothing to be gained by doing extra work to support it.