labjack / labjack-ljm-python

LJM library Python wrapper for LabJack T4, T7 and T8.
MIT License
38 stars 21 forks source link

Add Python 3.12 Compatibility #22

Open NickLavrov opened 2 months ago

NickLavrov commented 2 months ago

In setup.py in CLASSIFIERS please specify that python 3.12 is supported (if so). Given that there are no external package dependencies, there is nothing to update dependency-wise.

There is no test suite included in this repo, but I did this: Plug in LabJack T7 PRO via ethernet to my M1 Mac and run: find Examples/Basic -name "*.py" | xargs -I {} python {} 2 (the 2 is for the loop counter argument in labjack-ljm-python/Examples/Basic/write_read_loop_with_config.py so it doesn't loop infinitely). All files ran successfully with python 3.12, with the package installed as pip install -e .. I did not run all the tests in Examples/More because I don't use the other connection methods or advanced aspects of this package.

Looking at how python 3.11 compatibility was added with no changes, I suspect this to not require many changes. One thing is setuptools: (from AI) The setuptools package is still available in Python 3.12 and provides the distutils module, which was deprecated in Python 3.10 and removed in Python 3.12. However, distutils is no longer available by default in virtual environments created with venv. To access it, you can run pip install setuptools in the activated virtual environment. (end of AI). This means that whatever build and release process is used here, if using a venv, will need to install setuptools, likely.

davelopez01 commented 2 months ago

Thank you for letting us know about this. We will add Python 3.12 to CLASSIFIERS in our next release. Doing quick tests, the latest labjack-ljm package on PyPi installs with 3.12 fine, and examples seem fine. We will test with 3.12 more thoroughly when we update.

The older method of installing with local files:

python setup.py install

Cannot find setuptools by default in 3.12, but the current recommended way (run in the package's root directory):

python -m pip install .

Will install the setuptools dependency for the installation. Also, "python -m build" will install the setuptools dependency during the build.