From a39c5a45b5318b8b821906ca9b93c695caf2f01f Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 24 Nov 2020 21:30:19 -0800 Subject: [PATCH 1/4] Update documentation to reflect new minimum Python 3.5 requirement --- doc/quickstart.rst | 3 +-- setup.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 680631fd..1056fe57 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -7,12 +7,11 @@ Quickstart Guide Dependencies ------------ -* Python 2.7+ or 3.0+ +* Python 3.5+ * git: https://git-scm.com * GitPython: https://pypi.python.org/pypi/GitPython * semantic_version: https://pypi.python.org/pypi/semantic_version * btest: https://pypi.python.org/pypi/btest -* configparser backport (not needed when using Python 3.5+): https://pypi.python.org/pypi/configparser Note that following the suggested `Installation`_ process via :program:`pip` will automatically install dependencies for you. diff --git a/setup.py b/setup.py index 9d7d1bc2..c82ca20b 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,6 @@ 'License :: OSI Approved :: University of Illinois/NCSA Open Source License', 'Operating System :: POSIX :: Linux', 'Operating System :: MacOS :: MacOS X', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Topic :: System :: Networking :: Monitoring', 'Topic :: Utilities', From 8f18e459162591665e69613ffb77c8b102692fb9 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 24 Nov 2020 21:32:21 -0800 Subject: [PATCH 2/4] Update Python invocations to use explicit `python3` --- Makefile | 4 ++-- zkg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 08085c0b..7300485c 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,8 @@ test: .PHONY: dist dist: - ZKG_PYPI_DIST=yes python setup.py bdist_wheel - ZKG_PYPI_DIST=yes ZKG_PYPI_DIST_LEGACY=yes python setup.py bdist_wheel + ZKG_PYPI_DIST=yes python3 setup.py bdist_wheel + ZKG_PYPI_DIST=yes ZKG_PYPI_DIST_LEGACY=yes python3 setup.py bdist_wheel .PHONY: upload upload: twine-check dist diff --git a/zkg b/zkg index 3d5295d7..3d1c6100 100755 --- a/zkg +++ b/zkg @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function from zeekpkg._util import ( From cff6aab4cf25a84737f03b42b1f82b756eed9cc7 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 24 Nov 2020 21:46:30 -0800 Subject: [PATCH 3/4] Remove Python compatibility logic for versions less than 3.5 --- Makefile | 4 ++-- setup.py | 4 ---- zeekpkg/_util.py | 8 +------- zeekpkg/manager.py | 7 +------ zkg | 24 ++++-------------------- 5 files changed, 8 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 7300485c..0fac8180 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,8 @@ test: .PHONY: dist dist: - ZKG_PYPI_DIST=yes python3 setup.py bdist_wheel - ZKG_PYPI_DIST=yes ZKG_PYPI_DIST_LEGACY=yes python3 setup.py bdist_wheel + python3 setup.py bdist_wheel + ZKG_PYPI_DIST_LEGACY=yes python3 setup.py bdist_wheel .PHONY: upload upload: twine-check dist diff --git a/setup.py b/setup.py index c82ca20b..6b6bb547 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,8 @@ from setuptools import setup -from sys import version_info import os install_requires = ['gitpython', 'semantic_version', 'btest'] -if version_info[0] + version_info[1] / 10 < 3.5 or os.environ.get('ZKG_PYPI_DIST'): - install_requires.append("configparser") - setup( name='bro-pkg' if os.environ.get('ZKG_PYPI_DIST_LEGACY') else 'zkg', version=open('VERSION').read().replace('-', '.dev', 1).strip(), diff --git a/zeekpkg/_util.py b/zeekpkg/_util.py index 4ebcc629..35f39387 100644 --- a/zeekpkg/_util.py +++ b/zeekpkg/_util.py @@ -169,13 +169,7 @@ def std_encoding(stream): return locale.getpreferredencoding() def read_zeek_config_line(stdout): - rval = stdout.readline() - - # Python 2 returned bytes, Python 3 returned unicode - if isinstance(rval, bytes): - rval = rval.decode(std_encoding(sys.stdout)) - - return rval.strip() + return stdout.readline().strip() def get_zeek_version(): diff --git a/zeekpkg/manager.py b/zeekpkg/manager.py index 460ca5be..f9a11cb0 100644 --- a/zeekpkg/manager.py +++ b/zeekpkg/manager.py @@ -22,12 +22,7 @@ except ImportError: from urlparse import urlparse -if ( sys.version_info[0] < 3 or - (sys.version_info[0] == 3 and sys.version_info[1] < 2) ): - from configparser import SafeConfigParser as GoodConfigParser -else: - # SafeConfigParser renamed to ConfigParser in Python >= 3.2 - from configparser import ConfigParser as GoodConfigParser +from configparser import ConfigParser as GoodConfigParser import git import semantic_version as semver diff --git a/zkg b/zkg index 3d1c6100..857b75db 100755 --- a/zkg +++ b/zkg @@ -30,26 +30,13 @@ try: except ImportError as err: import configparser -if ( sys.version_info[0] < 3 or - (sys.version_info[0] == 3 and sys.version_info[1] < 2) ): - from configparser import SafeConfigParser as GoodConfigParser -else: - # SafeConfigParser renamed to ConfigParser in Python >= 3.2 - from configparser import ConfigParser as GoodConfigParser +from configparser import ConfigParser as GoodConfigParser import git import zeekpkg -def get_input(prompt): - if sys.version_info[0] < 3: - prompt_bytes = prompt.encode(std_encoding(sys.stdout)) - return raw_input(prompt_bytes).decode(std_encoding(sys.stdin)) - - return input(prompt) - - def confirmation_prompt(prompt, default_to_yes=True): yes = {'y', 'ye', 'yes'} @@ -58,7 +45,7 @@ def confirmation_prompt(prompt, default_to_yes=True): else: prompt += ' [N/y] ' - choice = get_input(prompt).lower() + choice = input(prompt).lower() if not choice: if default_to_yes: @@ -116,7 +103,7 @@ def prompt_for_user_vars(manager, config, configfile, force, pkg_infos): else: prompt = '{} asks for {} ({}) ? [{}] '.format( name, key, desc, default_value) - response = get_input(prompt) + response = input(prompt) if response: answers[key] = response @@ -1816,10 +1803,7 @@ def _fill_metadata_version(pkginfo_name_metadata_version, info_metadata): def cmd_config(manager, args, config, configfile): if args.config_param == 'all': - if sys.version_info[0] < 3: - from StringIO import StringIO - else: - from io import StringIO + from io import StringIO out = StringIO() config.write(out) From 41e20c0e1eac09f2d72e3b25042b26f3ada1c94a Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 24 Nov 2020 21:52:04 -0800 Subject: [PATCH 4/4] Update pip invocations to use explicit `pip3` --- Makefile | 2 +- doc/developers.rst | 4 ++-- doc/quickstart.rst | 8 ++++---- testing/Makefile | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0fac8180..08844a0c 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ twine-check: echo "Uploading to PyPi requires 'twine' and it's not found in PATH."; \ echo "Install it and/or make sure it is in PATH."; \ echo "E.g. you could use the following command to install it:"; \ - echo "\tpip install twine"; \ + echo "\tpip3 install twine"; \ echo ; \ exit 1; \ } diff --git a/doc/developers.rst b/doc/developers.rst index d6086e41..6b0eecb3 100644 --- a/doc/developers.rst +++ b/doc/developers.rst @@ -48,7 +48,7 @@ To build documentation locally, find the requirements in They can be installed like: - pip install -r requirements.txt + pip3 install -r requirements.txt Local Build/Preview ~~~~~~~~~~~~~~~~~~~ @@ -59,7 +59,7 @@ HTML and man page, respectively. To view the generated HTML output, open :file:`doc/man/zkg.1`. If you have also installed :program:`sphinx-autobuild` (e.g. via -:program:`pip`), there's a :file:`Makefile` target, ``make livehtml``, you can +:program:`pip3`), there's a :file:`Makefile` target, ``make livehtml``, you can use to help preview documentation changes as you edit the reST files. Remote Hosting diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 1056fe57..41e228ba 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -13,7 +13,7 @@ Dependencies * semantic_version: https://pypi.python.org/pypi/semantic_version * btest: https://pypi.python.org/pypi/btest -Note that following the suggested `Installation`_ process via :program:`pip` +Note that following the suggested `Installation`_ process via :program:`pip3` will automatically install dependencies for you. Installation @@ -23,13 +23,13 @@ Using the latest stable release on PyPI_: .. code-block:: console - $ pip install zkg + $ pip3 install zkg Using the latest git development version: .. code-block:: console - $ pip install git+git://github.com/zeek/package-manager@master + $ pip3 install git+git://github.com/zeek/package-manager@master .. note:: @@ -41,7 +41,7 @@ Using the latest git development version: Basic Configuration ------------------- -After installing via :program:`pip`, additional configuration is required. +After installing via :program:`pip3`, additional configuration is required. First, make sure that the :program:`zeek-config` script that gets installed with :program:`zeek` is in your :envvar:`PATH`. Then, as the user you want to run :program:`zkg` with, do: diff --git a/testing/Makefile b/testing/Makefile index d123e0e1..b7cd8415 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -9,7 +9,7 @@ btest-installation-check: echo "btest was not located in PATH."; \ echo "Install it and/or make sure it is in PATH."; \ echo "E.g. you could use the following command to install it:"; \ - echo "\tpip install btest"; \ + echo "\tpip3 install btest"; \ echo ; \ exit 1; \ }