Require Python 3, drop Python 2 support

Python 3 is widely available. All major Linux distributions support it.
RHEL is covered via EPEL (which is already required for cmake3). Drop
support for Python 2 in order to reduce maintenance costs. The main
motivation is being able to simplify the tests.

CMake is updated to search for Python >= 3.4 and will fail if
unavailable (generating dissectors.c requires Python, so it is quite an
important piece to have).

The documentation is updated to reflect the Python 3.7 paths used by
Chocolatey. Tested the git-review installation instructions in Windows 7
x64 without a previous Chocolatey installation.

macOS brew now installs Python 3 (its dependencies are already installed
by python@2 for libxml2). The macOS (non-brew variant) is updated to use
the official 64-bit installer to install Python 3.

Change-Id: I80b1e36957f338e0dad1bfcc173b6418682cddba
Reviewed-on: https://code.wireshark.org/review/30192
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2018-10-13 15:56:02 +02:00 committed by Anders Broman
parent 77114b721d
commit e9f7bb5127
15 changed files with 109 additions and 59 deletions

View File

@ -888,8 +888,7 @@ set(GLIB2_MIN_VERSION 2.32.0)
set(GTHREAD2_OPTIONS REQUIRED)
set(GCRYPT_OPTIONS "1.4.2" REQUIRED)
set(Perl_OPTIONS REQUIRED)
set(PythonInterp_FIND_VERSION 2)
set(Python_ADDITIONAL_VERSIONS 3)
set(PythonInterp_OPTIONS "3.4" REQUIRED)
set(YACC_OPTIONS REQUIRED)
if (NOT WIN32)
@ -1670,7 +1669,6 @@ set(LIBEPAN_LIBS
${CARES_LIBRARIES}
${KERBEROS_LIBRARIES}
${LUA_LIBRARIES}
${PYTHON_LIBRARIES}
${GEOIP_LIBRARIES}
${GCRYPT_LIBRARIES}
${GNUTLS_LIBRARIES}

View File

@ -23,7 +23,7 @@ can be found at the following sites:
pkgconfig:
http://pkgconfig.freedesktop.org/releases/
python 2.7 or later, including Python 3:
python 3.4 or later:
https://www.python.org/downloads/source/
If you want to use the Wireshark GUI, install one or both of these toolkits:

View File

@ -3,12 +3,13 @@
# http://public.kitware.com/Bug/view.php?id=13818
if(NOT PYTHON_EXECUTABLE AND WIN32)
foreach(_major_version 3 2)
foreach(_major_version 3)
foreach(_minor_version 7 6 5 4 3 2 1)
if (PYTHON_EXECUTABLE)
break()
endif()
find_program(PYTHON_EXECUTABLE
python3.exe
python.exe
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_major_version}.${_minor_version}\\InstallPath]

View File

@ -5,10 +5,12 @@
# source tree. For external dissectors, set it to the
# absolute path (e.g. "${CMAKE_CURRENT_SOURCE_DIR}").
include(LocatePythonModule)
locate_python_module(asn2wrs REQUIRED PATHS "${CMAKE_SOURCE_DIR}/tools")
function(ASN2WRS)
if(NOT PY_ASN2WRS)
include(LocatePythonModule)
locate_python_module(asn2wrs REQUIRED PATHS "${CMAKE_SOURCE_DIR}/tools")
endif()
if(NOT PROTO_OPT)
set(PROTO_OPT -p ${PROTOCOL_NAME})
elseif(PROTO_OPT STREQUAL "_EMPTY_")

4
debian/control vendored
View File

