Pull Request did not pass cdci

Hi, I’ve created a PR for cocos2dx v4 and it fails.
Not sure completely why. Does anybody can help me?

Thanks in advance.

You can explore it a bit.



Haha, yeah :slight_smile:

1 problem solved, 1 to go.

Now it is complaining about LUA. I don’t have it, should I install it to see what is going on?

Lua is part of your cocos2d-x install. There used to be a separate download but no longer.

You may need to regenerate the LUA bindings, because you’ve added new methods and constants to the API that need to be accessible from LUA. I’m not 100% certain about this, but it won’t hurt to try. Once you update the bindings, create an Android build of the LUA tests locally on your system to make sure it has no issues.

Check the folder: [cocos2dx install path]/tools/tolua

The binding generator script is named genbindings.py. Open up the README.mdown file in there for some info on how to use it.

Great thought. This makes sense

Hi, thank you for the suggestions, but I am a little lost with the NDK settings.

For Android I am using NDK version 21.1.6352462
I added this entry to my .bash_profile

export NDK_ROOT=~/Library/Android/sdk/ndk/21.1.6352462

Then execute
$ source ~/.bash_profile

Then in /tools/tolua
$ ./genbindings.py

But I am getting this error:
NDK_ROOT not defined. Please define NDK_ROOT in your environment.

My python is 2.7

Thanks in advance.

Install NDK16b, because if I recall correctly, there are problems using anything newer with the genbindings.py script. It can be installed side-by-side with any other version of NDK you may be using.

Ok, I am making baby steps here :slight_smile:
I have NDK16 now and I am getting a new error.

ImportError: No module named yaml

I have these phytons

$ python --version
Python 2.7.16
$ python3 --version
Python 3.7.6

I’ve installed yaml for phyton3 by running,
$ pip3 install pyyaml

for old python I am getting an error on installing

And still I am getting the same error.
I guess I need to setup phyton 2.7 correctly, right?

I am not a phyton savvy :grimacing:

PS: Would be better to have this ./genbindings.py as part of CDCI process? :slight_smile:

Try the suggestions here using pip:


I recall seeing it in the CI build logs, so it may actually be in there. You still need to generate it yourself and test it though, just to ensure that the bindings are correct, because sometimes it can’t auto-generate the bindings, which means you need to code them manually.

I made same progress but a print inside the .py is an giving error.

Which makes me ask, which python is this script for?
Or can you run this .py on my behalf?



$ ./genbindings.py
generating userconf.ini...
Generating bindings for cocos2dx_backend...
/usr/local/bin/python3 /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/bindings-generator/generator.py /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/tolua/cocos2dx_backend.ini -s cocos2d-backend -t lua -o /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/cocos/scripting/lua-bindings/auto -n lua_cocos2dx_backend_auto
  File "/Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/bindings-generator/generator.py", line 1386
    print "%s will be skipped completely" % (class_name)
SyntaxError: invalid syntax
Generating lua bindings fails.

Here my status

$ python --version
Python 2.7.16

$ python3 --version
Python 3.9.1

$ python3 -m pip install pyyaml
Requirement already satisfied: pyyaml in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (5.4.1)

$ pip install pyyaml
Requirement already satisfied: pyyaml in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (5.4.1)

$ which python

$ which python3

$ echo $PYTHON_BIN

$ ls -ltah /usr/bin/ | grep python
-rwxr-xr-x     1 root   wheel    31K Sep 22 01:29 python3
lrwxr-xr-x     1 root   wheel    75B Oct 20  2019 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x     1 root   wheel    82B Oct 20  2019 python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x     1 root   wheel    76B Oct 20  2019 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x     1 root   wheel    82B Oct 20  2019 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x     1 root   wheel    76B Oct 20  2019 pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x     1 root   wheel    75B Oct 20  2019 python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x     1 root   wheel    75B Oct 20  2019 python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

If you open up genbindings.py, you’ll come across this:

def _check_python_bin_env():
    ''' Checking the environment PYTHON_BIN, which will be used for building

        PYTHON_BIN = os.environ['PYTHON_BIN']
    except Exception:
        print "PYTHON_BIN not defined, use current python."
        PYTHON_BIN = sys.executable

    return PYTHON_BIN

That is most likely the cause of the problem, and if not, it’ll just be something in that file, which I’m sure you can address very quickly.

In case you’re not sure why that is the problem, this is from your last post:

PYTHON_BIN is mapping to Python 3, not Python 2, so it’s trying to run the script with the new Python. The script can only be run in Python 2.

So, the quickest solution is to just undefine PYTHON_BIN for that session, or re-map it to point to Python 2.

Well, I cannot run python 2.7 because it is not on my Mac. I have Catalina, and pretty soon BigSur, and python 2.7 was removed. I only have some variables set but not python.

The older Python language, version 2.7, is being deprecated in macOS 10.15 Catalina and won’t be included in macOS 10.16. The same goes for other UNIX scripting languages.
Catalina without 2.7

Any change to create a ./genbindings3.py that runs with python3?

They’ve deprecated the built-in Python2, which means they’ll no longer ship it with the OS, but nothing prevents users from installing it themselves. The Python releases for Mac OS X are here

Do a net search for “how to install Python 2.7 on Mac OS X” and you’ll get plenty of results, such as these instructions.

1 Like

Sorry, I really wanted to help with my PR. I checked and I cannot reinstall pyhton2.7.
Maybe when the pandemic is over and I have time I might learn LUA and Python, to try to upload a fix for Android and iOS. :cry:

Hi again, I made some progress on my python problem.
Now it is failing because I do not have the module Cheetah as you can see here:

$ ./genbindings.py
PYTHON_BIN not defined, use current python.
generating userconf.ini...
Generating bindings for cocos2dx_backend...
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/bindings-generator/generator.py /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/tolua/cocos2dx_backend.ini -s cocos2d-backend -t lua -o /Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/cocos/scripting/lua-bindings/auto -n lua_cocos2dx_backend_auto
Traceback (most recent call last):
File "/Users/marcela/Documents/source/cocos2dx_mnn/cocos2d-x/tools/bindings-generator/generator.py", line 15, in <module>
from Cheetah.Template import Template
ImportError: No module named Cheetah.Template

My question is, which version of Cheetah goes with python2.7 to run genbindings.py?

To be honest I’ve never heard of Cheetah. @zhangxm do you know?

Try this:
pip install Cheetah3

You will also need PyYAML, and you can try version 5.1:
pip install PyYAML==5.1

More info in this post (it’s a bit outdated, but may help): https://discuss.cocos2d-x.org/t/cocos2d-x-jsb-auto-binding-tool-binding-generator-b-g-tips/10691

1 Like

Can refer to [readme] to install environments.