diff --git a/.travis.yml b/.travis.yml index 2b62211..d3cda49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,77 +21,13 @@ matrix: include: - env: TOX_ENV=flake8 - - python: 2.7 - env: - - TOX_ENV=py27-tw154 - - - python: 2.7 - env: - - TOX_ENV=py27-tw187 - - - python: 2.7 - env: - - TOX_ENV=py27-twtrunk - - - python: 2.7 - env: - - TOX_ENV=py27-asyncio - - - - python: pypy - env: - - TOX_ENV=pypy-tw154 - - - python: pypy - env: - - TOX_ENV=pypy-tw187 - - - python: pypy - env: - - TOX_ENV=pypy-twtrunk - - - python: pypy - env: - - TOX_ENV=pypy-asyncio - - - - python: pypy3 - env: - - TOX_ENV=pypy3-tw154 - - - python: pypy3 - env: - - TOX_ENV=pypy3-tw187 - - - python: pypy3 - env: - - TOX_ENV=pypy3-twtrunk - - - python: pypy3 - env: - - TOX_ENV=pypy3-asyncio - - - - python: 3.4 - env: - - TOX_ENV=py34-tw154 - - - python: 3.4 - env: - - TOX_ENV=py34-tw187 - - - python: 3.4 - env: - - TOX_ENV=py34-asyncio - - - python: 3.5 env: - - TOX_ENV=py35-tw154 + - TOX_ENV=py35-tw187 - python: 3.5 env: - - TOX_ENV=py35-tw187 + - TOX_ENV=py35-tw1910 - python: 3.5 env: @@ -101,48 +37,53 @@ matrix: env: - TOX_ENV=py35-asyncio + - python: 3.7 + env: + - TOX_ENV=py37-tw187 - - python: 3.6 + - python: 3.7 env: - - TOX_ENV=py36-tw154 + - TOX_ENV=py37-tw1910 - - python: 3.6 + - python: 3.7 env: - - TOX_ENV=py36-tw187 + - TOX_ENV=py37-twtrunk - - python: 3.6 + - python: 3.7 env: - - TOX_ENV=py36-twtrunk + - TOX_ENV=py37-asyncio - - python: 3.6 + - python: 3.8 env: - - TOX_ENV=py36-asyncio + - TOX_ENV=py38-tw187 + - python: 3.8 + env: + - TOX_ENV=py38-tw1910 - - python: 3.7 - dist: xenial - sudo: required + - python: 3.8 env: - - TOX_ENV=py37-tw154 + - TOX_ENV=py38-twtrunk - - python: 3.7 - dist: xenial - sudo: required + - python: 3.8 env: - - TOX_ENV=py37-tw187 + - TOX_ENV=py38-asyncio - - python: 3.7 - dist: xenial - sudo: required + - python: pypy3 env: - - TOX_ENV=py37-twtrunk + - TOX_ENV=pypy3-tw187 - - python: 3.7 - dist: xenial - sudo: required + - python: pypy3 env: - - TOX_ENV=py37-asyncio + - TOX_ENV=pypy3-tw1910 + - python: pypy3 + env: + - TOX_ENV=pypy3-twtrunk + + - python: pypy3 + env: + - TOX_ENV=pypy3-asyncio # https://docs.travis-ci.com/user/build-stages/matrix-expansion/ - stage: deploy python: "3.7" diff --git a/README.rst b/README.rst index 2eab953..4ad808d 100644 --- a/README.rst +++ b/README.rst @@ -22,19 +22,12 @@ either one's event loop to the other using some event loop adapter. Platform support ---------------- -**txaio** runs on CPython 2.7/3.3+ and PyPy 2/3, on top of Twisted or asyncio. Specifically, **txaio** is tested on the following platforms: +**txaio** runs on CPython 3.5+ and PyPy 3, on top of *Twisted* or *asyncio*. Specifically, **txaio** is tested on the following platforms: -**Python 2:** +* CPython 3.5, 3.7 and 3.8 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib) +* PyPy 3 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib) -* CPython 2.7 on Twisted 12.1, 13.2, 15.4, 16.5, trunk and on Trollius 2.0 -* PyPy 2 on Twisted 12.1, 13.2, 15.4, 16.5, trunk and on Trollius 2.0 - -**Python 3:** - -* CPython 3.4 on Twisted 15.4, 16.5, trunk and on asyncio (stdlib) -* CPython 3.5 on Twisted 15.4, 16.5, trunk and on asyncio (stdlib) -* CPython 3.6 on Twisted 15.4, 16.5, trunk and on asyncio (stdlib) -* PyPy 3 on Twisted 15.4, 16.5, trunk and on asyncio (stdlib) +> Note: txaio up to version 18.8.1 also supported Python 2.7 and Python 3.4. Beginning with release v20.1.1, txaio only supports Python 3.5+. How it works diff --git a/docs/releases.rst b/docs/releases.rst index 2c3bc89..cb49126 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -1,15 +1,16 @@ txio releases ============= -master +20.1.1 ------ -- ... - +- IMPORTANT: beginning release v20.1.1, we only support Python 3.5 or later +- new: moved ``time_ns`` and ``perf_counter_ns`` helper functions here 18.8.1 ------ +* IMPORTANT: release v18.8.1 is the last release supporting Python 2. We will support Python 3.5 and later beginning with release v20.1.1. - add API to support cancellation; this means passing a 1-argument callable to ``create_future`` and ``txaio.cancel`` to actually cancel a future diff --git a/setup.py b/setup.py index 547fdb2..b7bf184 100644 --- a/setup.py +++ b/setup.py @@ -48,23 +48,9 @@ 'twisted>=12.1.0', # MIT ] -# asyncio dependencies +# asyncio dependencies: Python 3.5+ has asyncio builtin # -if PY3: - if PY33: - # "Tulip" - extras_require_asyncio = [ - "asyncio>=3.4.3" # Apache 2.0 - ] - else: - # Python 3.4+ has asyncio builtin - extras_require_asyncio = [] -else: - # backport of asyncio for Python 2 - extras_require_asyncio = [ - "trollius>=2.0", # Apache 2.0 - "futures>=3.0.3" # BSD license - ] +extras_require_asyncio = [] # development dependencies # @@ -97,6 +83,7 @@ author_email='autobahnws@googlegroups.com', url='https://github.com/crossbario/txaio', platforms=('Any'), + python_requires='>=3.5', install_requires=[ 'six' ], @@ -129,14 +116,11 @@ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", diff --git a/txaio/util.py b/test/test_util.py similarity index 81% rename from txaio/util.py rename to test/test_util.py index ea53bc2..5a72596 100644 --- a/txaio/util.py +++ b/test/test_util.py @@ -24,17 +24,14 @@ # ############################################################################### -import sys -import time +import txaio -def time_ns(): - if sys.version_info >= (3, 7): - return time.time_ns() - return int(time.time() * 1000000000.) +def test_time_ns(framework): + now = txaio.time_ns() + assert now > 0 -def perf_counter_ns(): - if sys.version_info >= (3, 7): - return time.perf_counter_ns() - return int(time.perf_counter() * 1000000000.) +def test_perf_counter_ns(framework): + now = txaio.perf_counter_ns() + assert now > 0 diff --git a/tox.ini b/tox.ini index 1b5e222..8768317 100644 --- a/tox.ini +++ b/tox.ini @@ -3,35 +3,25 @@ envlist = flake8 # CPython - py27-{tw154,tw165,tw187,twtrunk,asyncio} - py34-{tw154,tw165,tw187,asyncio} - py35-{tw154,tw165,tw187,twtrunk,asyncio} - py36-{tw154,tw165,tw187,twtrunk,asyncio} - py37-{tw154,tw165,tw187,twtrunk,asyncio} + py35-{tw187,tw1910,twtrunk,asyncio} + py37-{tw165,tw187,tw1910,twtrunk,asyncio} + py38-{tw165,tw187,tw1910,twtrunk,asyncio} # PyPy - pypy-{tw154,tw165,tw187,twtrunk,asyncio} - pypy3-{tw154,tw165,tw187,twtrunk,asyncio} + pypy3-{tw187,tw1910,twtrunk,asyncio} [testenv] deps = six mock - pytest==4.4.0 - coverage==4.0 + pytest==4.6.9 + coverage==4.5.4 ; twisted dependencies - tw154: twisted==15.4.0 - tw165: twisted==16.5.0 tw187: twisted==18.7.0 + tw1910: twisted==19.10.0 twtrunk: https://github.com/twisted/twisted/archive/trunk.zip - {tw154,tw165,tw187,twtrunk}: pytest-twisted==1.10 - - ; asyncio dependencies - py26-asyncio: trollius>=2.0 - py26-asyncio: ordereddict - py27-asyncio: trollius>=2.0 - pypy-asyncio: trollius>=2.0 + {tw187,tw1910,twtrunk}: pytest-twisted==1.10 changedir=test @@ -44,7 +34,6 @@ commands = # -s: show output immediately # -v: one line per test, instead of one dot - [testenv:flake8] deps = flake8 diff --git a/txaio/__init__.py b/txaio/__init__.py index e4ae68f..41d5c68 100644 --- a/txaio/__init__.py +++ b/txaio/__init__.py @@ -97,6 +97,8 @@ class _Config(object): 'ILogger', # API for logging 'sleep', # little helper for inline sleeping + 'time_ns', # helper: current time (UTC) in ns + 'perf_counter_ns', # helper: current performance counter in ns ) diff --git a/txaio/_unframework.py b/txaio/_unframework.py index 582f07e..7c888b0 100644 --- a/txaio/_unframework.py +++ b/txaio/_unframework.py @@ -79,3 +79,5 @@ def _throw_usage_error(*args, **kw): ILogger = _throw_usage_error sleep = _throw_usage_error +time_ns = _throw_usage_error +perf_counter_ns = _throw_usage_error diff --git a/txaio/_util.py b/txaio/_util.py new file mode 100644 index 0000000..6b6a71b --- /dev/null +++ b/txaio/_util.py @@ -0,0 +1,48 @@ +############################################################################### +# +# The MIT License (MIT) +# +# Copyright (c) Crossbar.io Technologies GmbH +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +############################################################################### + +import sys +import time + + +if sys.version_info >= (3, 7): + + time_ns = time.time_ns + perf_counter_ns = time.perf_counter_ns + +else: + + def time_ns(): + """ + Shim for standard library time.time_ns for Python < 3.7. + """ + return int(time.time() * 1000000000.) + + def perf_counter_ns(): + """ + Shim for standard library time.perf_counter for Python < 3.7. + """ + return int(time.perf_counter() * 1000000000.) diff --git a/txaio/_version.py b/txaio/_version.py index f31bce0..45a9826 100644 --- a/txaio/_version.py +++ b/txaio/_version.py @@ -1 +1 @@ -__version__ = u'18.8.1' +__version__ = u'20.1.1' diff --git a/txaio/aio.py b/txaio/aio.py index 69ec751..f4aeeb9 100644 --- a/txaio/aio.py +++ b/txaio/aio.py @@ -40,6 +40,7 @@ from txaio.interfaces import IFailedFuture, ILogger, log_levels from txaio._iotype import guess_stream_needs_encoding from txaio._common import _BatchedTimer +from txaio import _util from txaio import _Config import six @@ -571,3 +572,5 @@ def sleep(self, delay): add_callbacks = _default_api.add_callbacks gather = _default_api.gather sleep = _default_api.sleep +time_ns = _util.time_ns +perf_counter_ns = _util.perf_counter_ns diff --git a/txaio/tx.py b/txaio/tx.py index ecb3916..3c7323e 100644 --- a/txaio/tx.py +++ b/txaio/tx.py @@ -44,6 +44,7 @@ from txaio._iotype import guess_stream_needs_encoding from txaio import _Config from txaio._common import _BatchedTimer +from txaio import _util import six @@ -587,3 +588,5 @@ def get_global_log_level(): add_callbacks = _default_api.add_callbacks gather = _default_api.gather sleep = _default_api.sleep +time_ns = _util.time_ns +perf_counter_ns = _util.perf_counter_ns