@ -7,7 +7,7 @@ Build-Depends: lsb-release,
qtbase5-dev, qtbase5-dev-tools, qttools5-dev, qttools5-dev-tools,
qtmultimedia5-dev, libqt5svg5-dev,
libpcap0.8-dev, flex, libz-dev, debhelper (>= 9), po-debconf, libtool,
python (>= 2.6.6-3~), python-ply, libc-ares-dev, xsltproc,
python3, python3-ply, libc-ares-dev, xsltproc,
docbook-xsl (>= 1.64.1.0-0), docbook-xml, libxml2-utils, libpcre3-dev,
libcap2-dev [linux-any] | libcap-dev (>= 2.17) [linux-any],
bison, quilt, libparse-yapp-perl,
@ -84,7 +84,7 @@ Package: wireshark-dev
Architecture: any
Section: devel
Depends: ${misc:Depends}, omniidl (>= 4.0.1-2), libpcap0.8-dev, libtool,
libglib2.0-dev, ${python:Depends}, python-ply, snacc, debhelper,
libglib2.0-dev, ${python3:Depends}, python3-ply, snacc, debhelper,
cdbs, libwireshark-dev, libwiretap-dev
Replaces: ethereal-dev (<< 1.0.0-3)
Conflicts: ethereal-dev (<< 1.0.0-3)

2
debian/rules vendored
View File

@ -23,7 +23,7 @@ endif
VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: \(.*\)-.*/\1/p')
export docdir = /usr/share/doc/wireshark-doc
%:
dh $@ --with python2 --buildsystem cmake --with quilt --parallel
dh $@ --with python3 --buildsystem cmake --with quilt --parallel
override_dh_auto_configure:
dh_auto_configure -- -DBUILD_xxx2deb=ON

View File

@ -1181,7 +1181,7 @@ It is also COOL to work on a great Open Source project such as the case with
To use the idl2wrs to generate Wireshark dissectors, you need the following:
* Python must be installed. See link:http://python.org/[]
* Python must be installed. See link:https://python.org/[]
* `omniidl` from the omniORB package must be available. See link:http://omniorb.sourceforge.net/[]
@ -1321,8 +1321,7 @@ wireshark_gen.py are residing in the current directory. This may need tweaking
if you place these files somewhere else.
If it complains about being unable to find some modules (e.g. tempfile.py), you
may want to check if PYTHONPATH is set correctly. On my Linux box, it is
PYTHONPATH=/usr/lib/python2.4/
may want to check if PYTHONPATH is set correctly.
// End of WSDG Chapter Dissection

View File

@ -209,8 +209,8 @@ PS$>cyg-get docbook-xml45 [...]
==== Install Python
Get the Python 3.5 or 2.7 installer from http://python.org/download/[] and
install Python into the default location (_C:\Python35_ or _C:\Python27_).
Get a Python 3.x installer from https://python.org/download/[] and
install Python into the default location (_C:\Python37_).
Why is this recommended? Cygwins _/usr/bin/python_ is a Cygwin-specific
symbolic link which cannot be run from Windows. The native package is faster
@ -222,13 +222,7 @@ Alternatively you can install Python using Chocolatey:
PS$>choco install -y python3
----
or
----
PS$>choco install -y python2
----
Chocolatey installs Python in _C:\tools\python3_ and _C:\tools\python2_ by default.
Chocolatey installs Python in _C:\Python37_ by default.
[[ChSetupGit]]

View File

@ -166,10 +166,14 @@ To install it from Chocolatey run
+
--
----
# Make sure "Scripts" is in our path
PS$>$env:path += ";C:\tools\python2\Scripts"
PS$>choco install pip
PS$>choco install git-review -source python
# If you have not already, install Python 3 first and then *restart* the shell.
PS$>choco install -y python3
PS$>choco install -y git-review -source python
# Make sure that "git-review" is present in our path (edit the version as needed).
PS$>$userpath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
PS$>$userpath += ";C:\Python37\Scripts"
PS$>[Environment]::SetEnvironmentVariable("Path", $userpath, [EnvironmentVariableTarget]::User)
PS$>RefreshEnv
----
--

View File

