Bug 242997 - games/oolite: Fix build for Python 3.x
Summary: games/oolite: Fix build for Python 3.x
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Rene Ladan
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-12-31 00:33 UTC by lightside
Modified: 2020-02-03 19:40 UTC (History)
3 users (show)

See Also:


Attachments
Proposed patch (since 520894 revision) (2.31 KB, patch)
2019-12-31 00:33 UTC, lightside
no flags Details | Diff
Proposed patch (since 520894 revision) (2.32 KB, patch)
2019-12-31 00:49 UTC, lightside
no flags Details | Diff
Proposed patch (since 520894 revision) (2.30 KB, patch)
2019-12-31 12:47 UTC, lightside
no flags Details | Diff
Proposed patch (since 520894 revision, Python 3.5+ variant) (1.67 KB, patch)
2020-01-17 09:51 UTC, lightside
no flags Details | Diff
Proposed patch (since 520894 revision) (5.55 KB, patch)
2020-01-27 21:41 UTC, lightside
no flags Details | Diff
Proposed patch (since 520894 revision, Python 3.5+ variant) (4.84 KB, patch)
2020-01-28 01:22 UTC, lightside
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lightside 2019-12-31 00:33:25 UTC
Created attachment 210342 [details]
Proposed patch (since 520894 revision)

Patch to fix build with using Python 3.x for games/oolite port (v1.88).

- Use cached Python path for configure on build stage
- Use 2to3 script to convert required *.py scripts from 2 to 3 version
Comment 1 lightside 2019-12-31 00:49:41 UTC
Created attachment 210343 [details]
Proposed patch (since 520894 revision)

Changed PREFIX to LOCALBASE for 2to3 path.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2019-12-31 02:05:34 UTC
@lightside Thank you for the patch

Could you please:

 - Submit this patch upstream as an issue or pull request, and include the issue/PR URL in the See Also field

 - Confirm that this change passes QA (poudriere)

Also, if you are able to, and in order to ensure games/oolite remains available and usable by users, consider maintaining this port. Please include an update to the MAINTAINER line if you can
Comment 3 lightside 2019-12-31 12:47:36 UTC
Created attachment 210354 [details]
Proposed patch (since 520894 revision)

- Cosmetic changes.

Hello, Kubilay Kocak.

