Poperton
Poperton

Reputation: 2236

Android's repo tool fails with python2

My Dockerfile has python3, and I get:

RUN repo init -u https://android.googlesource.com/platform/manifest
 ---> Running in f3adc38c2aac
/usr/bin/env: 'python': No such file or directory

If I install python, I get this error:

Step 6/7 : RUN repo init -u https://android.googlesource.com/platform/manifest
 ---> Running in 9c03e1b95c0f
repo: warning: Python 2 is no longer supported; Please upgrade to Python 3.6+.
Traceback (most recent call last):
  File "/home/project/aosp/.repo/repo/main.py", line 56, in <module>
    from subcmds.version import Version
  File "/home/project/aosp/.repo/repo/subcmds/__init__.py", line 38, in <module>
    ['%s' % name])
  File "/home/project/aosp/.repo/repo/subcmds/upload.py", line 27, in <module>
    from hooks import RepoHook
  File "/home/project/aosp/.repo/repo/hooks.py", line 472
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

Repo is downloaded like this:

RUN mkdir -p /android_tools \
&& curl https://storage.googleapis.com/git-repo-downloads/repo > /android_tools/repo \
&& chmod a+x /android_tools/repo

Upvotes: 3

Views: 3148

Answers (1)

phd
phd

Reputation: 94726

https://storage.googleapis.com/git-repo-downloads/repo requires at least Python 3.6.

To use python3 with that just downloaded repo you need to fix the shebang line:

sed -i '1s/python/python3/' /android_tools/repo

Upvotes: 2

Related Questions