From 5ef9fd977889a3029d2ab0d44efecb2e841c6a72 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Sun, 24 Nov 2019 18:55:12 -0800 Subject: [PATCH 01/25] nanomsg/__init__.py: fix ctype int for _INT_PACKER Signed-off-by: Stephen Arnold --- nanomsg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanomsg/__init__.py b/nanomsg/__init__.py index ab584dc..93eb3f7 100644 --- a/nanomsg/__init__.py +++ b/nanomsg/__init__.py @@ -159,7 +159,7 @@ class Socket(object): """ - _INT_PACKER = _Struct(str('l')) + _INT_PACKER = _Struct(str('i')) class _Endpoint(object): def __init__(self, socket, endpoint_id, address): From 1582adc74a9b4b6dcbbd753d1b75fef9b2b3edde Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 25 Nov 2019 10:01:57 -0800 Subject: [PATCH 02/25] .travis.yml: add version tag to fix manual nanomsg build Signed-off-by: Stephen Arnold --- .travis.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7167a59..1b12029 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: python python: - - "3.2" - - "3.3" - - "3.4" - "2.7" - - "2.6" + - "3.5" + - "3.6" + - "3.7" # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors # Build steps taken from @@ -12,14 +11,14 @@ python: install: - git clone --quiet --depth=100 "https://github.com/nanomsg/nanomsg.git" ~/builds/nanomsg && pushd ~/builds/nanomsg - && mkdir build - && cd build - && cmake .. - && cmake --build . - && ctest -C Debug . - && sudo cmake --build . --target install - && sudo ldconfig - && popd + - export TRAVIS_TAG=$(cat .version) + - git checkout -b "${TRAVIS_TAG}" + - mkdir build && cd build + - cmake .. + - cmake --build . + - ctest -C Debug . + - sudo cmake --build . --target install + - sudo ldconfig && popd # command to run tests, e.g. python setup.py test script: LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib python setup.py test From f3574595cc776152cf7ac396a826cf7d35faec46 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 25 Nov 2019 10:05:39 -0800 Subject: [PATCH 03/25] .travis.yml: add sudo requirement for install Signed-off-by: Stephen Arnold --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1b12029..415a8fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo: required + language: python python: - "2.7" From 95a38170fa77280e0fdd166a8af6df07348bfcf6 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 25 Nov 2019 10:09:37 -0800 Subject: [PATCH 04/25] .travis.yml: add pre-install for cmake and build-essential Signed-off-by: Stephen Arnold --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 415a8fc..8bab5d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,13 @@ python: - "3.6" - "3.7" +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y software-properties-common + - sudo add-apt-repository -y -u ppa:ubuntu-toolchain-r/test + - sudo apt-get -qq update + - sudo apt-get install -y --allow-unauthenticated build-essential cmake + # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors # Build steps taken from # https://github.com/nanomsg/nanomsg#build-it-with-cmake From fec4717ff701f046f8f64f1ef25616bfa2390e0e Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Tue, 3 Dec 2019 15:37:50 -0800 Subject: [PATCH 05/25] .travis.yml: use ppa pkgs for build deps (no building deps from src) Signed-off-by: Stephen Arnold --- .travis.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bab5d5..76598b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,24 +10,14 @@ python: before_install: - sudo apt-get -qq update - sudo apt-get install -y software-properties-common - - sudo add-apt-repository -y -u ppa:ubuntu-toolchain-r/test + - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + - sudo add-apt-repository -y ppa:nerdboy/embedded - sudo apt-get -qq update - - sudo apt-get install -y --allow-unauthenticated build-essential cmake + - sudo apt-get install -y --allow-unauthenticated build-essential # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -# Build steps taken from -# https://github.com/nanomsg/nanomsg#build-it-with-cmake install: - - git clone --quiet --depth=100 "https://github.com/nanomsg/nanomsg.git" ~/builds/nanomsg - && pushd ~/builds/nanomsg - - export TRAVIS_TAG=$(cat .version) - - git checkout -b "${TRAVIS_TAG}" - - mkdir build && cd build - - cmake .. - - cmake --build . - - ctest -C Debug . - - sudo cmake --build . --target install - - sudo ldconfig && popd + - sudo apt-get install libnanomsg-dev # command to run tests, e.g. python setup.py test script: LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib python setup.py test From cf922b5fa4791b4fd929d1641896e9a0315b6f39 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Sat, 11 Jan 2020 20:36:51 -0800 Subject: [PATCH 06/25] pep8/flake8 cleanup and setup.cfg, add tox as test runner, update travis Signed-off-by: Stephen Arnold --- .travis.yml | 16 ++++++++++---- _nanomsg_ctypes/__init__.py | 41 +++++++++++++++++------------------- nanomsg/__init__.py | 18 +++++++--------- nanomsg_wrappers/__init__.py | 7 ++++-- requirements-dev.txt | 4 ++++ setup.cfg | 18 ++++++++++++++++ tests/test_pubsub.py | 2 +- tox.ini | 15 +++++++++++++ 8 files changed, 82 insertions(+), 39 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 setup.cfg create mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index 76598b5..16d48c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,18 +6,26 @@ python: - "3.5" - "3.6" - "3.7" + - "3.8-dev" + - "nightly" + +matrix: + fast_finish: true + allow_failures: + - python: "3.8-dev" + - python: "nightly" before_install: - sudo apt-get -qq update - sudo apt-get install -y software-properties-common - - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:nerdboy/embedded - sudo apt-get -qq update - - sudo apt-get install -y --allow-unauthenticated build-essential + - sudo apt-get install libnanomsg-dev # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - - sudo apt-get install libnanomsg-dev + - pip install tox-travis # command to run tests, e.g. python setup.py test -script: LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib python setup.py test +script: + - tox diff --git a/_nanomsg_ctypes/__init__.py b/_nanomsg_ctypes/__init__.py index 43aefc1..7382778 100644 --- a/_nanomsg_ctypes/__init__.py +++ b/_nanomsg_ctypes/__init__.py @@ -1,8 +1,6 @@ -from __future__ import division, absolute_import, print_function,\ - unicode_literals +from __future__ import division, absolute_import, print_function, unicode_literals import ctypes -import platform import sys if sys.platform in ('win32', 'cygwin'): @@ -19,7 +17,7 @@ def _c_func_wrapper_factory(cdecl_text): def move_pointer_and_strip(type_def, name): if '*' in name: - type_def += ' ' + name[:name.rindex('*')+1] + type_def += ' ' + name[:name.rindex('*') + 1] name = name.rsplit('*', 1)[1] return type_def.strip(), name.strip() @@ -31,35 +29,34 @@ def type_lookup(type_def): 'int': ctypes.c_int, 'int *': ctypes.POINTER(ctypes.c_int), 'void *': ctypes.c_void_p, - 'size_t': ctypes.c_size_t, - 'size_t *': ctypes.POINTER(ctypes.c_size_t), + 'size_t': ctypes.c_size_t, + 'size_t *': ctypes.POINTER(ctypes.c_size_t), 'struct nn_msghdr *': ctypes.c_void_p, 'struct nn_pollfd *': ctypes.c_void_p, } - type_def_without_const = type_def.replace('const ','') + type_def_without_const = type_def.replace('const ', '') if type_def_without_const in types: return types[type_def_without_const] - elif (type_def_without_const.endswith('*') and - type_def_without_const[:-1] in types): + elif (type_def_without_const.endswith('*') and type_def_without_const[:-1] in types): return ctypes.POINTER(types[type_def_without_const[:-1]]) else: raise KeyError(type_def) - return types[type_def.replace('const ','')] + return types[type_def.replace('const ', '')] - a, b = [i.strip() for i in cdecl_text.split('(',1)] - params, _ = b.rsplit(')',1) + a, b = [i.strip() for i in cdecl_text.split('(', 1)] + params, dummy = b.rsplit(')', 1) rtn_type, name = move_pointer_and_strip(*a.rsplit(' ', 1)) param_spec = [] for param in params.split(','): if param != 'void': param_spec.append(move_pointer_and_strip(*param.rsplit(' ', 1))) - func = _functype(type_lookup(rtn_type), - *[type_lookup(type_def) for type_def, _ in param_spec])( - (name, _lib), - tuple((2 if '**' in type_def else 1, name) - for type_def, name in param_spec) - ) + func = ( + _functype(type_lookup(rtn_type), + *[type_lookup(type_def) for type_def, _ in param_spec]) + ((name, _lib), tuple((2 if '**' in type_def else 1, name) + for type_def, name in param_spec))) + func.__name__ = name return func @@ -136,7 +133,7 @@ def create_writable_buffer(size): This is the ctypes implementation. """ - return (ctypes.c_ubyte*size)() + return (ctypes.c_ubyte * size)() def nn_setsockopt(socket, level, option, value): @@ -188,7 +185,7 @@ def nn_send(socket, msg, flags): def _create_message(address, length): class Message(ctypes.Union): - _fields_ = [('_buf', ctypes.c_ubyte*length)] + _fields_ = [('_buf', ctypes.c_ubyte * length)] _len = length _address = address @@ -237,7 +234,7 @@ def nn_poll(fds, timeout=-1): s.revents = 0 polls.append(s) - poll_array = (PollFds*len(fds))(*polls) + poll_array = (PollFds * len(fds))(*polls) res = _nn_poll(poll_array, len(fds), int(timeout)) if res <= 0: return res, {} @@ -276,7 +273,7 @@ def nn_recv(socket, *args): else: _nclib = ctypes.cdll.LoadLibrary('libnanoconfig.so') except OSError: - pass # No nanoconfig, sorry + pass # No nanoconfig, sorry else: # int nc_configure (int s, const char *addr) nc_configure = _functype(ctypes.c_int, ctypes.c_int, ctypes.c_char_p)( diff --git a/nanomsg/__init__.py b/nanomsg/__init__.py index 93eb3f7..5e59586 100644 --- a/nanomsg/__init__.py +++ b/nanomsg/__init__.py @@ -1,8 +1,6 @@ from __future__ import division, absolute_import, print_function, unicode_literals -from .version import __version__ from struct import Struct as _Struct -import warnings from . import wrapper @@ -13,7 +11,7 @@ nanoconfig_started = False -#Import constants into module with NN_ prefix stripped +# Import constants into module with NN_ prefix stripped for name, value in wrapper.nn_symbols(): if name.startswith('NN_'): name = name[3:] @@ -112,7 +110,7 @@ def poll(in_sockets, out_sockets, timeout=-1): # convert to milliseconds or -1 if timeout >= 0: - timeout_ms = int(timeout*1000) + timeout_ms = int(timeout * 1000) else: timeout_ms = -1 res, sockets = wrapper.nn_poll(sockets, timeout_ms) @@ -174,7 +172,7 @@ def address(self): def shutdown(self): self._fdocket._endpoints.remove(self) _nn_check_positive_rtn(wrapper.nn_shutdown(self._fdocket._fd, - self._endpoint_id)) + self._endpoint_id)) def __repr__(self): return '<%s socket %r, id %r, address %r>' % ( @@ -258,8 +256,8 @@ def _set_reconnect_interval_max(self, value): send_fd = property(_get_send_fd, doc='Send file descripter') recv_fd = property(_get_recv_fd, doc='Receive file descripter') - linger = property(_get_linger, _set_linger, doc='Socket linger in ' - 'milliseconds (0.001 seconds)') + linger = property(_get_linger, _set_linger, doc='Socket linger in ' + 'milliseconds (0.001 seconds)') recv_buffer_size = property(_get_recv_buffer_size, _set_recv_buffer_size, doc='Receive buffer size in bytes') send_buffer_size = property(_get_send_buffer_size, _set_send_buffer_size, @@ -298,8 +296,8 @@ def endpoints(self): @property def uses_nanoconfig(self): - return (self._endpoints and - isinstance(self._endpoints[0], Socket.NanoconfigEndpoint)) + return (self._endpoints and isinstance(self._endpoints[0], + Socket.NanoconfigEndpoint)) def bind(self, address): """Add a local endpoint to the socket""" @@ -385,7 +383,7 @@ def get_int_option(self, level, option): ' as size of int (%r)') % (rtn, size)) return Socket._INT_PACKER.unpack_from(buffer(buf))[0] - def get_string_option(self, level, option, max_len=16*1024): + def get_string_option(self, level, option, max_len=16 * 1024): buf = create_writable_buffer(max_len) rtn, length = wrapper.nn_getsockopt(self._fd, level, option, buf) _nn_check_positive_rtn(rtn) diff --git a/nanomsg_wrappers/__init__.py b/nanomsg_wrappers/__init__.py index 1da62f5..33ad56b 100644 --- a/nanomsg_wrappers/__init__.py +++ b/nanomsg_wrappers/__init__.py @@ -7,10 +7,12 @@ _choice = None + def set_wrapper_choice(name): global _choice _choice = name + def load_wrapper(): if _choice is not None: return importlib.import_module('_nanomsg_' + _choice) @@ -22,6 +24,7 @@ def load_wrapper(): "%s, performance may be affected!") % (default,)) return importlib.import_module('_nanomsg_ctypes') + def get_default_for_platform(): if python_implementation() == 'CPython': return 'cpy' @@ -30,5 +33,5 @@ def get_default_for_platform(): def list_wrappers(): - return [module_name.split('_',2)[-1] for _, module_name, _ in - pkgutil.iter_modules() if module_name.startswith('_nanomsg_')] + return [module_name.split('_', 2)[-1] for _, module_name, _ in + pkgutil.iter_modules() if module_name.startswith('_nanomsg_')] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..836e343 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +pytest +pytest-flake8 +pytest-pep8 +pytest-cov diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e4c08b7 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[tool:pytest] +flake8-max-line-length = 109 + +flake8-ignore = + nanomsg/__init__.py F821 + _nanomsg_ctypes/__init__.py F821 + tests/*.py ALL + +markers = + pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/ + +pep8maxlinelength = 109 + +pep8ignore = + tests/* ALL + nanomsg/__init__.py F821 + _nanomsg_ctypes/__init__.py F821 + diff --git a/tests/test_pubsub.py b/tests/test_pubsub.py index 0678b65..bd6ae3c 100644 --- a/tests/test_pubsub.py +++ b/tests/test_pubsub.py @@ -30,7 +30,7 @@ def test_subscribe_works(self): actual = s2.recv() - self.assertEquals(expected, actual) + self.assertEqual(expected, actual) if __name__ == '__main__': unittest.main() diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..fd1a139 --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ +[tox] +envlist = py27, py3{5,6,7,8} +skip_missing_interpreters = true + +[tox:travis] +2.7 = py27 +3.5 = py35 +3.6 = py36 +3.7 = py37 +3.8 = py38 + +[testenv] +deps = -rrequirements-dev.txt +commands = + py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing From cd7c531b5165f2ebea7f28f8b51d4e113520242a Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Sat, 11 Jan 2020 22:19:15 -0800 Subject: [PATCH 07/25] version bump for new package, pick up recent fixes * move version var to setup.py, remove version.py, update coverage cfg Signed-off-by: Stephen Arnold --- nanomsg/version.py | 2 -- setup.cfg | 4 ++-- setup.py | 7 +++++-- tox.ini | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 nanomsg/version.py diff --git a/nanomsg/version.py b/nanomsg/version.py deleted file mode 100644 index 5ac9e42..0000000 --- a/nanomsg/version.py +++ /dev/null @@ -1,2 +0,0 @@ - -__version__ = '1.0' diff --git a/setup.cfg b/setup.cfg index e4c08b7..950d2cc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [tool:pytest] -flake8-max-line-length = 109 +flake8-max-line-length = 95 flake8-ignore = nanomsg/__init__.py F821 @@ -9,7 +9,7 @@ flake8-ignore = markers = pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/ -pep8maxlinelength = 109 +pep8maxlinelength = 95 pep8ignore = tests/* ALL diff --git a/setup.py b/setup.py index 9d31dc1..7b5b808 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,11 @@ from distutils.command.build_ext import build_ext -with open(os.path.join('nanomsg','version.py')) as f: - exec(f.read()) +__version__ = '1.0.2' + +FPND_DOWNLOAD_URL = ( + 'https://github.com/freepn/nanomsg-python/tarball/' + __version__ +) libraries = [str('nanomsg')] diff --git a/tox.ini b/tox.ini index fd1a139..0162ccb 100644 --- a/tox.ini +++ b/tox.ini @@ -12,4 +12,4 @@ skip_missing_interpreters = true [testenv] deps = -rrequirements-dev.txt commands = - py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing + py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg --cov nanomsg_wrappers --cov-report term-missing From aea36321d526577492886e1414c696f173e2dbbc Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Sat, 11 Jan 2020 22:58:39 -0800 Subject: [PATCH 08/25] setup.py: fix missing download url, use correct name Signed-off-by: Stephen Arnold --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 7b5b808..0ed62ca 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,11 @@ from distutils.command.build_ext import build_ext -__version__ = '1.0.2' +NANOMSG_VERSION = '1.0.2-1' +REL_TAG = NANOMSG_VERSION.replace('-', 'p') -FPND_DOWNLOAD_URL = ( - 'https://github.com/freepn/nanomsg-python/tarball/' + __version__ +NANOMSG_DOWNLOAD_URL = ( + 'https://github.com/freepn/nanomsg-python/tarball/' + REL_TAG ) @@ -60,7 +61,7 @@ setup( name='nanomsg', - version=__version__, + version=NANOMSG_VERSION, packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')], ext_modules=[cpy_extension], install_requires=install_requires, @@ -79,6 +80,7 @@ author='Tony Simpson', author_email='agjasimpson@gmail.com', url='https://github.com/tonysimpson/nanomsg-python', + download_url=NANOMSG_DOWNLOAD_URL, keywords=['nanomsg', 'driver'], license='MIT', test_suite="tests", From 438ceb078d79c6025716c51467ee3b80f9d457b9 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Mon, 13 Jan 2020 13:59:41 -0800 Subject: [PATCH 09/25] setup.py: remove nose from install_requires (use pytest or setup.py) Signed-off-by: Stephen Arnold --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 0ed62ca..a8c9732 100644 --- a/setup.py +++ b/setup.py @@ -67,15 +67,15 @@ install_requires=install_requires, description='Python library for nanomsg.', classifiers=[ - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python", "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ], author='Tony Simpson', author_email='agjasimpson@gmail.com', From a66fc23e681e8961d6d124781a15573ffe303bc5 Mon Sep 17 00:00:00 2001 From: Cody Piersall Date: Thu, 7 Jun 2018 13:56:00 -0500 Subject: [PATCH 10/25] Fix bug in error message The error message was showing the return code instead of the length of the returned object. --- nanomsg/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanomsg/__init__.py b/nanomsg/__init__.py index 5e59586..6825162 100644 --- a/nanomsg/__init__.py +++ b/nanomsg/__init__.py @@ -380,7 +380,7 @@ def get_int_option(self, level, option): _nn_check_positive_rtn(rtn) if length != size: raise NanoMsgError(('Returned option size (%r) should be the same' - ' as size of int (%r)') % (rtn, size)) + ' as size of int (%r)') % (length, size)) return Socket._INT_PACKER.unpack_from(buffer(buf))[0] def get_string_option(self, level, option, max_len=16 * 1024): From 8b4702e88e0037e9bfa585f658168a09d5d83b25 Mon Sep 17 00:00:00 2001 From: Stephen Arnold Date: Sat, 11 Jan 2020 20:36:51 -0800 Subject: [PATCH 11/25] pep8/flake8 cleanup and setup.cfg, add tox as test runner, update travis Signed-off-by: Stephen Arnold --- setup.cfg | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 950d2cc..e4c08b7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [tool:pytest] -flake8-max-line-length = 95 +flake8-max-line-length = 109 flake8-ignore = nanomsg/__init__.py F821 @@ -9,7 +9,7 @@ flake8-ignore = markers = pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/ -pep8maxlinelength = 95 +pep8maxlinelength = 109 pep8ignore = tests/* ALL diff --git a/tox.ini b/tox.ini index 0162ccb..fd1a139 100644 --- a/tox.ini +++ b/tox.ini @@ -12,4 +12,4 @@ skip_missing_interpreters = true [testenv] deps = -rrequirements-dev.txt commands = - py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg --cov nanomsg_wrappers --cov-report term-missing + py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing From 465458e38a009f9fa71180b93dfc84bf047dbeab Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 10:42:15 -0800 Subject: [PATCH 12/25] update python versions, remove pep8 from test deps Signed-off-by: Stephen L Arnold --- .travis.yml | 4 ++-- requirements-dev.txt | 1 - setup.cfg | 11 ----------- setup.py | 2 ++ tox.ini | 5 +++-- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16d48c1..8a9a1cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,13 @@ python: - "3.5" - "3.6" - "3.7" - - "3.8-dev" + - "3.8" + - "3.9-dev" - "nightly" matrix: fast_finish: true allow_failures: - - python: "3.8-dev" - python: "nightly" before_install: diff --git a/requirements-dev.txt b/requirements-dev.txt index 836e343..19f6008 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,3 @@ pytest pytest-flake8 -pytest-pep8 pytest-cov diff --git a/setup.cfg b/setup.cfg index e4c08b7..9d06e8a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,14 +5,3 @@ flake8-ignore = nanomsg/__init__.py F821 _nanomsg_ctypes/__init__.py F821 tests/*.py ALL - -markers = - pep8: workaround for https://bitbucket.org/pytest-dev/pytest-pep8/issues/23/ - -pep8maxlinelength = 109 - -pep8ignore = - tests/* ALL - nanomsg/__init__.py F821 - _nanomsg_ctypes/__init__.py F821 - diff --git a/setup.py b/setup.py index a8c9732..0bde63c 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,8 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], author='Tony Simpson', author_email='agjasimpson@gmail.com', diff --git a/tox.ini b/tox.ini index fd1a139..e9367c2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py3{5,6,7,8} +envlist = py27, py3{5,6,7,8,9} skip_missing_interpreters = true [tox:travis] @@ -8,8 +8,9 @@ skip_missing_interpreters = true 3.6 = py36 3.7 = py37 3.8 = py38 +3.9 = py39 [testenv] deps = -rrequirements-dev.txt commands = - py.test tests --flake8 --pep8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing + py.test tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing From 4147a4fc81dd2b33c97081e550d877b6b274cddb Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 11:05:22 -0800 Subject: [PATCH 13/25] migrate CI to github actions - needs libnanomsg-dev and ubuntu-20.04 img Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++++ .travis.yml => travis.yml_disabled | 0 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/ci.yml rename .travis.yml => travis.yml_disabled (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b0da929 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: ci + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + sudo apt-get install -y libnanomsg-dev + pip install -r requirements-dev.txt + - name: Test with pytest + run: | + pytest tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing diff --git a/.travis.yml b/travis.yml_disabled similarity index 100% rename from .travis.yml rename to travis.yml_disabled From fd2e295ef21a54b5448f638e49fcfc324901d2a6 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 11:13:52 -0800 Subject: [PATCH 14/25] install cython and nanomsg-utils Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0da929..73104d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - sudo apt-get install -y libnanomsg-dev + sudo apt-get install -y libnanomsg-dev nanomsg-utils pip install -r requirements-dev.txt - name: Test with pytest run: | From 11029eac9a92514b0df30bbd94b8c398b66859db Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 13:20:50 -0800 Subject: [PATCH 15/25] switch test driver to tox Signed-off-by: Stephen L Arnold --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73104d3..0fa458b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,8 @@ jobs: run: | python -m pip install --upgrade pip sudo apt-get install -y libnanomsg-dev nanomsg-utils - pip install -r requirements-dev.txt - - name: Test with pytest + pip install tox + - name: Test with tox run: | - pytest tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing + tox -e py + # pytest tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing From 11bd73b0aeb22a649dc6339af79453a911eb2d91 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 13:32:11 -0800 Subject: [PATCH 16/25] add github CI status badge Signed-off-by: Stephen L Arnold --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5788325..661bab3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ nanomsg-python ============== +![GitHub CI Workflow Status](https://img.shields.io/github/workflow/status/freepn/nanomsg-python/ci) + Python library for [nanomsg](http://nanomsg.org/) which does not compromise on usability or performance. From 5acd0ca639481a0687c19e89f640622458265a91 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 15:23:38 -0800 Subject: [PATCH 17/25] re-work appveyor cfg, add vcpkg install for nanomsg Signed-off-by: Stephen L Arnold --- appveyor.yml | 98 +++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 54 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6db46c8..1b85249 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,66 +1,56 @@ -# The template for this file was from https://packaging.python.org/appveyor/ +# What Python version is installed where: +# http://www.appveyor.com/docs/installed-software#python +clone_folder: c:\projects\nanomsg-python environment: + global: + PYTHONIOENCODING: utf-8 matrix: - # For Python versions available on Appveyor, see - # http://www.appveyor.com/docs/installed-software#python - - PYTHON: "C:\\Python27" - CMAKE_GENERATOR: "Visual Studio 9 2008" - - PYTHON: "C:\\Python34" - CMAKE_GENERATOR: "Visual Studio 10 2010" - - PYTHON: "C:\\Python35" - CMAKE_GENERATOR: "Visual Studio 14 2015" - PYTHON: "C:\\Python36" - CMAKE_GENERATOR: "Visual Studio 14 2015" - - PYTHON: "C:\\Python27" - CMAKE_GENERATOR: "Visual Studio 9 2008 Win64" - - PYTHON: "C:\\Python34-x64" - CMAKE_GENERATOR: "Visual Studio 10 2010 Win64" - - PYTHON: "C:\\Python35-x64" - CMAKE_GENERATOR: "Visual Studio 14 2015 Win64" + TOX_ENV: "py36" - PYTHON: "C:\\Python36-x64" - CMAKE_GENERATOR: "Visual Studio 14 2015 Win64" + TOX_ENV: "py36" + - PYTHON: "C:\\Python37" + TOX_ENV: "py37" + - PYTHON: "C:\\Python37-x64" + TOX_ENV: "py37" + - PYTHON: "C:\\Python38" + TOX_ENV: "py38" + - PYTHON: "C:\\Python38-x64" + TOX_ENV: "py38" + - PYTHON: "C:\\Python39" + TOX_ENV: "py39" + - PYTHON: "C:\\Python39-x64" + TOX_ENV: "py39" +## Before repo cloning +init: + ## without this, temporary directory could be created in current dir + ## which will make some tests fail. + - mkdir C:\TMP + - set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH% + - set TOX_TESTENV_PASSENV=DISTUTILS_USE_SDK MSSdk INCLUDE LIB + - python -V + +## After repo cloning install: - # We need wheel installed to build wheels - - "%PYTHON%\\python.exe -m pip install wheel" - # Visual Studio 9 2008 does not come with stdint.h, so we'll copy over a - # different version. We only need to do it whenever we're building with - # 2008, but it doesn't hurt to copy it unconditionally. The first copy is to - # build nanomsg, the second is to build the extension. - - ps: cp "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include\\stdint.h" - "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include\\stdint.h" - - ps: cp "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include\\stdint.h" - "C:\\Users\\appveyor\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\include\\stdint.h" - - git clone https://github.com/nanomsg/nanomsg.git nanomsg-src - - pwd - - ps: pushd nanomsg-src - - git checkout 1.0.0 - - ps: mkdir build - - ps: cd build - - cmake -DNN_STATIC_LIB=ON -G"%CMAKE_GENERATOR%" .. - - cmake --build . - - cmake --build . --target install - - ps: cp Debug\nanomsg.lib ..\.. - - ps: popd - - pwd +- cmd: >- + cd c:\projects + vcpkg install nanomsg + cd .. -build_script: - - "%PYTHON%\\python.exe setup.py install" +build: false -test_script: - - "build.cmd %PYTHON%\\python.exe setup.py test" +## Before tests +before_test: + - python -m pip install --upgrade pip wheel + - pip install tox virtualenv codecov -after_test: - # build the wheel. - # build.cmd sets up necessary variables for 64-bit builds - - "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" +## Custom test script +test_script: -artifacts: - # bdist_wheel puts your built wheel in the dist directory - - path: dist\* + ## real tests + - "%PYTHON%/Scripts/tox -e %TOX_ENV%" -#on_success: -# You can use this step to upload your artifacts to a public website. -# See Appveyor's documentation for more details. Or you can simply -# access your wheels from the Appveyor "artifacts" tab for your build. + ## installable + - pip install . From 58912beb2e3b4e4ae2f81526aea05ed0f3180f95 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 15:29:21 -0800 Subject: [PATCH 18/25] set windows build image to Visual Studio 2019 Signed-off-by: Stephen L Arnold --- appveyor.yml | 4 ++++ tox.ini | 1 + 2 files changed, 5 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 1b85249..6ab98d0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,11 @@ # What Python version is installed where: # http://www.appveyor.com/docs/installed-software#python +image: + - Visual Studio 2019 + clone_folder: c:\projects\nanomsg-python + environment: global: PYTHONIOENCODING: utf-8 diff --git a/tox.ini b/tox.ini index e9367c2..fa73dda 100644 --- a/tox.ini +++ b/tox.ini @@ -13,4 +13,5 @@ skip_missing_interpreters = true [testenv] deps = -rrequirements-dev.txt commands = + # pip install . py.test tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing From 7aa14df15970fea1f8d5c04e175bf80ee070362e Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 15:31:51 -0800 Subject: [PATCH 19/25] get rid of the directory change before vcpkg install blah Signed-off-by: Stephen L Arnold --- appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6ab98d0..50531c6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,9 +39,7 @@ init: ## After repo cloning install: - cmd: >- - cd c:\projects vcpkg install nanomsg - cd .. build: false From 3f6f9ccb6e44c987a571b6a6992c92489e758440 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 19:11:34 -0800 Subject: [PATCH 20/25] update vcpkg install, need to find where it puts the libraries Signed-off-by: Stephen L Arnold --- appveyor.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 50531c6..88d44fb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,26 +4,16 @@ image: - Visual Studio 2019 -clone_folder: c:\projects\nanomsg-python - environment: global: PYTHONIOENCODING: utf-8 matrix: - - PYTHON: "C:\\Python36" - TOX_ENV: "py36" - PYTHON: "C:\\Python36-x64" TOX_ENV: "py36" - - PYTHON: "C:\\Python37" - TOX_ENV: "py37" - PYTHON: "C:\\Python37-x64" TOX_ENV: "py37" - - PYTHON: "C:\\Python38" - TOX_ENV: "py38" - PYTHON: "C:\\Python38-x64" TOX_ENV: "py38" - - PYTHON: "C:\\Python39" - TOX_ENV: "py39" - PYTHON: "C:\\Python39-x64" TOX_ENV: "py39" @@ -38,8 +28,10 @@ init: ## After repo cloning install: -- cmd: >- - vcpkg install nanomsg + - cmd: cd c:\tools\vcpkg + - cmd: vcpkg integrate install + - cmd: vcpkg install nanomsg:x64-windows + - cmd: cd "%APPVEYOR_BUILD_FOLDER%" build: false From b8f2f4d47b299342d8ce497907b02fa475241e13 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 19:23:47 -0800 Subject: [PATCH 21/25] update setup.py with more generic "Windows" platform test Signed-off-by: Stephen L Arnold --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0bde63c..e98202a 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ libraries = [str('nanomsg')] # add additional necessary library/include path info if we're on Windows -if sys.platform in ("win32", "cygwin"): +if sys.platform in ("win32", "cygwin") or platform.system() == "Windows": libraries.extend([str('ws2_32'), str('advapi32'), str('mswsock')]) # nanomsg installs to different directory based on architecture arch = platform.architecture()[0] @@ -31,7 +31,7 @@ try: import ctypes - if sys.platform in ('win32', 'cygwin'): + if platform.system() == "Windows": _lib = ctypes.windll.nanoconfig elif sys.platform == 'darwin': _lib = ctypes.cdll.LoadLibrary('libnanoconfig.dylib') From a0c99d2ce1a493d81d23d7803ae32d84df2c7616 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 21:12:31 -0800 Subject: [PATCH 22/25] use setuptools_scm and a basic pyproject.toml to set the version Signed-off-by: Stephen L Arnold --- appveyor.yml => appveyor_yml.disabled | 0 pyproject.toml | 2 ++ setup.cfg | 4 ++++ setup.py | 11 +---------- 4 files changed, 7 insertions(+), 10 deletions(-) rename appveyor.yml => appveyor_yml.disabled (100%) create mode 100644 pyproject.toml diff --git a/appveyor.yml b/appveyor_yml.disabled similarity index 100% rename from appveyor.yml rename to appveyor_yml.disabled diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..508294e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] diff --git a/setup.cfg b/setup.cfg index 9d06e8a..89310bc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,7 @@ +[options] +setup_requires = + setuptools_scm + [tool:pytest] flake8-max-line-length = 109 diff --git a/setup.py b/setup.py index e98202a..967cb9f 100644 --- a/setup.py +++ b/setup.py @@ -8,14 +8,6 @@ from distutils.command.build_ext import build_ext -NANOMSG_VERSION = '1.0.2-1' -REL_TAG = NANOMSG_VERSION.replace('-', 'p') - -NANOMSG_DOWNLOAD_URL = ( - 'https://github.com/freepn/nanomsg-python/tarball/' + REL_TAG -) - - libraries = [str('nanomsg')] # add additional necessary library/include path info if we're on Windows if sys.platform in ("win32", "cygwin") or platform.system() == "Windows": @@ -61,7 +53,6 @@ setup( name='nanomsg', - version=NANOMSG_VERSION, packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')], ext_modules=[cpy_extension], install_requires=install_requires, @@ -82,8 +73,8 @@ author='Tony Simpson', author_email='agjasimpson@gmail.com', url='https://github.com/tonysimpson/nanomsg-python', - download_url=NANOMSG_DOWNLOAD_URL, keywords=['nanomsg', 'driver'], license='MIT', test_suite="tests", + use_scm_version=True, ) From 0e0e172b7467fd540e01013755162248c08d4864 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Wed, 11 Nov 2020 21:25:50 -0800 Subject: [PATCH 23/25] README.md: add note about tested versions Signed-off-by: Stephen L Arnold --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 661bab3..8b05fe0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ nanomsg-python ![GitHub CI Workflow Status](https://img.shields.io/github/workflow/status/freepn/nanomsg-python/ci) +This fork of nanomsg-python is currently tested on Python 2.7 and Python 3.6+ on Linux, Darwin, and Windows (the latter two somewhat theoretical). + Python library for [nanomsg](http://nanomsg.org/) which does not compromise on usability or performance. From f4126565a54f4458b84e13042a481d1e03180f00 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Sun, 15 Nov 2020 11:00:59 -0800 Subject: [PATCH 24/25] replace setuptools_scm with legacy version.py, adjust project files Signed-off-by: Stephen L Arnold --- nanomsg/version.py | 1 + pyproject.toml | 2 +- setup.cfg | 4 ---- setup.py | 6 +++++- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 nanomsg/version.py diff --git a/nanomsg/version.py b/nanomsg/version.py new file mode 100644 index 0000000..b7c92bd --- /dev/null +++ b/nanomsg/version.py @@ -0,0 +1 @@ +__version__ = '1.0.2-3' diff --git a/pyproject.toml b/pyproject.toml index 508294e..ed95be6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] +requires = ["setuptools>=30.3.0", "wheel"] diff --git a/setup.cfg b/setup.cfg index 89310bc..9d06e8a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,3 @@ -[options] -setup_requires = - setuptools_scm - [tool:pytest] flake8-max-line-length = 109 diff --git a/setup.py b/setup.py index 967cb9f..91f4b18 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,10 @@ from distutils.command.build_ext import build_ext +with open(os.path.join('nanomsg','version.py')) as f: + exec(f.read()) + + libraries = [str('nanomsg')] # add additional necessary library/include path info if we're on Windows if sys.platform in ("win32", "cygwin") or platform.system() == "Windows": @@ -53,6 +57,7 @@ setup( name='nanomsg', + version=__version__, packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')], ext_modules=[cpy_extension], install_requires=install_requires, @@ -76,5 +81,4 @@ keywords=['nanomsg', 'driver'], license='MIT', test_suite="tests", - use_scm_version=True, ) From 6b11e177dbd4dc226ab36c1331c5b229238babfc Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Sun, 15 Nov 2020 12:13:21 -0800 Subject: [PATCH 25/25] bump version 1.0.2-3 -> 1.0.2-4 for patch release Signed-off-by: Stephen L Arnold --- nanomsg/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanomsg/version.py b/nanomsg/version.py index b7c92bd..095a760 100644 --- a/nanomsg/version.py +++ b/nanomsg/version.py @@ -1 +1 @@ -__version__ = '1.0.2-3' +__version__ = '1.0.2-4'