@ -73,7 +73,7 @@ path via the `-p` flag:
[source,sh]
----
$ python test.py -p /path/to/wireshark-build/run
$ python3 test.py -p /path/to/wireshark-build/run
----
You can list tests by passing one or more complete or partial names to
@ -82,19 +82,19 @@ You can list tests by passing one or more complete or partial names to
[source,sh]
----
# List all tests
$ python test.py -l
$ python test.py -l all
$ python test.py --list
$ python test.py --list all
$ python3 test.py -l
$ python3 test.py -l all
$ python3 test.py --list
$ python3 test.py --list all
# List only tests containing "dumpcap"
$ python test.py -l dumpcap
$ python3 test.py -l dumpcap
# List all suites
$ python test.py --list-suites
$ python3 test.py --list-suites
# List all suites and cases
$ python test.py --list-cases
$ python3 test.py --list-cases
----
If one of the listing flags is not present, tests are run. If no names or `all` is supplied,
@ -103,14 +103,14 @@ all tests are run. Otherwise tests that match are run.
[source,sh]
----
# Run all tests
$ python test.py
$ python test.py all
$ python3 test.py
$ python3 test.py all
# Only run tests containing "dumpcap"
$ python test.py -l dumpcap
$ python3 test.py -l dumpcap
# Run the "clopts" suite
$ python test.py suite_clopts
$ python3 test.py suite_clopts
----
=== Adding Or Modifying Tests

View File

