Skip to content

Commit

Permalink
Require python3 (emscripten-core#11836)
Browse files Browse the repository at this point in the history
In prep for emscripten 2.0.0 require drop support for python2

Fixes: emscripten-core#7198
  • Loading branch information
sbc100 authored Aug 7, 2020
1 parent c86f67c commit a85b303
Show file tree
Hide file tree
Showing 21 changed files with 12 additions and 136 deletions.
18 changes: 0 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ jobs:
executor: bionic
steps:
- checkout
- run: pip2 install flake8==3.7.8
- run: pip3 install flake8==3.7.8
- run: python2 -m flake8 --show-source --statistics
- run: python3 -m flake8 --show-source --statistics
test-sanity:
executor: bionic
Expand Down Expand Up @@ -362,19 +360,6 @@ jobs:
export PATH="${HOME}/.jsvu:${PATH}"
jsvu --os=default --engines=v8
- build
test-minimal-python2:
environment:
# PTYHON_BIN is used in this file to control which version of python
# we use to run the test runner, and EMSDK_PYTHON is used by emcc and
# other tools to determine which version of python to use internally.
# These can, by design, vary independently.
PYTHON_BIN: "python2"
EMSDK_PYTHON: "python2"
EMCC_ALLOW_PYTHON2: "1"
executor: bionic
steps:
- run-tests:
test_targets: "wasm2.test_hello_world other.test_emcc_size_parsing"
test-wasm0:
executor: bionic
steps:
Expand Down Expand Up @@ -505,9 +490,6 @@ workflows:
- test-sockets-chrome:
requires:
- build-linux
- test-minimal-python2:
requires:
- build-linux
- build-windows
- test-minimal-windows:
requires:
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ See docs/process.md for how version tagging works.

Current Trunk
-------------
- Python2 is no longer supported by Emscripten. Emsdk now includes a bundled
copy of Python3 on both macOS and Windows. This means that only non-emsdk
users and linux users should be effected by this change.

1.40.1: 08/01/2020
------------------
Expand Down
4 changes: 0 additions & 4 deletions em++
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions em-config
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emar
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions embuilder
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emcc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emcmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emranlib
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emrun
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emscons
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
4 changes: 0 additions & 4 deletions emsize
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
9 changes: 3 additions & 6 deletions site/source/docs/getting_started/downloads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ Windows
macOS
+++++

If you use MacOS 10.13.3 or later then you should have a new enough version of Python installed (older versions may not work due to `a GitHub change with SSL <https://github.com/emscripten-core/emscripten/issues/6275>`_). Otherwise you can manually install and use Python 2.7.12 or newer.
If you the Emscripten SDK it includes a bundled version of Python 3. Otherwise
you will need to manually install and use Python 3.5 or newer.

These instructions explain how to install **all** the :ref:`required tools <toolchain-what-you-need>`. You can :ref:`test whether some of these are already installed <toolchain-test-which-dependencies-are-installed>` on the platform and skip those steps.

Expand All @@ -134,8 +135,6 @@ These instructions explain how to install **all** the :ref:`required tools <tool

- Download and install latest CMake from `Kitware CMake downloads <http://www.cmake.org/download/>`_.

.. _getting-started-on-macos-install-python2:

Linux
+++++

Expand All @@ -146,16 +145,14 @@ Linux
::

# Install Python
sudo apt-get install python2.7
sudo apt-get install python3

# Install CMake (optional, only needed for tests and building Binaryen)
sudo apt-get install cmake

# Install Java (optional, only needed for Closure Compiler minification)
sudo apt-get install default-jre

.. note:: You need Python 2.7.12 or newer because older versions may not work due to `a GitHub change with SSL <https://github.com/emscripten-core/emscripten/issues/6275>`_).

.. note:: If you want to use your system's Node.js instead of the emsdk's, it may be ``node`` instead of ``nodejs``, and you can adjust the ``NODE_JS`` attribute of your ``.emscripten`` file to point to it.

- *Git* is not installed automatically. Git is only needed if you want to use tools from one of the development branches **emscripten-incoming** or **emscripten-master**:
Expand Down
53 changes: 2 additions & 51 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,6 @@ def decorated(self):
return decorated


