Support Python 3
Currently splunklib only suppports Python 2. This is quite a bit annoying for those of us that have made the jump to Python 3, especially as the spunk api is not easily handleable via standard Python XML tools.
Hi @tylereaves
Thanks for reporting this. Splunk ships with the SDK in the box and currently it does not support Python 3. For this reason and due to the fact that Python 3 introduces significant / non-backward compat changes, we are holding off on Python 3 for now.
Back-porting of python functionality to versions 2.x ceased with the introduction of Python 3.2 in Feb 2011, almost four years ago. All scientific/numeric packages have long since made the transition, making 2.x untenable. Please correct this major deficiency.
I have begun work to port the code to python 3. Basing functionality (connecting, accessing indexes, query retrieval) work: https://github.com/martindurant/splunk-sdk-python
Hi @martindurant
First, thanks for your effort here, this is awesome. Second, are you planning to have backward compat API wise, or will it introduce breaking changes that would not be compat with Python 2.7?
As you see from my comments, I did not start this with a particular plan, and certainly I must have broken py2 compatability; although __future__ imports will fix some, I changed some module imports and bytes/string conversions.
All - thank you for the comments on this ticket, and the request. Let me try and explain a bit where @glennblock and I are coming from, so that it makes sense.
As you know, Splunk ships with Python 2.7. That is unlikely to change in the near-term, given the platform support matrix we have as well as some libraries still not being available on Python 3. Given that, we need to keep working on Python 2.x.
That said, we're not against having Python 3 support added, as long as it is:
- Backwards compatible with Python 2.x
- Does not break any features/behavior in the current SDK
- Does not preclude us from implementing things in the future
I think (3) is not a big risk, so as long as (1) and (2) are met, I think we'd be happy to take a pull request that achieved Python 3 compatibility.
I hope this helps explain the situation a little bit.
Would you be open to adding six as a dependency?
+1
I started writing a Python 2&3 compatible version with Six and future, but after making changes the Test Cases were not working and many revisions were coming in from the Splunk developers. I might revisit the Python 3 compatibility when time allots again.
@filmor we've been talking about it internally. The main issue we have with requiring six (or any other module) is that it would break the current pattern of not having any external dependencies. This is doubly important for us because of how some people use the SDK in their apps - they simply copy the splunklib folder into their app and don't need to worry about any dependencies.
If there was a way for us to not break that (i.e. not require pip/easy_install, have splunklib be entirely self contained), we'd be open to it.
From the Six documentation on https://pythonhosted.org/six/
Six provides simple utilities for wrapping over differences between Python 2 and Python 3. It is intended to support codebases that work on both Python 2 and 3 without modification. six consists of only one Python file, so it is painless to copy into a project. (emphasis mine)
Is it possible just to keep your SDK updated with the latest version of six prepackaged?
+1 it's time guys
Is it possible just to keep your SDK updated with the latest version of six prepackaged?
Since six is MIT licensed, I think this is reasonable especially since the license and version number are embedded in six.py.
Submitting a PR should be much easier now that we have support for Travis CI, so you don't have to run tests locally.
cannot agree more, considering pack six as a part of Public SDK (in its sub-folder like package/six.py), refer to request way
Pack six with the code and get it done. This is one of the last blockers for a large project I'am working on to move over to Python 3. It's time!
+1 from me as well. I'm working on a specific project where I really don't want to have to drop down to 2.7 just to get the data into Splunk using the SDK.
My organization has a large amount of Python 3 code we're integrating with Splunk, so we're doing it the hard way right now. Would it help if I submitted an enhancement request as a support ticket?
@buysse please do
It's high time. Please port the SDK to python 3.x
Python 2.7 will retire in 3 years, 1 month.... when can we expect this to be ported?