PythonScanClient / PyScanClient

Python Client for CS-Studio Scan Service
Eclipse Public License 1.0
3 stars 4 forks source link

Support Python3 #22

Closed dxmaxwell closed 5 years ago

dxmaxwell commented 5 years ago

I would like to use the ScanClient in Python3, @kasemir have you given this any consideration?

I used the 2to3 program to convert this library and there were no errors. However some of the changes would break compatibility with Python2, particularly around use of urllib, but I imagine that some workarounds exist for these issues. I don't have much experience supporting Python2 and 3 at the same time, but I could put together a PR if you're interested.

kasemir commented 5 years ago

Moving to python 3 would be OK when calling the library from C-python (3). But we're also calling it from within displays that submit scans, i.e. from jython. Jython doesn't support python 3, unclear ever; https://stackoverflow.com/questions/2351008/when-will-jython-support-python-3.

I would be OK with creating a python3 branch, so those who only call the lib from C python can then get started with P3.

dxmaxwell commented 5 years ago

I agree that a new branch is a good place to start. It seems like Jython supports the future module, so it may be possible to support all three interpreters. Either way I need this for an upcoming project so I have to get it working with Python3, or move everything back to Python2. What version of Jython are you using?

kasemir commented 5 years ago
<dependency>
      <groupId>org.python</groupId>
      <artifactId>jython-standalone</artifactId>
      <version>2.7.1</version>
</dependency>
dxmaxwell commented 5 years ago

I remember when I last looked at this library it was important to use the builtin 'urllib2' module to support both Jython and CPython interpreters. But I see that since then a special implementation was added for Java to overcome some bugs related to the 'urllib2' implementation in Jython in the v2.7.1 release. Perhaps the primary implementation could now be switched to the 'requests' library? The main advantage being that it already supports P2 and P3.

kasemir commented 5 years ago

I think all the network interaction is inside the scanclient.py perform_request method, so yes, you could update that to the requests lib for C python.

dxmaxwell commented 5 years ago

The library has been updated to support Python3. All the stand alone tests passed (on python2, python3 and jython), except for one that I reported in issue #23. I will continue with integration testing this week.

kasemir commented 5 years ago

Good, go ahead with a pull request.

dxmaxwell commented 5 years ago

The library has been updated to support Python3. All the stand alone tests passed (on python2, python3 and jython), except for one that I reported in issue #23. I will continue with integration testing this week.

dxmaxwell commented 5 years ago

Did some basic testing with an actual scan server and it's working as expected. PR #25

dxmaxwell commented 5 years ago

Updated the version number PR #26

dxmaxwell commented 5 years ago

Been using this library in Python3 and it is working as expected.