Help building editor on Mac, Python 3 required?

I’m trying to build the editor on my Mac running Big Sur. When I try to grab external packages:

python2 ./scripts/build.py install_ext --platform=x86_64-darwin --package-path=./mystuff

I end up seeing lot of Python syntax errors, samples below.

File "build/bdist.macosx-11.2-x86_64/egg/pip/_internal/self_outdated_check.py", line 184
  pip_cmd = f"{sys.executable} -m pip"

File "/Users/martinfox/Programs/defold/defold/tmp/dynamo_home/ext/lib/python/pip-21.0.1-py2.7.egg/pip/_internal/configuration.py", line 167
  raise ConfigurationError(f"No such key - {key}")

All of the syntax errors involve f-strings which are a Python 3.6 feature according to my friendly neighborhood search engine (I’m not a Python coder). The Defold documentation states that the required Python version is 2.7.

(Note: I get the same problem if I drop the --platform option. And despite what the documentation shows the build.py script insists on having a --package-path specified.)

How do I get past this? Is the only option to install Python 3.6+?

No, don’t install Python 3. Have you followed all of the setup steps?

I believe I’ve followed the setup steps, there aren’t that many before invoking build.py to grab the external packages.

The same errors can be duplicated outside of the Defold build process, just try to install pip.

mkdir blah
PYTHONPATH=./blah python -m easy_install -d blah pip

On my Mac this command pulls down pip 21.0.1 which dropped support for Python 2 in January of this year.

Worked around this by altering build.py to explicitly request pip 20.3.4

run.env_command(self._form_env(), ['python', '-m', 'easy_install', '-q', '-d', join(self.ext, 'lib', 'python'), 'pip==20.3.4'])
2 Likes

Ah, good catch!
Sorry you had to deal with this!
At least it tells us that we’re being force to move towards python3 soon(-ish).

2 Likes

Do you want me to open an issue on this?

I’ve run into some other problems for which I’ve found work-arounds. In build.py the MacOS SDK is hard-coded to 10.15 and the XcodeDefault is hard-coded at 12.1. Since my Mac and Xcode are both up-to-date I have MacOS11.1 and XcodeDefault12.4 respectively.

In editor/project.clj it calls for codox 0.9.3 which doesn’t seem to be available on clojars. I slammed the version to 0.10.7 to get past this.

I am blocked when I try to build the editor with pre-built engine binaries. In editor/tasks/leiningen/init.clj it slurps in the VERSION file and then issues a git rev-list command using that string. It looks like the VERSION file was bumped up to 1.2.180 but there is no corresponding git tag so the git command fails. I could use some guidance on how to proceed with this one.

Thanks, we already have a ticket for updating Python.

As for the “work arounds”, it’s currently the way we do this too. Since we update so rarely, and it’s only 2-3 places to change, we haven’t prioritised improving it.
However, since newcomers often find this tricky, I think we should improve on it, to detect what version is currently installed.

it slurps in the VERSION

Hmm, that version file should only be used when building stable releases.
On dev, we have the alpha version, 1.2.180, and that one isn’t released to the stable channel. On the stable channel, we have version 1.2.179.
I think the problem is that it doesn’t pickup the fact that it should run towards the alpha channel.
I suspect we’ve changed something in our build scripts to fix something, and forgot to upgrade this part.

However, do you require the locally built engine or are you good with using the prebuilt engine?
If you are ok using the prebuilt version, we recommend using the editor-dev branch. That’s where we develop editor-only fixes, (e.g. it’s not file format changes to the engine), and it gets published as soon as we push something to it.

1 Like

I should have been clearer, do you want me to enter tickets for the spot fixes I’ve had to make? Specifically asking for an older version of pip and a newer version of codox.

I’m fine with hand-editing build.py to bump the SDK version numbers, it would just be nice if this was documented in the README. I could enter a ticket on that also if you want.

I will switch to a different branch for now, I don’t need to be on the dev branch as I learn the system. I hadn’t even noticed that git defaulted to dev instead of master when I cloned.

1 Like

Yes, please!

1 Like