Skip to content

Add MapScript support for Python 3.x#5561

Merged
Schpidi merged 1 commit intoMapServer:masterfrom
claudep:py3
Mar 23, 2018
Merged

Add MapScript support for Python 3.x#5561
Schpidi merged 1 commit intoMapServer:masterfrom
claudep:py3

Conversation

@claudep
Copy link
Copy Markdown
Contributor

@claudep claudep commented Mar 15, 2018

Allows MapScript to build and run against Python 3.4.
The changes appear to continue to work with Python 2.7.

If there are multiple Python versions installed on your machine,
the Python version that is selected is whatever CMake finds first
or the path set with -DPYTHON_EXECUTABLE=

Changes include:

  • print "" ---> print("")
  • raise E, "text" ---> raise E("text")
  • PyString_FromStringAndSize() ---> PyBytes_FromStringAndSize()
  • Remove references to PyFile*

Allows MapScript to build and run against Python 3.4.
The changes appear to continue to work with Python 2.7.

If there are multiple Python versions installed on your machine,
the Python version that is selected is whatever CMake finds first
or the path set with -DPYTHON_EXECUTABLE=

Changes include:
* print ""                     ---> print("")
* raise E, "text"              ---> raise E("text")
* PyString_FromStringAndSize() ---> PyBytes_FromStringAndSize()
* Remove references to PyFile*
@geographika
Copy link
Copy Markdown
Member

geographika commented Mar 23, 2018

I've tried this pull request on a Windows machine with Python3. The build is fine when using SWIG 3.0.12.
Thanks @claudep !

There a few unit test fixes for Python3 syntax, but after making these all but 2 of the tests that pass in Python2 pass in Python3. These are both in the imagetest.py file and relate to writing an image to file. The majority of the tests from this test file also fail in Python3 so the writing of images to file probably needs to be reviewed in depth.

Summary - pull request looks good to me - Python MapScript works as well on Python3 as Python2, and there are large parts of the MapScript API to review as several tests and the docs are no longer up-to-date.

@claudep
Copy link
Copy Markdown
Contributor Author

claudep commented Mar 23, 2018

There a few unit test fixes for Python3 syntax, but after making these

Feel free to make a PR against my branch.

@Schpidi
Copy link
Copy Markdown
Member

Schpidi commented Mar 23, 2018

We tested this here at the code sprint in Bonn and agreed that it is fine to merge. It might break Python 2.6 but this is out of maintenance since 2013 anyways. Many thanks for the contribution!

@Schpidi Schpidi merged commit 0475509 into MapServer:master Mar 23, 2018
@claudep claudep deleted the py3 branch March 23, 2018 13:16
@claudep
Copy link
Copy Markdown
Contributor Author

claudep commented Mar 23, 2018

Thanks for merging. I proposed a follow-up with a bunch of test syntax issues in #5572.

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.

4 participants