Skip to content

Commit

Permalink
Add python 3.12 support (#2045)
Browse files Browse the repository at this point in the history
* Test python 3.12 and use as primary build env

* Add python 3.12 classifier to setup.py (for PyPI)

* Run `tox -e codegen`

* Update changelog

* Update tox-systems_tests.ini
I somehow overlooked this in my first commit, where I was supposed to add testing

* Stop using pkg_resources in Python 3.10 and later

* sort package names

* Update grpcio and friends deps for Python 3.12 compatibility

* Regenerated pb2 files
  • Loading branch information
ni-jfitzger authored Apr 22, 2024
1 parent f145329 commit 81e371c
Show file tree
Hide file tree
Showing 58 changed files with 3,855 additions and 3,698 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ matrix:
include:
# We run tests on the latest supported version of Python first.
# This is where additional tests are run so we give it more time.
- python: "3.11"
- python: "3.12"
- python: "3.8"
- python: "3.9"
- python: "3.10"
- python: "3.11"

install:
- travis_retry sudo apt-get -y install python3-pip
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file.
## Unreleased
* ### ALL
* #### Added
* Support for Python 3.12
* #### Changed
* #### Removed
* ### `nidcpower` (NI-DCPower)
Expand Down
20 changes: 17 additions & 3 deletions build/templates/__init__.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def get_diagnostic_information():

note: Python bitness may be incorrect when running in a virtual environment
'''
import importlib.metadata
import os
import pkg_resources
import platform
import struct
import sys
Expand Down Expand Up @@ -107,8 +107,22 @@ def get_diagnostic_information():
else:
raise SystemError('Unsupported platform: {}'.format(platform.system()))

installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]
if sys.version_info[1] >= 10:
installed_packages_names = [
name
for name_list in importlib.metadata.packages_distributions().values()
for name in name_list
]
installed_packages_names = set(installed_packages_names)
installed_packages_list = [
{'name': name, 'version': importlib.metadata.distribution(name).version}
for name in sorted(installed_packages_names)
]
## TODO (ni-jfitzger): Delete use of pkg_resources when we drop Python 3.9 support. See https://github.com/ni/nimi-python/issues/2047
else:
import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]

info['os']['name'] = os_name
info['os']['version'] = platform.version()
Expand Down
5 changes: 3 additions & 2 deletions build/templates/setup.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ setup(
% if grpc_supported:
extras_require={
'grpc': [
'grpcio>=1.49.1,<2.0',
'protobuf>=4.21,<5.0'
'grpcio>=1.59.0,<2.0',
'protobuf>=4.21.6,<5.0'
],
},
% endif
Expand All @@ -77,6 +77,7 @@ setup(
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: System :: Hardware :: Hardware Drivers"
],
Expand Down
4 changes: 2 additions & 2 deletions build/templates/tox-system_tests.ini.mako
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox -c tox-system_tests.ini" from the driver directory. (generated/${module_name})
[tox]
envlist = ${wheel_env}py{38,39,310,311}-${module_name}-system_tests, py311-${module_name}-coverage
envlist = ${wheel_env}py{38,39,310,311,312}-${module_name}-system_tests, py312-${module_name}-coverage
skip_missing_interpreters=True
ignore_basepython_conflict=True
# We put the .tox directory outside of the Jenkins workspace so that it isn't wiped with the rest of the repo
Expand Down Expand Up @@ -85,7 +85,7 @@ deps =
${module_name}-coverage: coverage

depends =
${module_name}-coverage: py{38,39,310,311}-${module_name}-system_tests
${module_name}-coverage: py{38,39,310,311,312}-${module_name}-system_tests
% if uses_other_wheel:
${module_name}-system_tests: ${wheel_env}
% endif
Expand Down
19 changes: 16 additions & 3 deletions generated/nidcpower/nidcpower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def get_diagnostic_information():
note: Python bitness may be incorrect when running in a virtual environment
'''
import importlib.metadata
import os
import pkg_resources
import platform
import struct
import sys
Expand Down Expand Up @@ -64,8 +64,21 @@ def is_venv():
else:
raise SystemError('Unsupported platform: {}'.format(platform.system()))

installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]
if sys.version_info[1] >= 10:
installed_packages_names = [
name
for name_list in importlib.metadata.packages_distributions().values()
for name in name_list
]
installed_packages_names = set(installed_packages_names)
installed_packages_list = [
{'name': name, 'version': importlib.metadata.distribution(name).version}
for name in sorted(installed_packages_names)
]
else:
import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]

info['os']['name'] = os_name
info['os']['version'] = platform.version()
Expand Down
1,268 changes: 634 additions & 634 deletions generated/nidcpower/nidcpower/nidcpower_pb2.py

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions generated/nidcpower/nidcpower/nidevice_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 32 additions & 32 deletions generated/nidcpower/nidcpower/session_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions generated/nidcpower/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def read_contents(file_to_read):
],
extras_require={
'grpc': [
'grpcio>=1.49.1,<2.0',
'protobuf>=4.21,<5.0'
'grpcio>=1.59.0,<2.0',
'protobuf>=4.21.6,<5.0'
],
},
setup_requires=['pytest-runner', ],
Expand All @@ -66,6 +66,7 @@ def read_contents(file_to_read):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: System :: Hardware :: Hardware Drivers"
],
Expand Down
4 changes: 2 additions & 2 deletions generated/nidcpower/tox-system_tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox -c tox-system_tests.ini" from the driver directory. (generated/nidcpower)
[tox]
envlist = py{38,39,310,311}-nidcpower-system_tests, py311-nidcpower-coverage
envlist = py{38,39,310,311,312}-nidcpower-system_tests, py312-nidcpower-coverage
skip_missing_interpreters=True
ignore_basepython_conflict=True
# We put the .tox directory outside of the Jenkins workspace so that it isn't wiped with the rest of the repo
Expand Down Expand Up @@ -43,7 +43,7 @@ deps =
nidcpower-coverage: coverage

depends =
nidcpower-coverage: py{38,39,310,311}-nidcpower-system_tests
nidcpower-coverage: py{38,39,310,311,312}-nidcpower-system_tests

passenv =
GIT_BRANCH
Expand Down
19 changes: 16 additions & 3 deletions generated/nidigital/nidigital/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def get_diagnostic_information():
note: Python bitness may be incorrect when running in a virtual environment
'''
import importlib.metadata
import os
import pkg_resources
import platform
import struct
import sys
Expand Down Expand Up @@ -58,8 +58,21 @@ def is_venv():
else:
raise SystemError('Unsupported platform: {}'.format(platform.system()))

installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]
if sys.version_info[1] >= 10:
installed_packages_names = [
name
for name_list in importlib.metadata.packages_distributions().values()
for name in name_list
]
installed_packages_names = set(installed_packages_names)
installed_packages_list = [
{'name': name, 'version': importlib.metadata.distribution(name).version}
for name in sorted(installed_packages_names)
]
else:
import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]

info['os']['name'] = os_name
info['os']['version'] = platform.version()
Expand Down
24 changes: 12 additions & 12 deletions generated/nidigital/nidigital/nidevice_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,132 changes: 566 additions & 566 deletions generated/nidigital/nidigital/nidigitalpattern_pb2.py

Large diffs are not rendered by default.

Loading

0 comments on commit 81e371c

Please sign in to comment.