Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Python 3.7 compatibility #205

Merged
merged 2 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
- PYTHON_VERSION=3.7

cache:
timeout: 300
directories:
- ./miniconda # Conda environment
- ./.eggs # pytest eggs
Expand All @@ -30,16 +31,21 @@ before_install:
- conda -V || bash miniconda.sh -b -p ./miniconda -f
# Update conda
- conda install --yes conda
# Enable conda
- source ./miniconda/etc/profile.d/conda.sh
# Create build environment if it doesn't exist
- source activate buildenv || conda create --yes --name buildenv python=$PYTHON_VERSION
- conda activate buildenv || conda create --yes --name buildenv python=$PYTHON_VERSION
# Activate build environment
- source activate buildenv
- conda activate buildenv
# Pin python version
- echo "python == $PYTHON_VERSION.*" > $CONDA_PREFIX/conda-meta/pinned

install:
# Install build dependencies
- conda install --yes boost gxx_linux-64
- conda install --yes -c tango-controls tango=$TANGO_VERSION
- conda install --yes numpy # Not a strong requirement yet
- conda install --yes gevent # Temporary fix for gevent issue #1260
# Use conda prefix as root for the dependencies
- export BOOST_ROOT=$CONDA_PREFIX TANGO_ROOT=$CONDA_PREFIX ZMQ_ROOT=$CONDA_PREFIX OMNI_ROOT=$CONDA_PREFIX

Expand Down
30 changes: 18 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
# See LICENSE.txt for more info.
# ------------------------------------------------------------------------------

# pylint: disable=deprecated-method

import os
import imp
import sys
import runpy
import struct
import platform
import subprocess

from setuptools import setup, Extension
Expand All @@ -25,6 +26,12 @@
from distutils.unixccompiler import UnixCCompiler
from distutils.version import LooseVersion as V

# Distro import
try:
from pip._vendor import distro
except ImportError:
import platform as distro

# Sphinx imports
try:
import sphinx
Expand All @@ -44,12 +51,12 @@
POSIX = 'posix' in os.name
WINDOWS = 'nt' in os.name
IS64 = 8 * struct.calcsize("P") == 64
PYTHON_VERSION = platform.python_version_tuple()
PYTHON2 = ('2',) <= PYTHON_VERSION < ('3',)
PYTHON3 = ('3',) <= PYTHON_VERSION < ('4',)
PYTHON_VERSION = sys.version_info
PYTHON2 = (2,) <= PYTHON_VERSION < (3,)
PYTHON3 = (3,) <= PYTHON_VERSION < (4,)

# Linux distribution
distribution = platform.linux_distribution()[0].lower() if POSIX else ""
distribution = distro.linux_distribution()[0].lower() if POSIX else ""
distribution_match = lambda names: any(x in distribution for x in names)
DEBIAN = distribution_match(['debian', 'ubuntu', 'mint'])
REDHAT = distribution_match(['redhat', 'fedora', 'centos', 'opensuse'])
Expand Down Expand Up @@ -94,11 +101,10 @@ def abspath(*path):


def get_release_info():
name = "release"
release_dir = abspath('tango')
data = imp.find_module(name, [release_dir])
release = imp.load_module(name, *data)
return release.Release
namespace = runpy.run_path(
abspath('tango/release.py'),
run_name='tango.release')
return namespace['Release']


def uniquify(seq):
Expand Down Expand Up @@ -465,9 +471,9 @@ def setup_args():
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries',
]
Expand Down
5 changes: 1 addition & 4 deletions tango/asyncio_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

__all__ = ("AsyncioExecutor", "get_global_executor", "set_global_executor")

# Asyncio compatibility

ensure_future = getattr(asyncio, 'ensure_future', getattr(asyncio, 'async'))

# Global executor

Expand Down Expand Up @@ -74,7 +71,7 @@ def delegate(self, fn, *args, **kwargs):
"""Return the given operation as an asyncio future."""
callback = functools.partial(fn, *args, **kwargs)
coro = self.loop.run_in_executor(self.subexecutor, callback)
return ensure_future(coro)
return asyncio.ensure_future(coro)

def access(self, accessor, timeout=None):
"""Return a result from an asyncio future."""
Expand Down
2 changes: 1 addition & 1 deletion tango/asyncio_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run_coroutine_threadsafe(coro, loop):

def callback():
try:
_chain_future(asyncio.async(coro, loop=loop), future)
_chain_future(asyncio.ensure_future(coro, loop=loop), future)
except Exception as exc:
if future.set_running_or_notify_cancel():
future.set_exception(exc)
Expand Down
8 changes: 7 additions & 1 deletion tango/gevent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,15 @@ def access(self, accessor, timeout=None):
"""Return a result from an gevent future."""
return accessor.get(timeout=timeout)

def create_watcher(self):
try:
return self.loop.async_()
except AttributeError:
return getattr(self.loop, 'async')()

def submit(self, fn, *args, **kwargs):
task = GeventTask(fn, *args, **kwargs)
watcher = self.loop.async()
watcher = self.create_watcher()
watcher.start(task.spawn)
watcher.send()
task.started.wait()
Expand Down