building WorldEngine on MacOS X Yosemite under Python 3

94 views
Skip to first unread message

Mike Simpson

unread,
Jul 15, 2015, 10:42:06 PM7/15/15
to world...@googlegroups.com
So, it took me a little bit of finagling to get WorldEngine running on my Mac laptop under Python 3.x, and since I combined a bunch of different tips and tricks from various Google searches, I thought I'd summarize the process here, in case it's of use to anyone ... no promises about the following being at all optimal, since there was a lot of scrambling around and trying different things during the process.  But as best as I can document it from my notes:
  • The base platform was a recent-gen MacBook Pro running OS X Yosemite, version 10.10.4, including Xcode 6.4 and the associated command-line tools.

  • Prior to starting the process, I had already installed the Homebrew package manager, and then used it to install a non-system instance of Python 3.4.3, via:

    % brew update && brew install python3

    Note that this symlinks the Python executables in /usr/local/bin with "*3" suffixes, to differentiate them from the system-supplied Python 2.x that lives in /usr/bin, e.g. "/usr/local/bin/pip3", "/usr/local/bin/python3", etc.

  • I built out all of the source under /usr/local:

    % cd /usr/local
    % mkdir src ; cd src

  • There were a couple of prerequisites ("cmake", used by plate-tectonics, and the Python 3-compliant branches of "PyInstaller" and "protobuf") that needed to be installed first:

    % brew install cmake

    % curl -Lo pyinstaller-python3.zip https://github.com/pyinstaller/pyinstaller/archive/python3.zip
    % pip3 install pyinstaller-python3.zip

    % pip3 install -Iv protobuf==3.0.0-alpha-1

  • Then it was time to build and install the "plate-tectonics" library from source:

    % git clone https://github.com/Mindwerks/plate-tectonics.git
    % cd plate-tectonics
    % cmake .
    % make
    % cp -p libPlateTectonics.a /usr/local/lib
    % cp -p src/platecapi.hpp /usr/local/include
    % cp -p src/utils.hpp /usr/local/include
    % cd ..


    Note that the copy commands seemed to be necessary (or sufficient, anyway) to put the appropriate library and header files in locations where they would be automatically found later on during the compilation of the WorldEngine Python bindings.

  • Finally I compiled and installed the main "worldengine" code from source:

    % git clone https://github.com/Mindwerks/worldengine.git
    % cd worldengine
    % pip3 install -r requirements_base.txt


    Note that I installed the requirements from the base file; the "requirements3.txt" file adds the older 2.x version of "protobuf-py3", which wasn't needed since I had already installed the 3.x alpha version, up above.

    Everything built and installed at this point, but I then ran into problems at runtime.  I tracked back the errors and made a few modifications to the Python source, based on some Python 3-compliance notes about execfileimport syntax, and xrange/range.  I also changed the protobuf-py3 dependency definition in the "setup.py" file.  I've posted a Gist of the results of "git diff" to document the changes I made -- once those were in place, I could successfully build, install, and run "worldengine":

    % python3 setup.py build
    % python3 setup.py install

    % cd
    % worldengine world -v -n testworld -s 9 -x 128 -y 128 -q 9

       
    [ ... got the expected output and some lovely images ... ]


I just realized that I installed PyInstaller, but in the end, didn't wind up using it for anything -- oh well. :)

As always, YMMV.

.s9

Federico Tomassetti

unread,
Jul 18, 2015, 7:24:10 AM7/18/15
to Mike Simpson, world...@googlegroups.com
Thank you, thank you, thank you for sharing this!

Would be ok if I copy it and inser it in our wiki, of course citing you?

Cheers,
Federico
> --
> Visit the homepage of the project at
> https://github.com/Mindwerks/worldengine
> ---
> You received this message because you are subscribed to the Google Groups
> "worldengine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to worldengine...@googlegroups.com.
> To post to this group, send email to world...@googlegroups.com.
> Visit this group at http://groups.google.com/group/worldengine.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/worldengine/92b07bac-f9f8-4eda-b21d-595c79e20bbf%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Website at http://tomassetti.me
GitHub https://github.com/ftomassetti

Mike Simpson

unread,
Jul 18, 2015, 11:11:57 AM7/18/15
to world...@googlegroups.com, sten...@gmail.com
Federico --

Absolutely, no worries -- if anyone else wants to try to replicate the procedures, I'd be happy to help, and it probably wouldn't hurt: I only did it once, so that's not a lot of verification that the process actually works. :)

.s9

Mike Simpson

unread,
Jul 18, 2015, 11:56:14 AM7/18/15
to world...@googlegroups.com
Speaking of which, I just found two more Python 3-related tweaks that I missed, that were breaking the ancient_map generation: one related to a change in byte objects, and another due to a change in the way Python 3 does metaclass hooks.  I re-generated the git diff gist with the new tweaks in place.

.s9

ADUYM

unread,
Nov 4, 2016, 6:54:46 PM11/4/16
to worldengine
Hi Mike,

I tried following your instructions and got as far as the step(s) where you made modifications to the Python source. I have to confess, I have essentially no experience with python and a relatively rudimentary understanding of programming overall. I am running Mac OS Sierra 10.12.1 on a Mac Book Pro. Would you be able to elaborate on where and how I am supposed to implement the source code modifications? I tried copying and pasting the whole thing into terminal, then tried manually editing the source code, neither of which seemed to work (sorry, those are probably embarrassingly wrong things to do). Any suggestions or guidance would be appreciated.

Alex   

Mike Simpson

unread,
Nov 6, 2016, 11:16:38 AM11/6/16
to worldengine
Alex --

Not meant to discourage you if you're really into it, but given that you don't have a lot of Python experience, is there a reason you're trying to get it to run under Python 3?  E.g. on my OS X 10.11.6 (El Capitan) install, I just downloaded the pre-built 0.19 release for MacOS (from https://github.com/Mindwerks/worldengine/releases), un-bzip'd and un-tar'd it, then just ran the "worldengine" binary provided -- if you're just interested in running the generator, using the pre-built package is going to be a lot easier than re-implementing my old Python 3 compatibility hacks.

.s9
Reply all
Reply to author
Forward
0 new messages