Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ef9fd9
nanomsg/__init__.py: fix ctype int for _INT_PACKER
sarnold Nov 25, 2019
1582adc
.travis.yml: add version tag to fix manual nanomsg build
sarnold Nov 25, 2019
f357459
.travis.yml: add sudo requirement for install
sarnold Nov 25, 2019
95a3817
.travis.yml: add pre-install for cmake and build-essential
sarnold Nov 25, 2019
fec4717
.travis.yml: use ppa pkgs for build deps (no building deps from src)
sarnold Dec 3, 2019
cf922b5
pep8/flake8 cleanup and setup.cfg, add tox as test runner, update travis
sarnold Jan 12, 2020
cd7c531
version bump for new package, pick up recent fixes
sarnold Jan 12, 2020
aea3632
setup.py: fix missing download url, use correct name
sarnold Jan 12, 2020
438ceb0
setup.py: remove nose from install_requires (use pytest or setup.py)
sarnold Jan 13, 2020
a66fc23
Fix bug in error message
codypiersall Jun 7, 2018
9ab4e93
Merge pull request #66 from codypiersall/patch-1
tonysimpson Aug 11, 2020
8b4702e
pep8/flake8 cleanup and setup.cfg, add tox as test runner, update travis
sarnold Jan 12, 2020
465458e
update python versions, remove pep8 from test deps
sarnold Nov 11, 2020
4147a4f
migrate CI to github actions - needs libnanomsg-dev and ubuntu-20.04 img
sarnold Nov 11, 2020
fd2e295
install cython and nanomsg-utils
sarnold Nov 11, 2020
11029ea
switch test driver to tox
sarnold Nov 11, 2020
11bd73b
add github CI status badge
sarnold Nov 11, 2020
705e987
Merge pull request #1 from freepn/new-ci
sarnold Nov 11, 2020
5acd0ca
re-work appveyor cfg, add vcpkg install for nanomsg
sarnold Nov 11, 2020
58912be
set windows build image to Visual Studio 2019
sarnold Nov 11, 2020
7aa14df
get rid of the directory change before vcpkg install blah
sarnold Nov 11, 2020
3f6f9cc
update vcpkg install, need to find where it puts the libraries
sarnold Nov 12, 2020
b8f2f4d
update setup.py with more generic "Windows" platform test
sarnold Nov 12, 2020
a0c99d2
use setuptools_scm and a basic pyproject.toml to set the version
sarnold Nov 12, 2020
ae126fa
Merge pull request #2 from freepn/new-ci
sarnold Nov 12, 2020
0e0e172
README.md: add note about tested versions
sarnold Nov 12, 2020
f412656
replace setuptools_scm with legacy version.py, adjust project files
sarnold Nov 15, 2020
07f4ef2
Merge pull request #3 from freepn/noscm-ver
sarnold Nov 15, 2020
6b11e17
bump version 1.0.2-3 -> 1.0.2-4 for patch release
sarnold Nov 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 nanomsg-utils
pip install tox
- name: Test with tox
run: |
tox -e py
# pytest tests --flake8 nanomsg -v --cov nanomsg nanomsg_wrappers _nanomsg_ctypes --cov-report term-missing
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
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.

Expand Down
41 changes: 19 additions & 22 deletions _nanomsg_ctypes/__init__.py
Original file line number Diff line number Diff line change
@@ -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'):
Expand All @@ -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()

Expand All @@ -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

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

Expand Down Expand Up @@ -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, {}
Expand Down Expand Up @@ -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)(
Expand Down
66 changes: 0 additions & 66 deletions appveyor.yml

This file was deleted.

50 changes: 50 additions & 0 deletions appveyor_yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# What Python version is installed where:
# http://www.appveyor.com/docs/installed-software#python

image:
- Visual Studio 2019

environment:
global:
PYTHONIOENCODING: utf-8
matrix:
- PYTHON: "C:\\Python36-x64"
TOX_ENV: "py36"
- PYTHON: "C:\\Python37-x64"
TOX_ENV: "py37"
- PYTHON: "C:\\Python38-x64"
TOX_ENV: "py38"
- 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:
- cmd: cd c:\tools\vcpkg
- cmd: vcpkg integrate install
- cmd: vcpkg install nanomsg:x64-windows
- cmd: cd "%APPVEYOR_BUILD_FOLDER%"

build: false

## Before tests
before_test:
- python -m pip install --upgrade pip wheel
- pip install tox virtualenv codecov

## Custom test script
test_script:

## real tests
- "%PYTHON%/Scripts/tox -e %TOX_ENV%"

## installable
- pip install .
22 changes: 10 additions & 12 deletions nanomsg/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -159,7 +157,7 @@ class Socket(object):

"""

_INT_PACKER = _Struct(str('l'))
_INT_PACKER = _Struct(str('i'))

class _Endpoint(object):
def __init__(self, socket, endpoint_id, address):
Expand All @@ -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>' % (
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -382,10 +380,10 @@ 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):
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)
Expand Down
3 changes: 1 addition & 2 deletions nanomsg/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

__version__ = '1.0'
__version__ = '1.0.2-4'
Loading