(In reply to Kubilay Kocak from comment #2)
> Could you please:
> 
>  - Submit this patch upstream as an issue or pull request, and include the
> issue/PR URL in the See Also field
Sorry, but I can't (or not interested). There is no patch. There are only (temporary) dynamic changes with using 2to3 script, provided by Python installation.
But if remove "--no-diffs" option for invocation of 2to3 script, it shows changes for usage of print function:
-8<--
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored imacro_asm.py
--- imacro_asm.py	(original)
+++ imacro_asm.py	(refactored)
@@ -456,7 +456,7 @@
 if __name__ == '__main__':
     import sys
     if len(sys.argv) != 3:
-        print "usage: python imacro_asm.py infile.jsasm outfile.c.out"
+        print("usage: python imacro_asm.py infile.jsasm outfile.c.out")
         sys.exit(1)
 
     f = open(sys.argv[2], 'w')
RefactoringTool: Refactored build/cl.py
--- build/cl.py	(original)
+++ build/cl.py	(refactored)
@@ -51,7 +51,7 @@
             break
 
     if target == None:
-        print >>sys.stderr, "No target set" and sys.exit(1)
+        print("No target set" and sys.exit(1), file=sys.stderr)
 
     # The deps target lives here
     depstarget = os.path.basename(target) + ".pp"
@@ -90,7 +90,7 @@
 
     f = open(depstarget, "w")
     for dep in sorted(deps):
-        print >>f, "%s: %s" % (target, dep)
+        print("%s: %s" % (target, dep), file=f)
 
 if __name__ == "__main__":
     InvokeClWithDependencyGeneration(sys.argv[1:])
RefactoringTool: Files that were modified:
RefactoringTool: imacro_asm.py
RefactoringTool: build/cl.py
-->8-

Also, the custom version of SpyderMonkey is just a external dependency for OOlite, if looking for source code:
https://github.com/OoliteProject/oolite/tree/1.88/deps
https://github.com/OoliteProject/spidermonkey-ff4/blob/ca2fb5423fab4d72a3dc5fec911ce20bda01f223/README.txt

I guess, if developers may want to support Python 3.x version, they can do this with using 2to3 script, if needed. There is no defect and it normally works with using Python 2.x version. This is just a build dependency.

> - Confirm that this change passes QA (poudriere)
It passes build with using Python 3.x version:
-8<--
% make PYTHON_VERSION=3.6 clean check-plist
<..>
Configuring Javascript library...

mkdir -p deps/mozilla/js/src/build-release
<..>
checking for python2.7... (cached) /usr/local/bin/python3.6
<..>
checking for Python version >= 2.5... yes
<..>
====> Compressing man pages (compress-man)
====> Running Q/A tests (stage-qa)
====> Checking for pkg-plist issues (check-plist)
===> Parsing plist
===> Checking for items in STAGEDIR missing from pkg-plist
===> Checking for items in pkg-plist which are not in STAGEDIR
===> No pkg-plist issues found (check-plist)
-->8-

> Please include an update to the MAINTAINER line if you can
Thanks, but I interested in this PR only.
Comment 4 lightside 2020-01-17 09:51:25 UTC
Created attachment 210814 [details]
Proposed patch (since 520894 revision, Python 3.5+ variant)

Added patch for Python 3.5+ variant, since Python 3.7 version is by default in Mk/bsd.default-versions.mk file.
But lang/python27 port still exists, therefore committer may decide what to use.
Comment 5 lightside 2020-01-17 10:09:33 UTC
Also note, that related dynamic patches and 2to3 usage was moved to pre-configure stage on purpose:
- To support Python 2.7+ also (for first variant).
- To not affect files/patch-deps_mozilla_js_src_configure patch, without a need to regenerate it (if `make patch` used), because this is a possible temporary case before Python 3 support from developers.
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2020-01-22 05:43:07 UTC
(In reply to lightside from comment #5)

USES=python:<version> spec is declarative, not imperative, and should describe the Python versions a package 'supports', not which Python versions it should 'use', which is the responsibility of the ports framework and ultimately the user to select.

If oolite supports Python 2.x/3.x, USES=python:<version-spec> should be 2.7+ or 2.7-3.x where x is the highest currently supported Python 3.x version
Comment 7 lightside 2020-01-22 16:06:49 UTC
(In reply to Kubilay Kocak from comment #6)
> If oolite supports Python 2.x/3.x, USES=python:<version-spec> should be 2.7+
> or 2.7-3.x where x is the highest currently supported Python 3.x version
Yes, games/oolite build system supports Python 2.x. The dynamic patches and usage of 2to3 program before build stage allows to build with using Python 3.x. So, the first patch in attachment #210354 [details], which uses 2.7+ should be fine, while lang/python27 port is available (and not deprecated). I obsoleted attachment #210814 [details].

Thanks for clarification.
Comment 8 Rene Ladan freebsd_committer 2020-01-27 20:23:41 UTC
Can't we just make static patches (by importing future) instead of dynamically fiddling with the code? Also USES=python implies python 2.7 or higher, so no need to mention that explicitly.
Comment 9 lightside 2020-01-27 21:41:56 UTC
Created attachment 211114 [details]
Proposed patch (since 520894 revision)

Hello, Rene Ladan.

(In reply to Rene Ladan from comment #8)
Ok, I proposed static patches, instead of using 2to3 and sed programs for this case.

Thanks for attention.
Comment 10 lightside 2020-01-28 01:22:04 UTC
Created attachment 211118 [details]
Proposed patch (since 520894 revision, Python 3.5+ variant)

Also possible to propose a patch, which uses Python 3.x only, since Python 3.7 version is by default in Mk/bsd.default-versions.mk file. It differs from attachment #210814 [details] by using static patches. Otherwise, on committer preference.
Comment 11 commit-hook freebsd_committer 2020-02-03 13:46:41 UTC
A commit references this bug:

Author: rene
Date: Mon Feb  3 13:45:50 UTC 2020
New revision: 525036
URL: https://svnweb.freebsd.org/changeset/ports/525036

Log:
  games/oolite: build with Python 3.5 or later, undeprecate

  PR:             242997
  Submitted by:   lightside

Changes:
  head/games/oolite/Makefile
  head/games/oolite/files/patch-deps_mozilla_js_src_configure
  head/games/oolite/files/patch-deps_mozilla_js_src_configure.in
  head/games/oolite/files/patch-fixup-python
Comment 12 Rene Ladan freebsd_committer 2020-02-03 19:40:27 UTC
I've committed the 3.5 patch, thanks!