@ -64,8 +64,8 @@ PS:\>iex ((new-object net.webclient).DownloadString(_https://chocolatey.org/inst
Chocolatey sometimes installs packages in unexpected locations. Python
is a notable example. While it's typically installed in a top-level
directory, e.g. _C:\Python27_ or in %PROGRAMFILES%, e.g. _C:\Program
Files\Python36_, Chocolatey tends to install it under
directory, e.g. _C:\Python37_ or in %PROGRAMFILES%, e.g. _C:\Program
Files\Python37_, Chocolatey tends to install it under
_C:\ProgramData\chocolatey_ or _C:\Tools_. If you want to avoid this
behavior you'll probabaly want to install Python using the packages from
python.org.
@ -677,13 +677,12 @@ Your version string will likely vary.
=== Python
http://python.org/[Python] is an interpreted programming language. It is
used to generate some source files, documenation, and other tasks.
Python 2.5 or later (including Python 3) should work fine and Python 3 is
recommended. It may be required in the future.
https://python.org/[Python] is an interpreted programming language. It is
used to generate some source files, documentation, testing and other tasks.
Python 3.4 and later is required. Python 2.7 is no longer supported.
Python is either included or available as a package on most UNIX-like platforms.
Windows packages and source are available at http://python.org/download/[].
Windows packages and source are available at https://python.org/download/[].
The Cygwin Python package is *not* recommended since _/usr/bin/python_ is
a symbolic link, which causes confusion outside Cygwin.
@ -694,19 +693,12 @@ You can also use Chocolatey to install Python:
PS:\> choco install Python3
----
or
[source,cmd]
----
PS:\> choco install Python2
----
Chocolatey installs Python into _C:\tools\python3_ or _C:\tools\python2_ by
Chocolatey installs Python into _C:\Python37_ by
default. You can verify your Python version by running
[source,sh]
----
$ python --version
$ python3 --version
----
on UNIX-like platforms and

View File

@ -55,7 +55,7 @@ BuildRequires: cmake3 >= 3.5
BuildRequires: cmake >= 3.5
%endif
BuildRequires: gcc
BuildRequires: python
BuildRequires: python3
BuildRequires: perl
BuildRequires: flex
BuildRequires: bison

View File

@ -52,7 +52,7 @@ BASIC_LIST="libglib2.0-dev \
bison \
flex \
make \
python \
python3 \
perl \
libgcrypt-dev"
@ -78,7 +78,7 @@ ADDITIONAL_LIST="libnl-3-dev \
DEBDEPS_LIST="debhelper \
po-debconf \
python-ply \
python3-ply \
docbook-xsl \
docbook-xml \
libxml2-utils \

View File

@ -13,7 +13,7 @@
brew update
#install some libs needed by Wireshark
brew install c-ares glib libgcrypt gnutls lua@5.1 cmake nghttp2 snappy lz4 libxml2 json-glib ninja libmaxminddb doxygen libsmi spandsp
brew install c-ares glib libgcrypt gnutls lua@5.1 cmake python nghttp2 snappy lz4 libxml2 json-glib ninja libmaxminddb doxygen libsmi spandsp
#install Qt5
brew install qt5

View File

@ -178,6 +178,7 @@ if [ "$SPANDSP_VERSION" ]; then
fi
BCG729_VERSION=1.0.2
JSON_GLIB_VERSION=1.2.6
PYTHON3_VERSION=3.7.1
#
# GNU autotools; they're provided with releases up to Snow Leopard, but
@ -1700,11 +1701,65 @@ uninstall_json_glib() {
fi
}
install_python3() {
if [ "$PYTHON3_VERSION" -a ! -f python3-$PYTHON3_VERSION-done ] ; then
echo "Downloading and installing python3:"
[ -f python-$PYTHON3_VERSION-macosx10.9.pkg ] || curl -L -O https://www.python.org/ftp/python/$PYTHON3_VERSION/python-$PYTHON3_VERSION-macosx10.9.pkg || exit 1
$no_build && echo "Skipping installation" && return
sudo installer -target / -pkg python-$PYTHON3_VERSION-macosx10.9.pkg || exit 1
touch python3-$PYTHON3_VERSION-done
fi
}
uninstall_python3() {
# Major version (e.g. "3.7")
local PYTHON_VERSION=${installed_python3_version%.*}
if [ ! -z "$installed_python3_version" ] ; then
echo "Uninstalling python3:"
frameworkdir="/Library/Frameworks/Python.framework/Versions/$PYTHON_VERSION"
sudo rm -rf "$frameworkdir"
sudo rm -rf "/Applications/Python $PYTHON_VERSION"
sudo find /usr/local/bin -maxdepth 1 -lname "*$frameworkdir/bin/*" -delete
# Remove three symlinks and empty directories. Removing directories
# might fail if for some reason multiple versions are installed.
sudo rm /Library/Frameworks/Python.framework/Headers
sudo rm /Library/Frameworks/Python.framework/Python
sudo rm /Library/Frameworks/Python.framework/Resources
sudo rmdir /Library/Frameworks/Python.framework/Versions
sudo rmdir /Library/Frameworks/Python.framework
sudo pkgutil --forget org.python.Python.PythonApplications-$PYTHON_VERSION
sudo pkgutil --forget org.python.Python.PythonDocumentation-$PYTHON_VERSION
sudo pkgutil --forget org.python.Python.PythonFramework-$PYTHON_VERSION
sudo pkgutil --forget org.python.Python.PythonUnixTools-$PYTHON_VERSION
rm python3-$installed_python3_version-done
if [ "$#" -eq 1 -a "$1" = "-r" ] ; then
#
# Get rid of the previously downloaded and unpacked version.
#
rm -f python-$installed_python3_version-macosx10.9.pkg
fi
installed_python3_version=""
fi
}
install_all() {
#
# Check whether the versions we have installed are the versions
# requested; if not, uninstall the installed versions.
#
if [ ! -z "$installed_python3_version" -a \
"$installed_python3_version" != "$PYTHON3_VERSION" ] ; then
echo "Installed python3 version is $installed_python3_version"
if [ -z "$PYTHON3_VERSION" ] ; then
echo "python3 is not requested"
else
echo "Requested python3 version is $PYTHON3_VERSION"
fi
uninstall_python3 -r
fi
if [ ! -z "$installed_json_glib_version" -a \
"$installed_json_glib_version" != "$JSON_GLIB_VERSION" ] ; then
echo "Installed json-glib version is $installed_json_glib_version"
@ -2177,6 +2232,8 @@ install_all() {
install_bcg729
install_json_glib
install_python3
}
uninstall_all() {
@ -2193,6 +2250,8 @@ uninstall_all() {
# We also do a "make distclean", so that we don't have leftovers from
# old configurations.
#
uninstall_python3
uninstall_json_glib
uninstall_bcg729
@ -2400,6 +2459,7 @@ then
installed_spandsp_version=`ls spandsp-*-done 2>/dev/null | sed 's/spandsp-\(.*\)-done/\1/'`
installed_bcg729_version=`ls bcg729-*-done 2>/dev/null | sed 's/bcg729-\(.*\)-done/\1/'`
installed_json_glib_version=`ls json_glib-*-done 2>/dev/null | sed 's/json_glib-\(.*\)-done/\1/'`
installed_python3_version=`ls python3-*-done 2>/dev/null | sed 's/python3-\(.*\)-done/\1/'`
cd $topdir
fi