Download it now!
Bug 130911 - Policy on converting Perl scripts to Python
Summary: Policy on converting Perl scripts to Python
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.0.0
Keywords: difficultyMedium, easyHack, skillPython, skillScript, topicCleanup
Depends on:
Blocks:
 
Reported: 2020-02-24 21:10 UTC by Jussi Pakkanen
Modified: 2020-04-24 10:06 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jussi Pakkanen 2020-02-24 21:10:26 UTC
As per the discussion in https://gerrit.libreoffice.org/c/core/+/89262

I would like to propose that converting Perl scripts used in Libreoffice can be ported to Python without needing any special rationale. The reasons for this are:

- more people know Python than Perl
- new developers (i.e. anyone under 35) do not know Perl at all
- Python is a lot more readable in any case
- Python has builtin functionality for a lot things where Perl needs to call external executables (like zip, tar), reducing dependencies
- Converting all Perl code to Python is (in practice) a requirement for removing Cygwin as a build dependency on Windows 

In practice this would mean that merge requests that convert Perl to Python could just have this in their commit messages:

See tdf#XXXXX for motivation.
Comment 1 Mike Kaganski 2020-02-25 07:32:12 UTC
I agree. Even if only as a pre-requisite to drop Cygwin dependency, this is already valid.
Comment 2 Commit Notification 2020-03-06 11:32:55 UTC
Jussi Pakkanen committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6ec05ef6fef789f5646b773495285e845e155d77

tdf#130911: convert some token generation scripts from Perl to Python.

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2020-03-20 08:53:01 UTC
Jussi Pakkanen committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b29fb89d0a49fde0f5757774d64a7aba8298ac75

tdf#130911: convert image-sort from Perl to Python

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Samuel Mehrbrodt (allotropia) 2020-03-20 13:15:44 UTC
Making an easy hack out of this.

Just pick one of the perl files: https://opengrok.libreoffice.org/search?project=core&type=perl
Comment 5 Commit Notification 2020-03-31 19:53:23 UTC
Jussi Pakkanen committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d2c23609083d7b3e5267b1e4c923476cbc509d00

tdf#130911: convert desktop-translate from Perl to Python.

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Olivier Hallot 2020-04-10 01:10:49 UTC
Build fails. Linux Kubuntu, latest release.

autogen.input:

--with-lang=ALL
--with-help=online
--with-omindex=server
--without-krb5
--disable-postgresql-sdbc
--with-jdk-home=/usr/lib/jvm/default-java
--enable-kf5
--enable-qt5
--enable-gtk3-kde5
--with-myspell-dicts


Crash at

Traceback (most recent call last):
  File "/home/tdf/git/core/solenv/bin/desktop-translate.py", line 82, in <module>
    assert(value[-1] == '"')
AssertionError
Traceback (most recent call last):
  File "/home/tdf/git/core/solenv/bin/desktop-translate.py", line 82, in <module>
    assert(value[-1] == '"')
AssertionError
make[1]: *** [/home/tdf/git/core/sysui/CustomTarget_share.mk:245: /home/tdf/git/core/workdir/CustomTarget/sysui/share/libreofficedev/build.flag] Error 1
Comment 7 Jussi Pakkanen 2020-04-10 17:39:11 UTC
Can you test if this fixes it for you:

https://gerrit.libreoffice.org/c/core/+/92050
Comment 8 Olivier Hallot 2020-04-11 02:33:32 UTC
(In reply to Jussi Pakkanen from comment #7)
> Can you test if this fixes it for you:
> 
> https://gerrit.libreoffice.org/c/core/+/92050

Build in now OK with the patch
Comment 9 Stephan Bergmann 2020-04-24 08:21:54 UTC
(In reply to Olivier Hallot from comment #8)
> (In reply to Jussi Pakkanen from comment #7)
> > Can you test if this fixes it for you:
> > 
> > https://gerrit.libreoffice.org/c/core/+/92050
> 
> Build in now OK with the patch

but see <https://gerrit.libreoffice.org/c/core/+/92838> "Properly escape desktop file string values"
Comment 10 Stephan Bergmann 2020-04-24 10:06:58 UTC
(In reply to Jussi Pakkanen from comment #0)
> As per the discussion in https://gerrit.libreoffice.org/c/core/+/89262
> 
> I would like to propose that converting Perl scripts used in Libreoffice can
> be ported to Python without needing any special rationale. The reasons for
> this are:
> 
> - more people know Python than Perl
> - new developers (i.e. anyone under 35) do not know Perl at all
> - Python is a lot more readable in any case
> - Python has builtin functionality for a lot things where Perl needs to call
> external executables (like zip, tar), reducing dependencies
> - Converting all Perl code to Python is (in practice) a requirement for
> removing Cygwin as a build dependency on Windows 

I am not convinced that the above benefits necessarily outweigh the costs, though, or that any actual costs of conversion are at least distributed fairly in the developer base.  For example, I haven't counted the hours I had to spent on <https://git.libreoffice.org/core/+/13aebf3dc75a73b381fb8d72c9788a8ee5aa911c%5E!/> "Missing dependency", <https://git.libreoffice.org/core/+/9831d806ca7223058f74c61f4e1254c84464014d%5E!/> "Fix desktop-translate.py", <https://git.libreoffice.org/core/+/009db597027890ade07d31674c740ae0fc432f87%5E!/> "Only process with brand.pl the *.keys and *.desktop files", and <https://git.libreoffice.org/core/+/3f38a57a4ed8515dd145aea46ed697f101409c2f%5E!/> "Properly escape desktop file string values" after the change from comment 5.  (Though to be fair, the last two of those commits helped to find and address pre-existing issues.)