def is_python3_version_supported():
"""Retuns True if the installed python3 version is supported by emscripten.
Note: Emscripten requires python3.5 or above since python3.4 and below do not
support circular dependencies."""
try:
print('is_python3_version_supported')
python3 = shared.which('python3')
print(' python3 =', python3)
output = shared.run_process([python3, '--version'], stdout=PIPE).stdout
print(' output =', output, output.split())
output = output.split()[1]
# ignore final component which can contains non-integers (e.g 'rc1')
version = [int(x) for x in output.split('.')[:2]]
return version >= [3, 5]
except Exception:
# If anything goes wrong (no python3, unexpected output format), then we do
# not support this python3
return False


def encode_leb(number):
# TODO(sbc): handle larger numbers
assert(number < 255)
Expand Down Expand Up @@ -6822,28 +6801,6 @@ def test_dash_s_no_space(self):
err = self.expect_fail([EMCC, path_from_root('tests', 'hello_world.cpp'), '-sEXPORTED_FUNCTIONS=["foo"]'])
self.assertContained('error: undefined exported function: "foo"', err)

def test_python_2_3(self):
# check emcc/em++ can be called by any python
def trim_py_suffix(filename):
"""remove .py from EMCC(=emcc.py)"""
return filename[:-3] if filename.endswith('.py') else filename

def run(python):
if python == 'python3':
has = is_python3_version_supported()
else:
has = shared.which(python) is not None
print(python, has)
if has:
print(' checking emcc.py...')
self.run_process([python, path_from_root('emcc.py'), '--version'], stdout=PIPE)
print(' checking em++.py...')
self.run_process([python, path_from_root('em++.py'), '--version'], stdout=PIPE)

run('python')
run('python2')
run('python3')

def test_zeroinit(self):
create_test_file('src.c', r'''
#include <stdio.h>
Expand Down Expand Up @@ -8500,14 +8457,8 @@ def test_autotools_shared_check(self):
env = os.environ.copy()
env['LC_ALL'] = 'C'
expected = ': supported targets:.* elf'
for python in [PYTHON, 'python', 'python2', 'python3']:
if not shared.which(python):
continue
if python == 'python3' and not is_python3_version_supported():
continue
print(python)
out = self.run_process([python, path_from_root('emcc.py'), '--help'], stdout=PIPE, env=env).stdout
assert re.search(expected, out)
out = self.run_process([EMCC, '--help'], stdout=PIPE, env=env).stdout
assert re.search(expected, out)

def test_ioctl_window_size(self):
self.do_other_test(os.path.join('other', 'ioctl', 'window_size'))
Expand Down
1 change: 0 additions & 1 deletion tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def make_executable(name):
temp_bin = tempfile.mkdtemp()
make_executable('llvm-dis')
make_executable('node')
make_executable('python2')
env['PATH'] = temp_bin + os.pathsep + os.environ['PATH']
output = self.do(command, env=env)
finally:
Expand Down
2 changes: 1 addition & 1 deletion tools/gen_struct_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# coding=utf-8
# Copyright 2013 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
Expand Down
2 changes: 1 addition & 1 deletion tools/maybe_wasm2js.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# Copyright 2019 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
Expand Down
4 changes: 0 additions & 4 deletions tools/run_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ if [ -z "$PYTHON" ]; then
PYTHON=$(which python 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
PYTHON=$(which python2 2> /dev/null)
fi

if [ -z "$PYTHON" ]; then
echo 'unable to find python in $PATH'
exit 1
Expand Down
8 changes: 2 additions & 6 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
import sys
import tempfile

if sys.version_info < (2, 7, 0):
print('emscripten requires python 2.7.0 or above (python 2.7.12 or newer is recommended, older python versions are known to run into SSL related issues, https://github.com/emscripten-core/emscripten/issues/6275)', file=sys.stderr)
sys.exit(1)

if sys.version_info[0] == 3 and sys.version_info < (3, 5):
print('emscripten requires at least python 3.5 (or python 2.7.12 or above)', file=sys.stderr)
if sys.version_info < (3, 5):
print('error: emscripten requires python 3.5 or above', file=sys.stderr)
sys.exit(1)

from .toolchain_profiler import ToolchainProfiler
Expand Down

0 comments on commit a85b303

Please sign in to comment.