Skip to content
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: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ sudo: false
language: python
os: linux
python:
- 2.7
- 3.4
- 3.5
- 3.6
- &mainstream_python 3.7-dev
- &mainstream_python 2.7
- &pypy pypy
- pypy3.5
install:
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
- pip install tox-travis
Expand Down Expand Up @@ -49,8 +44,7 @@ jobs:
- docker
install:
- *upgrade_python_toolset
script:
- ./tools/run_docker.sh "threaded"
script: []
before_deploy:
- pip install -r build_requirements.txt
- python setup.py bdist_wheel
Expand Down
8 changes: 2 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ Pros:
::

Python 2.7
Python 3.4
Python 3.5
Python 3.6
Python 3.7
PyPy
PyPy3 3.5+
Jyton 2.7

.. note:: Update to version 2.0+ for usage with python 3.4+. This version is for legacy python and no new features are planned.

Decorators:

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
six >=1.10.0
futures>=3.1 ; python_version == "2.7"
typing >= 3.6 ; python_version < "3.8"
124 changes: 3 additions & 121 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,10 @@

import ast
import collections
from distutils.command import build_ext
import distutils.errors
import glob
import os.path
import shutil
import sys

try:
from Cython.Build import cythonize
import gevent
except ImportError:
gevent = cythonize = None

import setuptools

PY3 = sys.version_info[:2] > (2, 7) # type: bool

with open(
os.path.join(
os.path.dirname(__file__),
Expand All @@ -50,81 +37,6 @@
long_description = f.read()


def _extension(modpath):
"""Make setuptools.Extension."""
return setuptools.Extension(modpath, [modpath.replace('.', '/') + '.py'])


requires_optimization = [
_extension('threaded._class_decorator'),
_extension('threaded._base_threaded'),
_extension('threaded._py3_helpers'),
_extension('threaded._threaded3'),
_extension('threaded._base_gthreadpooled'),
_extension('threaded._gthreadpooled3'),
]

if 'win32' != sys.platform:
requires_optimization.append(
_extension('threaded.__init__')
)

ext_modules = cythonize(
requires_optimization,
compiler_directives=dict(
always_allow_keywords=True,
binding=True,
embedsignature=True,
overflowcheck=True,
language_level=3,
)
) if cythonize is not None and PY3 else []


class BuildFailed(Exception):
"""For install clear scripts."""
pass


class AllowFailRepair(build_ext.build_ext):
"""This class allows C extension building to fail and repairs init."""

def run(self):
"""Run."""
try:
build_ext.build_ext.run(self)

# Copy __init__.py back to repair package.
build_dir = os.path.abspath(self.build_lib)
root_dir = os.path.abspath(os.path.join(__file__, '..'))
target_dir = build_dir if not self.inplace else root_dir

src_file = os.path.join('threaded', '__init__.py')

src = os.path.join(root_dir, src_file)
dst = os.path.join(target_dir, src_file)

if src != dst:
shutil.copyfile(src, dst)
except (
distutils.errors.DistutilsPlatformError,
getattr(globals()['__builtins__'], 'FileNotFoundError', OSError)
):
raise BuildFailed()

def build_extension(self, ext):
"""build_extension."""
try:
build_ext.build_ext.build_extension(self, ext)
except (
distutils.errors.CCompilerError,
distutils.errors.DistutilsExecError,
distutils.errors.DistutilsPlatformError,
ValueError
):
raise BuildFailed()


# noinspection PyUnresolvedReferences
def get_simple_vars_from_src(src):
"""Get simple (string/number/boolean and None) assigned values from source.
Expand Down Expand Up @@ -176,8 +88,6 @@ def get_simple_vars_from_src(src):
ast.Str, ast.Num,
ast.List, ast.Set, ast.Dict, ast.Tuple
)
if PY3:
ast_data += (ast.Bytes, ast.NameConstant,)

tree = ast.parse(src)

Expand Down Expand Up @@ -221,11 +131,6 @@ def get_simple_vars_from_src(src):

'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',

'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
Expand All @@ -235,7 +140,6 @@ def get_simple_vars_from_src(src):
'pooling',
'multithreading',
'threading',
'asyncio',
'gevent',
'development',
]
Expand All @@ -255,7 +159,7 @@ def get_simple_vars_from_src(src):
long_description=long_description,
classifiers=classifiers,
keywords=keywords,
python_requires='>=2.7.5,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
python_requires='>=2.7.5,<3.0',
# While setuptools cannot deal with pre-installed incompatible versions,
# setting a lower bound is not harmful - it makes error messages cleaner. DO
# NOT set an upper bound on setuptools, as that will lead to uninstallable
Expand All @@ -266,36 +170,14 @@ def get_simple_vars_from_src(src):
"!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,"
"!=36.2.0",
extras_require={
':python_version == "2.7"': [
'futures>=3.1',
],
'gevent': [
'gevent >= 1.2.2'
],
},
install_requires=required,
package_data={
'threaded': [
os.path.basename(filename)
for filename in glob.glob(os.path.join('threaded', '*.pyi'))
] + [
'py.typed'
],
'threaded': ['py.typed'],
},
)
if PY3 and cythonize is not None:
setup_args['ext_modules'] = ext_modules
setup_args['cmdclass'] = dict(build_ext=AllowFailRepair)

try:
setuptools.setup(**setup_args)
except BuildFailed:
print(
'*' * 80 + '\n'
'* Build Failed!\n'
'* Use clear scripts version.\n'
'*' * 80 + '\n'
)
del setup_args['ext_modules']
del setup_args['cmdclass']
setuptools.setup(**setup_args)
setuptools.setup(**setup_args)
17 changes: 6 additions & 11 deletions test/test_gevent_threadpooled.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@
except ImportError:
gevent = None

import six

import threaded

if six.PY3:
from os import cpu_count
else:
try:
from multiprocessing import cpu_count
except ImportError:
def cpu_count():
"""Fake CPU count."""
return 1
try:
from multiprocessing import cpu_count
except ImportError:
def cpu_count():
"""Fake CPU count."""
return 1


@unittest.skipIf(gevent is None, 'No gevent')
Expand Down
17 changes: 6 additions & 11 deletions test/test_pooled.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
import threading
import unittest

import six

import threaded

if six.PY3:
from os import cpu_count
else:
try:
from multiprocessing import cpu_count
except ImportError:
def cpu_count():
"""Fake CPU count."""
return 1
try:
from multiprocessing import cpu_count
except ImportError:
def cpu_count():
"""Fake CPU count."""
return 1


class TestThreadPooled(unittest.TestCase):
Expand Down
111 changes: 0 additions & 111 deletions test/test_pooled_async.py

This file was deleted.

Loading