Skip to content
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

g.extension: change to python3 #83

Merged
merged 5 commits into from
Aug 11, 2019

Conversation

anikaweinmann
Copy link
Contributor

@anikaweinmann anikaweinmann commented Aug 7, 2019

Motivation: the Addons source code is to be used by multiple GRASS versions. Since 7.8+ Python 3 is expected while older versions need Python 2. Hence a global change in all Addons of shebang to Python 3 would be a problem.

Proposed solution: change shebang during installation.

@anikaweinmann anikaweinmann changed the title WIP: g.extension change to python3 WIP: g.extension: change to python3 Aug 7, 2019
@@ -675,8 +679,43 @@ def install_extension(source, url, xmlurl):
if sys.platform == "win32":
ret += install_extension_win(module)
else:
# set /usr/bin/python to python3 cause of python shebangs
ps = gscript.Popen((
"update-alternatives", "--install", "/usr/bin/python",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this part or would the change python -> python3 be enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Please also note that update-alternatives will not work on Windows or possibly on some Linux distos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the update-alternatives and replaces the shebangs for not Windows systems


# change python to python3 in shebang
proc = subprocess.Popen(
"which " + module, shell=True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which cannot be used since it's not multiplatform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the which is removed

@landam
Copy link
Member

landam commented Aug 7, 2019

  • "update-alternatives" have sometime to be done with "sudo"

  • shebang is changed for modules as well as for the modules in metamodules

Please can you explain in detail this PR.

@anikaweinmann
Copy link
Contributor Author

I've added code for windows, but unfortunately I can't test it.
If someone can test on windows and/or other systems, that would be great.

@anikaweinmann anikaweinmann changed the title WIP: g.extension: change to python3 g.extension: change to python3 Aug 8, 2019
@anikaweinmann anikaweinmann marked this pull request as ready for review August 8, 2019 11:31
@neteler neteler requested a review from hellik August 8, 2019 15:52
@neteler
Copy link
Member

neteler commented Aug 11, 2019

... merging PR for easier testing on Windows

@neteler neteler merged commit 89b2e78 into OSGeo:master Aug 11, 2019
@neteler
Copy link
Member

neteler commented Aug 11, 2019

Backported to relbranch78 in 494bbaf

petrasovaa pushed a commit to petrasovaa/grass that referenced this pull request Dec 3, 2019
* g.extension: change to python3
* g.extension: update for metamodules
* g.extension: python3 shebangs for windows
@neteler neteler added this to the 7.8.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants