Closed ni-jfitzger closed 4 months ago
Python 3.12 tests currently fail due to use of pkg_resources in __init__.py.
easy_install, pkg_resources, setuptools and distutils are no longer provided by default in environments created with venv or bootstrapped with ensurepip, since they are part of the setuptools package. For projects relying on these at runtime, the setuptools project should be declared as a dependency and installed separately (typically, using pip).
https://docs.python.org/3/whatsnew/3.12.html
importlib.metadata seems like a viable alternative, starting in Python 3.10. There's a backport, called importlib_metadata, but I don't want to add a dependency, so I think we'll wind up with an if/else and conditional import, for a while.
Python 3.12 tests currently fail due to use of pkg_resources in
__init__.py.
easy_install, pkg_resources, setuptools and distutils are no longer provided by default in environments created with venv or bootstrapped with ensurepip, since they are part of the setuptools package. For projects relying on these at runtime, the setuptools project should be declared as a dependency and installed separately (typically, using pip).
https://docs.python.org/3/whatsnew/3.12.html
importlib.metadata seems like a viable alternative, starting in Python 3.10. There's a backport, called importlib_metadata, but I don't want to add a dependency, so I think we'll wind up with an if/else and conditional import, for a while.
Are you sure you need importlib_metadata
with Python 3.8 and 3.9? We were using it in nidaqmx-python, which caused a lot of problems with packages that require specific versions of importlib_metadata
. We removed the importlib_metadata
dependency when we dropped Python 3.7 support.
The new nidaqmx installdriver
feature specifically uses importlib.resources
as a replacement for pkg_resources
: https://github.com/ni/nidaqmx-python/blob/master/generated/nidaqmx/_install_daqmx.py
Cc: @mshafer-ni
Are you sure you need importlib_metadata with Python 3.8 and 3.9?
@bkeryan I'm not going to use it. As I said, I don't want to a new install dependency. I'm going to use pkg_resources for Python 3.8 and 3.9 and importlib.metadata (built-in) for Python 3.10 and later.
Hmm ... looks like we might still be blocked.
travis-ci failed.
Building wheels for collected packages: grpcio-tools Building wheel for grpcio-tools (pyproject.toml): started Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error
I'll have to look into this.
Hmm ... looks like we might still be blocked.
travis-ci failed.
Building wheels for collected packages: grpcio-tools Building wheel for grpcio-tools (pyproject.toml): started Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): still running... Building wheel for grpcio-tools (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error
I'll have to look into this.
Looks like grpcio-tools 1.49.1 wheels are restricted to Python 3.10 and Python 3.11. grpcio-tools 1.59.0 is the earliest version supporting Python 3.12.
nidaqmx already added Python 3.12 support and used grpcio-tools 1.59.0 for Python 3.12. See https://github.com/ni/nidaqmx-python/pull/453
They used grpcio-tools 1.49.1 for Python 3.8 - Python 3.11 and grpcio-tools 1.59.0 for Python 3.12. However, nimi-python gets codegenerated with only a single version, so we'll have to do things differently.
Here are the compatibility requirements for grpcio-tools:
What does this Pull Request accomplish?
There are 3 major changes made to add Python 3.12 support.
1903
1944
I considered updating the version of Python used in the
.readthedocs.yaml
, but I'd rather be intentional about changes to documentation.pkg_resources
in__init__.py
withimportlib.metadata
for Python 3.10 and later.Tests failed on Python 3.12 because we tried to import a non-built-in module (pkg_resources) that we don't declare a dependency on. Full explanation below.
https://docs.python.org/3/whatsnew/3.12.html
Why the if/else implementation?
setuptools
dependency or aimportlib_metadata
dependency (backport ofimportlib.metadata
)importlib.metadata
offers functionality equivalent to what we were doing withpkg_resources
pkg_resources
,importlib.metadata
is built-in.I created #2047 to track the work to drop pkg_resources usage with Python 3.9.
grpcio-tools compatibility for version 1.59.0 (earliest version with Python 3.12 support):
List issues fixed by this Pull Request below, if any.
What testing has been done?
Did a before and after prettyprint of
nise.get_diagnostic_information()
on a local test machine.Using Python 3.12 before:
Using Python 3.12 after:
I also checked the output with Python 3.10.