#48204 support python3
Closed: wontfix None Opened 8 years ago by rmeggins.

We need to support python3 in our python scripts. This means

  • lib389
  • dirsrvtests
  • named pipe log scripts
  • other python code

The great summary for information about porting to python3 can be found at[0].

The best way to start is firstly to port all your tests to python3:
I recommend to run 2to3[1] tool on your tests to identify any incompatibilities which may occur and then fix them according to guide[2] to maintain python2 compatibility (2to3 simply converts python2 code to python3, also it is important to mention that 2to3 doesn't find all the differences)
Run tests with both python2 and python3 to identify problems and fix them using[2] (again, 2to3 may come handy).

[0] http://python3porting.com/
[1]

$ rpm -qf /usr/bin/2to3
python-tools-2.7.10-1.fc22.x86_64
[2] http://python3porting.com/noconv.html

Feodra 23 will start the python3 default delivery. Setting milestone to 1.3.5

Progress on this ticket is blocked by python3 not having an ldap module.

It seems that only the testing code needs python-ldap. The current Fedora effort to switch to python3 is focused on released code; tests, Build''''''''''Requires and infrastructure is somewhat less urgent.

I'll attach a patch for ds-logpipe, which seems to be the only Python code that ends up in the final RPM.

Replying to [comment:6 pviktori]:

It seems that only the testing code needs python-ldap. The current Fedora effort to switch to python3 is focused on released code; tests, Build''''''''''Requires and infrastructure is somewhat less urgent.

I'll attach a patch for ds-logpipe, which seems to be the only Python code that ends up in the final RPM.

Thanks for the patch, but I already have a patch for everything, including lib389. Its just that lib389 won't run anymore in python 3 because of the ldap module. I guess for now we can just patch the local DS scripts.

That would be great.
As I understand it, the DS (including the logpipe script) can be tested by the python2 version of lib389, so python2 can just be a dependency for testing.

Even patching the DS scripts would be really helpful for us (Fedora), can we count on that to happen? Along with official release?

Replying to [comment:9 rkuska]:

Even patching the DS scripts would be really helpful for us (Fedora), can we count on that to happen? Along with official release?

This will get pushed to the source for 389 version 1.3.5 (which should be our f23 release)

Replying to [comment:8 pviktori]:

That would be great.
As I understand it, the DS (including the logpipe script) can be tested by the python2 version of lib389, so python2 can just be a dependency for testing.

I'm acking your patch Petr. Do you want to push it to the master branch, or should I? Thanks!

Thanks! I don't have the rights to push to 389-ds, so it's your honor :)

acked and pushed

ff1c345..674eac2 master -> master
commit 674eac2
Author: Mark Reynolds mreynolds@redhat.com
Date: Wed Jul 8 14:25:04 2015 -0400

6c473cb..659c138 389-ds-base-1.3.4 -> 389-ds-base-1.3.4
commit 659c138
Author: Mark Reynolds mreynolds@redhat.com
Date: Wed Jul 8 14:25:04 2015 -0400

Thanks, Mark!

Sorry, may I ask you to investigate one more thing?

Miro HronĨok added this code to the 389-ds-base.spec. This command line touches the source code, which is not the right thing to do, I think... Is "/usr/bin/env python" really not good for python3? And there is no way to share the same python code between python2 and 3 (without doing this?)???
+# Make sure python3 is used in shebangs
+sed -r -i '1s|^#!\s/usr/bin.python.|#!%{__python3}|' ldap/admin/src/scripts/.py

Thanks!

P.S., for today's f23 build, I'm leaving the command line with "FIXME!!!"

It is up to downstream redistributors to choose the right shebang to use if upstream supports both Python2 and Python3.

/usr/bin/env python is really not good option for python3 and also not good for any python version if it is packaged as system package - RPM.
Currently there is no possibility to share python code between python2 and python3 and the only and correct way to have package run on python3 is to change the shebang. Please note that shebang is also altered automatically by setuptools if used and installed with setup.py.

Thanks Noriko!

To ssh://git.fedorahosted.org/git/389/ds.git
123df4d..18ae65b master -> master
commit 18ae65b
Author: Mark Reynolds mreynolds@redhat.com
Date: Wed Sep 2 16:00:13 2015 -0400

c6fd6a1..2783876 389-ds-base-1.3.4 -> 389-ds-base-1.3.4
commit 2783876

Next, I need to convert lib389...

After updating lib389 for python3, some tests needed to be reworked
0001-Ticket-48204-update-lib389-test-scripts-for-python-3.patch

Replying to [comment:24 rmeggins]:

https://fedorahosted.org/389/attachment/ticket/48204/0001-Ticket-48204-update-lib389-for-python3.patch#L352

The indentation seems wrong here.

Which file? I'm not seeing any issues on any line 352 in any one of those files, or line 352 in the patch file itself

Nevermind. I was confused.

Thanks Rich!

To ssh://git.fedorahosted.org/git/389/lib389.git
a5147f0..66e22b4 master -> master
commit 66e22b4cbe1ffb1bbe6c0fc4652443475b5ebb99
Author: Mark Reynolds mreynolds@redhat.com
Date: Fri Sep 4 15:50:36 2015 -0400

To ssh://git.fedorahosted.org/git/389/ds.git
2853143..3d0ae27 master -> master
commit 3d0ae27

2674f55..5bc311b 389-ds-base-1.3.4 -> 389-ds-base-1.3.4
commit 5bc311b

Metadata Update from @mreynolds:
- Issue assigned to mreynolds
- Issue set to the milestone: 1.3.4.5

7 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/1535

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

3 years ago

Login to comment on this ticket.

Metadata