New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace LooseVersion with pkg_resource.parse_version #254
Conversation
|
The PR is related to integration improvements and pip-installable effort, https://fedorahosted.org/freeipa/ticket/6468. |
|
I have a sneaky suspicion that the parse_version couldn't cope correctly with some of the downstream versioning schemes like RHEL z-stream releases and such. That should be OK with API version, but client/server versions can pose a problem. There is are some examples in the ipatests/test_ipaserver/test_version_comparison.py I made when solving a bug that was caused by incorrect version comparison. Can you check if parse_version can handle them correctly? |
|
sigh, you are right, parse_version does not handle one version comparison as we expect: |
|
In case you wonder what is going on, LooseVersion is both loose and dumb. The legacy version parser parses the version strings differently: |
|
Yes that's why we resorted to a direct CFFI call to RPM libs during server version check in upgrade. We simply could not win aside from re-implementing parsing of Z-stream versions etc. from scratch. |
0ae19f1
to
7d5b902
Compare
|
I reworked my PR to use |
|
I was thinking about this a bit, and was wondering whether the platform-specific idiosyncracies of the version handling could be safely confined to the platform-specific code. I.E ipaplatform.base would define version comparisons via standard The one thing that could be broken by this would be scenarios like Fedora clients talking to RHEL masters etc., but I think those sceniarios are not handled correctly by the current implementation anyway. Another thing I was thinking about is whether we could use some proxy object in ipalib/ipaclient/ipapython libs which would use version comparison from ipaplatform if present, and if not use standard Python algorithms. What I am aiming at that we should reduce the dependency of the PyPI candidate code on ipaplatform madness as much as is humanly possible. IMHO if we really want to use these modules in PyPI, then they ideally should not depend on ipaplatform at all. |
|
Upon closer inspection of the affected code it seems that all the code in ipalib/ipaclient/ipapython actually parses and compares API versions, which are sane and parseable by |
Somebody used a time machine and implemented your proposal already. IMHO it's ok to use |
|
Oh right, ok. My code reading skills are sub-par today. |
Yeah, I did.
As Martin said, we have two versions: package released version and API version. For released package version we need RPM/platform specific parser, but API version is just 2 numbers and standard python function can be used. It is the same accross platforms. API version is less important now, because we have versions of commads that scales better, and one day we may drop this overall API version completely. If you want to avoid importing platform then is fine to use standard python functions to compare API versions. Actually that rpmlib scares me. |
|
Thank you for PY3 fix, it actually belongs to this ticket https://fedorahosted.org/freeipa/ticket/6473 |
|
Back to |
|
It seems that your changes broke IPA upgrade: Traceback in ipaserver-install.log: |
|
setuptool's version parser does not support slicing. I need to find another solution for |
|
@martbab more fun, the doc string of https://github.com/freeipa/freeipa/blob/master/ipalib/frontend.py#L764 |
|
LGTM but please add the relevant ticket number into the commit message. |
pylint is having a hard time with distutils.version in tox's virtual envs. virtualenv uses some tricks to provide a virtual distutils package, pylint can't cope with. pylint-dev/pylint#73 suggests to use pkg_resources instead. pkg_resources' version parser has some more benefits, e.g. PEP 440 conformity. But pkg_resources.parse_version() is a heavy weight solution with reduced functionality, e.g. no access to major version. For API_VERSION and plugin version we can use a much simpler and faster approach. https://fedorahosted.org/freeipa/ticket/6468 Signed-off-by: Christian Heimes <cheimes@redhat.com>
|
Fixed upstream |
pylint is having a hard time with distutils.version in tox's virtual
envs. virtualenv uses some tricks to provide a virtual distutils
package, pylint can't cope with.
pylint-dev/pylint#73 suggests to use pkg_resources
instead. pkg_resources' version parser has some more benefits, e.g. PEP
440 conformity.
Signed-off-by: Christian Heimes cheimes@redhat.com