Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/jsiwek/python2-eol'
Browse files Browse the repository at this point in the history
* origin/topic/jsiwek/python2-eol:
  Update pip invocations to use explicit `pip3`
  Remove Python compatibility logic for versions less than 3.5
  Update Python invocations to use explicit `python3`
  Update documentation to reflect new minimum Python 3.5 requirement
  • Loading branch information
0xxon committed Nov 26, 2020
2 parents f0b3954 + 41e20c0 commit fd084d8
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 53 deletions.
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

2.4.2-5 | 2020-11-26 17:38:59 +0000

* Update pip invocations to use explicit `pip3` (Jon Siwek, Corelight)

* Remove Python compatibility logic for versions less than 3.5 (Jon Siwek, Corelight)

* Update Python invocations to use explicit `python3` (Jon Siwek, Corelight)

* Update documentation to reflect new minimum Python 3.5 requirement (Jon Siwek, Corelight)

2.4.2 | 2020-11-10 15:18:54 -0800

* Release 2.4.2.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
python3 setup.py bdist_wheel
ZKG_PYPI_DIST_LEGACY=yes python3 setup.py bdist_wheel

.PHONY: upload
upload: twine-check dist
Expand All @@ -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; \
}
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.2
2.4.2-5
4 changes: 2 additions & 2 deletions doc/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ 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`
Note that following the suggested `Installation`_ process via :program:`pip3`
will automatically install dependencies for you.

Installation
Expand All @@ -24,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::

Expand All @@ -42,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:
Expand Down
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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(),
Expand All @@ -26,7 +22,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',
Expand Down
2 changes: 1 addition & 1 deletion testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
}
2 changes: 1 addition & 1 deletion zeekpkg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import logging

__version__ = "2.4.2"
__version__ = "2.4.2-5"
__all__ = ['manager', 'package', 'source']

LOG = logging.getLogger(__name__)
Expand Down
8 changes: 1 addition & 7 deletions zeekpkg/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 1 addition & 6 deletions zeekpkg/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 5 additions & 21 deletions zkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

from __future__ import print_function
from zeekpkg._util import (
Expand Down Expand Up @@ -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'}

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fd084d8

Please sign in to comment.