diff options
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | CHANGES.rst | 10 | ||||
| -rw-r--r-- | LICENSE | 4 | ||||
| -rw-r--r-- | MANIFEST.in | 104 | ||||
| -rw-r--r-- | appveyor.yml | 13 | ||||
| -rw-r--r-- | conftest.py | 18 | ||||
| -rwxr-xr-x | make-manifest | 21 | ||||
| -rwxr-xr-x | make-win-release | 44 | ||||
| -rwxr-xr-x | setup.py | 48 | ||||
| -rw-r--r-- | src/greenlet/__init__.py | 16 | ||||
| -rw-r--r-- | src/greenlet/greenlet.c (renamed from greenlet.c) | 12 | ||||
| -rw-r--r-- | src/greenlet/greenlet.h (renamed from greenlet.h) | 3 | ||||
| -rw-r--r-- | src/greenlet/platform/setup_switch_x64_masm.cmd (renamed from setup_switch_x64_masm.cmd) | 2 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_aarch64_gcc.h (renamed from platform/switch_aarch64_gcc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_alpha_unix.h (renamed from platform/switch_alpha_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_amd64_unix.h (renamed from platform/switch_amd64_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_arm32_gcc.h (renamed from platform/switch_arm32_gcc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_arm32_ios.h (renamed from platform/switch_arm32_ios.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_csky_gcc.h (renamed from platform/switch_csky_gcc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_m68k_gcc.h (renamed from platform/switch_m68k_gcc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_mips_unix.h (renamed from platform/switch_mips_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc64_aix.h (renamed from platform/switch_ppc64_aix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc64_linux.h (renamed from platform/switch_ppc64_linux.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc_aix.h (renamed from platform/switch_ppc_aix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc_linux.h (renamed from platform/switch_ppc_linux.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc_macosx.h (renamed from platform/switch_ppc_macosx.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_ppc_unix.h (renamed from platform/switch_ppc_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_riscv_unix.h (renamed from platform/switch_riscv_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_s390_unix.h (renamed from platform/switch_s390_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_sparc_sun_gcc.h (renamed from platform/switch_sparc_sun_gcc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_x32_unix.h (renamed from platform/switch_x32_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_x64_masm.asm (renamed from platform/switch_x64_masm.asm) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_x64_masm.obj (renamed from platform/switch_x64_masm.obj) | bin | 1078 -> 1078 bytes | |||
| -rw-r--r-- | src/greenlet/platform/switch_x64_msvc.h (renamed from platform/switch_x64_msvc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_x86_msvc.h (renamed from platform/switch_x86_msvc.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/platform/switch_x86_unix.h (renamed from platform/switch_x86_unix.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/slp_platformselect.h (renamed from slp_platformselect.h) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/__init__.py | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/_test_extension.c (renamed from tests/_test_extension.c) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/_test_extension_cpp.cpp (renamed from tests/_test_extension_cpp.cpp) | 4 | ||||
| -rw-r--r-- | src/greenlet/tests/test_contextvars.py (renamed from tests/test_contextvars.py) | 7 | ||||
| -rw-r--r-- | src/greenlet/tests/test_cpp.py (renamed from tests/test_cpp.py) | 5 | ||||
| -rw-r--r-- | src/greenlet/tests/test_extension_interface.py (renamed from tests/test_extension_interface.py) | 5 | ||||
| -rw-r--r-- | src/greenlet/tests/test_gc.py (renamed from tests/test_gc.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_generator.py (renamed from tests/test_generator.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_generator_nested.py (renamed from tests/test_generator_nested.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_greenlet.py (renamed from tests/test_greenlet.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_leaks.py (renamed from tests/test_leaks.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_stack_saved.py (renamed from tests/test_stack_saved.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_throw.py (renamed from tests/test_throw.py) | 0 | ||||
| -rw-r--r-- | src/greenlet/tests/test_tracing.py (renamed from tests/test_tracing.py) | 0 | ||||
| -rwxr-xr-x | src/greenlet/tests/test_version.py | 49 | ||||
| -rw-r--r-- | src/greenlet/tests/test_weakref.py (renamed from tests/test_weakref.py) | 0 | ||||
| -rw-r--r-- | tests/__init__.py | 14 | ||||
| -rwxr-xr-x | tests/test_version.py | 20 | ||||
| -rw-r--r-- | tox.ini | 2 |
56 files changed, 185 insertions, 218 deletions
diff --git a/.travis.yml b/.travis.yml index fc5e3c1..78b4549 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ python: install: pip install -U -e .[test] -script: python run-tests.py +script: python -m unittest discover -v greenlet.tests diff --git a/CHANGES.rst b/CHANGES.rst index 835d9f4..a6bd00d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,16 @@ sdists. PyPI has standardized on .tar.gz for all platforms. - (Packaging) Stop using a custom distutils command to build extensions. distutils is deprecated. +- (Packaging) Remove the ability to use the deprecated command + ``python setup.py test``. Run greenlet tests with your favorite + unittest-compatible test runner, e.g., ``python -m unittest discover + greenlet.tests``. See `issue 185 <https://github.com/python-greenlet/greenlet/issues/185>`_. +- (Packaging) The directory layout and resulting sdists have changed. + See `issue 184 + <https://github.com/python-greenlet/greenlet/issues/184>`_. +- The ``greenlet`` module is now a package. There are no API changes, + so all existing imports, including from C code, should continue to + work. - (Documentation) Publish the change log to https://greenlet.readthedocs.io - Drop support for Python 2.4, 2.5, 2.6, 3.0, 3.1, 3.2 and 3.4. The project metadata now includes the ``python_requires`` data to @@ -1,8 +1,8 @@ The following files are derived from Stackless Python and are subject to the same license as Stackless Python: - slp_platformselect.h - files in platform/ directory + src/greenlet/slp_platformselect.h + files in src/greenlet/platform/ directory See LICENSE.PSF and http://www.stackless.com/ for details. diff --git a/MANIFEST.in b/MANIFEST.in index 7acc777..21f02e8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,70 +1,48 @@ -include .travis.yml -include .readthedocs.yml +### +# Source code +### +recursive-include src *.py +recursive-include src *.c +recursive-include src *.cpp +recursive-include src *.h +recursive-include src *.cmd +recursive-include src *.asm +recursive-include src *.obj +recursive-include benchmarks * + +### +# Documentation +### +recursive-include docs * +prune docs/_build + +### +# Configuration and project files +### + +include *.yml +include *.txt +include *.ini +include *.rst +include *.cfg +include *.py +include *.ini + +recursive-include appveyor *.cmd +recursive-include appveyor *.ps1 +recursive-include appveyor *.py + include AUTHORS include LICENSE include LICENSE.PSF include MANIFEST.in -include CHANGES.rst -include README.rst -include appveyor.yml -include appveyor/run_pip.py -include appveyor/run_with_env.cmd -include benchmarks/chain.py -include conftest.py -include dev-requirements.txt -include docs/Makefile -include docs/conf.py -include docs/greenlet.rst -include docs/index.rst -include docs/changes.rst -include docs/make.bat -include greenlet.c -include greenlet.h + +### XXX: Move these to a subdirectory. include make-manylinux include make-manifest include make-win-release -include my_build_ext.py -include platform/switch_aarch64_gcc.h -include platform/switch_alpha_unix.h -include platform/switch_amd64_unix.h -include platform/switch_arm32_gcc.h -include platform/switch_arm32_ios.h -include platform/switch_csky_gcc.h -include platform/switch_m68k_gcc.h -include platform/switch_mips_unix.h -include platform/switch_ppc64_linux.h -include platform/switch_ppc_aix.h -include platform/switch_ppc_linux.h -include platform/switch_ppc_macosx.h -include platform/switch_ppc_unix.h -include platform/switch_riscv_unix.h -include platform/switch_s390_unix.h -include platform/switch_sparc_sun_gcc.h -include platform/switch_x32_unix.h -include platform/switch_x64_masm.asm -include platform/switch_x64_masm.obj -include platform/switch_x64_msvc.h -include platform/switch_x86_msvc.h -include platform/switch_x86_unix.h -include run-tests.py -include setup.cfg -include setup.py -include setup_switch_x64_masm.cmd -include slp_platformselect.h -include tests/__init__.py -include tests/_test_extension.c -include tests/_test_extension_cpp.cpp -include tests/test_contextvars.py -include tests/test_cpp.py -include tests/test_extension_interface.py -include tests/test_gc.py -include tests/test_generator.py -include tests/test_generator_nested.py -include tests/test_greenlet.py -include tests/test_leaks.py -include tests/test_stack_saved.py -include tests/test_throw.py -include tests/test_tracing.py -include tests/test_version.py -include tests/test_weakref.py -include tox.ini + +global-exclude *.pyc +global-exclude *.pyd +global-exclude *.so +global-exclude .coverage diff --git a/appveyor.yml b/appveyor.yml index 5aae0e3..282ed80 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -101,11 +101,12 @@ install: https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` throw "There are newer queued builds for this pull request, failing early." } - - ECHO "Filesystem root:" - - ps: "ls \"C:/\"" + ## Debugging + # - ECHO "Filesystem root:" + # - ps: "ls \"C:/\"" - - ECHO "Installed SDKs:" - - ps: "if(Test-Path(\"C:/Program Files/Microsoft SDKs/Windows\")) {ls \"C:/Program Files/Microsoft SDKs/Windows\";}" + # - ECHO "Installed SDKs:" + # - ps: "if(Test-Path(\"C:/Program Files/Microsoft SDKs/Windows\")) {ls \"C:/Program Files/Microsoft SDKs/Windows\";}" # Install Python (from the official .msi of http://python.org) and pip when # not already installed. @@ -147,9 +148,9 @@ install: build_script: - "%CMD_IN_ENV% python -m pip install -U -e .[test]" -# XXX: setup.py test is deprecated + test_script: - - "%CMD_IN_ENV% python setup.py test" + - "%CMD_IN_ENV% python -m unittest discover -v greenlet.tests" after_test: - "%CMD_IN_ENV% python setup.py bdist_wheel" diff --git a/conftest.py b/conftest.py deleted file mode 100644 index e3d92a1..0000000 --- a/conftest.py +++ /dev/null @@ -1,18 +0,0 @@ -# configuration file for py.test - -import sys, os -from distutils.spawn import spawn - - -def pytest_configure(config): - os.chdir(os.path.dirname(__file__)) - cmd = [sys.executable, "setup.py", "-q", "build_ext", "-q", "-i"] - spawn(cmd, search_path=0) - - from tests import build_test_extensions - build_test_extensions() - - -def pytest_report_header(config): - import greenlet - return "greenlet %s from %s" % (greenlet.__version__, greenlet.__file__) diff --git a/make-manifest b/make-manifest deleted file mode 100755 index d9a3158..0000000 --- a/make-manifest +++ /dev/null @@ -1,21 +0,0 @@ -#! /usr/bin/env python - -# this file can be used as pre-commit hook with the following command: -# -# ln -sf ../../make-manifest .git/hooks/pre-commit -# - -import os - - -def main(): - files = sorted(set([x.strip() for x in os.popen("git ls-files")]) - - set(("make-manifest", ".gitignore"))) - with open("MANIFEST.in", "w") as f: - for x in files: - f.write("include %s\n" % x) - - os.system("git add MANIFEST.in; git diff --cached MANIFEST.in | cat") - -if __name__ == '__main__': - main() diff --git a/make-win-release b/make-win-release deleted file mode 100755 index ee04485..0000000 --- a/make-win-release +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/env python - -import sys, os, subprocess, re - -common_dist = ("bdist_wheel", "bdist_egg", "test") -pyver2dist = { - "Python27": common_dist, - "Python27x64": common_dist, - "Python35": common_dist, - "Python35x64": common_dist, -} - - -def system(cmd): - sys.stdout.write("====> Running %s\n" % cmd) - - popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) - nl = True - while 1: - char = popen.stdout.read(1) - if not char: - break - if nl: - sys.stdout.write(" ") - sys.stdout.write(char) - sys.stdout.flush() - nl = char == "\n" - - st = popen.wait() - if st != 0: - sys.exit("Error: command %r failed" % cmd) - sys.stdout.write("\n") - - -def main(): - here = os.path.dirname(os.path.dirname(sys.executable)) - for pyver, dists in sorted(pyver2dist.items()): - exe = os.path.join(here, pyver, "python.exe") - for d in dists: - cmd = "%s setup.py -q %s" % (exe, d) - system(cmd) - -if __name__ == "__main__": - main() @@ -8,6 +8,7 @@ import platform # distutils is deprecated and vendored into setuptools now. from setuptools import setup from setuptools import Extension +from setuptools import find_packages # workaround segfaults on openbsd and RHEL 3 / CentOS 3 . see # https://bitbucket.org/ambroff/greenlet/issue/11/segfault-on-openbsd-i386 @@ -26,19 +27,28 @@ def readfile(filename): with open(filename, 'r') as f: return f.read() +GREENLET_SRC_DIR = 'src/greenlet/' +GREENLET_HEADER_DIR = GREENLET_SRC_DIR +GREENLET_HEADER = GREENLET_HEADER_DIR + 'greenlet.h' +GREENLET_TEST_DIR = 'src/greenlet/tests/' +# The location of the platform specific assembly files +# for switching. +GREENLET_PLATFORM_DIR = GREENLET_SRC_DIR + 'platform/' + def _find_platform_headers(): - return glob.glob("platform/switch_*.h") + return glob.glob(GREENLET_PLATFORM_DIR + "switch_*.h") if hasattr(sys, "pypy_version_info"): ext_modules = [] headers = [] else: - headers = ['greenlet.h'] + + headers = [GREENLET_HEADER] if sys.platform == 'win32' and '64 bit' in sys.version: # this works when building with msvc, not with 64 bit gcc # switch_x64_masm.obj can be created with setup_switch_x64_masm.cmd - extra_objects = ['platform/switch_x64_masm.obj'] + extra_objects = [GREENLET_PLATFORM_DIR + 'switch_x64_masm.obj'] else: extra_objects = [] @@ -51,11 +61,14 @@ else: ext_modules = [ Extension( - name='greenlet', - sources=['greenlet.c'], + name='greenlet._greenlet', + sources=[GREENLET_SRC_DIR + 'greenlet.c'], extra_objects=extra_objects, extra_compile_args=extra_compile_args, - depends=['greenlet.h', 'slp_platformselect.h'] + _find_platform_headers() + depends=[ + GREENLET_HEADER, + GREENLET_SRC_DIR + 'slp_platformselect.h', + ] + _find_platform_headers() ), # Test extensions. # XXX: We used to try hard to not include these in built @@ -63,19 +76,19 @@ else: # layout with the test directory nested inside a greenlet directory. # See https://github.com/python-greenlet/greenlet/issues/184 and 189 Extension( - '_test_extension', - [os.path.join('tests', '_test_extension.c')], - include_dirs=[os.path.curdir] + name='greenlet.tests._test_extension', + sources=[GREENLET_TEST_DIR + '_test_extension.c'], + include_dirs=[GREENLET_HEADER_DIR] ), ] if os.environ.get('GREENLET_TEST_CPP', 'yes').lower() not in ('0', 'no', 'false'): ext_modules.append( Extension( - '_test_extension_cpp', - [os.path.join('tests', '_test_extension_cpp.cpp')], + name='greenlet.tests._test_extension_cpp', + sources=[GREENLET_TEST_DIR + '_test_extension_cpp.cpp'], language="c++", - include_dirs=[os.path.curdir]), + include_dirs=[GREENLET_HEADER_DIR]), ) setup( @@ -83,7 +96,7 @@ setup( version='1.0.0.dev0', description='Lightweight in-process concurrent programming', long_description=readfile("README.rst"), - url="https://github.com/python-greenlet/greenlet", + url="https://greenlet.readthedocs.io/", project_urls={ 'Bug Tracker': 'https://github.com/python-greenlet/greenlet/issues', 'Source Code': 'https://github.com/python-greenlet/gevent/', @@ -91,6 +104,9 @@ setup( }, license="MIT License", platforms=['any'], + package_dir={'': 'src'}, + packages=find_packages('src'), + include_package_data=True, headers=headers, ext_modules=ext_modules, classifiers=[ @@ -113,10 +129,10 @@ setup( extras_require={ 'docs': [ 'Sphinx', - ] + ], + 'test': [ + ], }, python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*", - # XXX: This is deprecated. appveyor.yml still uses it though. - test_suite='tests.test_collector', zip_safe=False, ) diff --git a/src/greenlet/__init__.py b/src/greenlet/__init__.py new file mode 100644 index 0000000..7e9142f --- /dev/null +++ b/src/greenlet/__init__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +""" +The root of the greenlet package. +""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +# TODO: Define a correct __all__ +# pylint:disable=unused-import +# TODO: Move the definition of __version__ here, instead of the +# C code. zest.releaser will find it here, but not in C. + +from ._greenlet import * # pylint:disable=wildcard-import +from ._greenlet import __version__ +from ._greenlet import _C_API # pylint:disable=no-name-in-module diff --git a/greenlet.c b/src/greenlet/greenlet.c index aad4ba0..895931d 100644 --- a/greenlet.c +++ b/src/greenlet/greenlet.c @@ -1725,19 +1725,19 @@ static char* copy_on_greentype[] = { static struct PyModuleDef greenlet_module_def = { PyModuleDef_HEAD_INIT, - "greenlet", + "greenlet._greenlet", NULL, -1, GreenMethods, }; PyMODINIT_FUNC -PyInit_greenlet(void) +PyInit__greenlet(void) #else #define INITERROR return PyMODINIT_FUNC -initgreenlet(void) +init_greenlet(void) #endif { PyObject* m = NULL; @@ -1750,7 +1750,7 @@ initgreenlet(void) #if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&greenlet_module_def); #else - m = Py_InitModule("greenlet", GreenMethods); + m = Py_InitModule("greenlet._greenlet", GreenMethods); #endif if (m == NULL) { @@ -1855,6 +1855,10 @@ initgreenlet(void) _PyGreenlet_API[PyGreenlet_SetParent_NUM] = (void *) PyGreenlet_SetParent; + /* XXX: Note that our module name is ``greenlet._greenlet``, but for + backwards compatibility with existing C code, we need the _C_API to + be directly in greenlet. + */ c_api_object = PyCapsule_New((void *) _PyGreenlet_API, "greenlet._C_API", NULL); if (c_api_object != NULL) { diff --git a/greenlet.h b/src/greenlet/greenlet.h index b63f07b..68fc035 100644 --- a/greenlet.h +++ b/src/greenlet/greenlet.h @@ -134,6 +134,9 @@ static void **_PyGreenlet_API = NULL; _PyGreenlet_API[PyGreenlet_SetParent_NUM]) /* Macro that imports greenlet and initializes C API */ +/* NOTE: This has actually moved to ``greenlet._greenlet._C_API``, but we + keep the older definition to be sure older code that might have a copy of + the header still works. */ #define PyGreenlet_Import() \ { \ _PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \ diff --git a/setup_switch_x64_masm.cmd b/src/greenlet/platform/setup_switch_x64_masm.cmd index a7f1fc9..0928595 100644 --- a/setup_switch_x64_masm.cmd +++ b/src/greenlet/platform/setup_switch_x64_masm.cmd @@ -1,2 +1,2 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" amd64
-ml64 /nologo /c /Fo platform\switch_x64_masm.obj platform\switch_x64_masm.asm
+ml64 /nologo /c /Fo switch_x64_masm.obj switch_x64_masm.asm
diff --git a/platform/switch_aarch64_gcc.h b/src/greenlet/platform/switch_aarch64_gcc.h index 0b9d556..0b9d556 100644 --- a/platform/switch_aarch64_gcc.h +++ b/src/greenlet/platform/switch_aarch64_gcc.h diff --git a/platform/switch_alpha_unix.h b/src/greenlet/platform/switch_alpha_unix.h index 216619f..216619f 100644 --- a/platform/switch_alpha_unix.h +++ b/src/greenlet/platform/switch_alpha_unix.h diff --git a/platform/switch_amd64_unix.h b/src/greenlet/platform/switch_amd64_unix.h index 16b99b7..16b99b7 100644 --- a/platform/switch_amd64_unix.h +++ b/src/greenlet/platform/switch_amd64_unix.h diff --git a/platform/switch_arm32_gcc.h b/src/greenlet/platform/switch_arm32_gcc.h index 035d6b9..035d6b9 100644 --- a/platform/switch_arm32_gcc.h +++ b/src/greenlet/platform/switch_arm32_gcc.h diff --git a/platform/switch_arm32_ios.h b/src/greenlet/platform/switch_arm32_ios.h index e993707..e993707 100644 --- a/platform/switch_arm32_ios.h +++ b/src/greenlet/platform/switch_arm32_ios.h diff --git a/platform/switch_csky_gcc.h b/src/greenlet/platform/switch_csky_gcc.h index 7486b94..7486b94 100644 --- a/platform/switch_csky_gcc.h +++ b/src/greenlet/platform/switch_csky_gcc.h diff --git a/platform/switch_m68k_gcc.h b/src/greenlet/platform/switch_m68k_gcc.h index da761c2..da761c2 100644 --- a/platform/switch_m68k_gcc.h +++ b/src/greenlet/platform/switch_m68k_gcc.h diff --git a/platform/switch_mips_unix.h b/src/greenlet/platform/switch_mips_unix.h index 1916b26..1916b26 100644 --- a/platform/switch_mips_unix.h +++ b/src/greenlet/platform/switch_mips_unix.h diff --git a/platform/switch_ppc64_aix.h b/src/greenlet/platform/switch_ppc64_aix.h index e07b8de..e07b8de 100644 --- a/platform/switch_ppc64_aix.h +++ b/src/greenlet/platform/switch_ppc64_aix.h diff --git a/platform/switch_ppc64_linux.h b/src/greenlet/platform/switch_ppc64_linux.h index 88e6847..88e6847 100644 --- a/platform/switch_ppc64_linux.h +++ b/src/greenlet/platform/switch_ppc64_linux.h diff --git a/platform/switch_ppc_aix.h b/src/greenlet/platform/switch_ppc_aix.h index c7d476f..c7d476f 100644 --- a/platform/switch_ppc_aix.h +++ b/src/greenlet/platform/switch_ppc_aix.h diff --git a/platform/switch_ppc_linux.h b/src/greenlet/platform/switch_ppc_linux.h index 0a71255..0a71255 100644 --- a/platform/switch_ppc_linux.h +++ b/src/greenlet/platform/switch_ppc_linux.h diff --git a/platform/switch_ppc_macosx.h b/src/greenlet/platform/switch_ppc_macosx.h index 56e573f..56e573f 100644 --- a/platform/switch_ppc_macosx.h +++ b/src/greenlet/platform/switch_ppc_macosx.h diff --git a/platform/switch_ppc_unix.h b/src/greenlet/platform/switch_ppc_unix.h index 2b3d307..2b3d307 100644 --- a/platform/switch_ppc_unix.h +++ b/src/greenlet/platform/switch_ppc_unix.h diff --git a/platform/switch_riscv_unix.h b/src/greenlet/platform/switch_riscv_unix.h index 5b5ea98..5b5ea98 100644 --- a/platform/switch_riscv_unix.h +++ b/src/greenlet/platform/switch_riscv_unix.h diff --git a/platform/switch_s390_unix.h b/src/greenlet/platform/switch_s390_unix.h index 6641854..6641854 100644 --- a/platform/switch_s390_unix.h +++ b/src/greenlet/platform/switch_s390_unix.h diff --git a/platform/switch_sparc_sun_gcc.h b/src/greenlet/platform/switch_sparc_sun_gcc.h index 652b57f..652b57f 100644 --- a/platform/switch_sparc_sun_gcc.h +++ b/src/greenlet/platform/switch_sparc_sun_gcc.h diff --git a/platform/switch_x32_unix.h b/src/greenlet/platform/switch_x32_unix.h index cb14ec1..cb14ec1 100644 --- a/platform/switch_x32_unix.h +++ b/src/greenlet/platform/switch_x32_unix.h diff --git a/platform/switch_x64_masm.asm b/src/greenlet/platform/switch_x64_masm.asm index f5c72a2..f5c72a2 100644 --- a/platform/switch_x64_masm.asm +++ b/src/greenlet/platform/switch_x64_masm.asm diff --git a/platform/switch_x64_masm.obj b/src/greenlet/platform/switch_x64_masm.obj Binary files differindex 64e3e6b..64e3e6b 100644 --- a/platform/switch_x64_masm.obj +++ b/src/greenlet/platform/switch_x64_masm.obj diff --git a/platform/switch_x64_msvc.h b/src/greenlet/platform/switch_x64_msvc.h index 601ea56..601ea56 100644 --- a/platform/switch_x64_msvc.h +++ b/src/greenlet/platform/switch_x64_msvc.h diff --git a/platform/switch_x86_msvc.h b/src/greenlet/platform/switch_x86_msvc.h index 010a22c..010a22c 100644 --- a/platform/switch_x86_msvc.h +++ b/src/greenlet/platform/switch_x86_msvc.h diff --git a/platform/switch_x86_unix.h b/src/greenlet/platform/switch_x86_unix.h index 3a95186..3a95186 100644 --- a/platform/switch_x86_unix.h +++ b/src/greenlet/platform/switch_x86_unix.h diff --git a/slp_platformselect.h b/src/greenlet/slp_platformselect.h index b5e8eb6..b5e8eb6 100644 --- a/slp_platformselect.h +++ b/src/greenlet/slp_platformselect.h diff --git a/src/greenlet/tests/__init__.py b/src/greenlet/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/greenlet/tests/__init__.py diff --git a/tests/_test_extension.c b/src/greenlet/tests/_test_extension.c index ec8b70c..ec8b70c 100644 --- a/tests/_test_extension.c +++ b/src/greenlet/tests/_test_extension.c diff --git a/tests/_test_extension_cpp.cpp b/src/greenlet/tests/_test_extension_cpp.cpp index 3b26571..fc3adad 100644 --- a/tests/_test_extension_cpp.cpp +++ b/src/greenlet/tests/_test_extension_cpp.cpp @@ -74,7 +74,7 @@ static PyMethodDef test_methods[] = { static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, - "_test_extension_cpp", + "greenlet.tests._test_extension_cpp", NULL, 0, test_methods, @@ -97,7 +97,7 @@ init_test_extension_cpp(void) #if PY_MAJOR_VERSION >= 3 module = PyModule_Create(&moduledef); #else - module = Py_InitModule("_test_extension_cpp", test_methods); + module = Py_InitModule("greenlet.tests._test_extension_cpp", test_methods); #endif if (module == NULL) { diff --git a/tests/test_contextvars.py b/src/greenlet/tests/test_contextvars.py index 02873c5..49b7c0d 100644 --- a/tests/test_contextvars.py +++ b/src/greenlet/tests/test_contextvars.py @@ -6,7 +6,7 @@ from functools import partial from greenlet import greenlet from greenlet import getcurrent -from greenlet import GREENLET_USE_CONTEXT_VARS + try: from contextvars import Context @@ -15,7 +15,8 @@ try: except ImportError: Context = ContextVar = copy_context = None -@unittest.skipUnless(GREENLET_USE_CONTEXT_VARS, "ContextVar not supported") +# We don't support testing if greenlet's built-in context var support is disabled. +@unittest.skipUnless(Context is not None, "ContextVar not supported") class ContextVarsTests(unittest.TestCase): def _new_ctx_run(self, *args, **kwargs): return copy_context().run(*args, **kwargs) @@ -249,7 +250,7 @@ class ContextVarsTests(unittest.TestCase): gr.gr_context = ctx self.assertIs(gr.gr_context, ctx) -@unittest.skipIf(GREENLET_USE_CONTEXT_VARS, "ContextVar supported") +@unittest.skipIf(Context is not None, "ContextVar supported") class NoContextVarsTests(unittest.TestCase): def test_contextvars_errors(self): let1 = greenlet(getcurrent().switch) diff --git a/tests/test_cpp.py b/src/greenlet/tests/test_cpp.py index ad1888f..741ea10 100644 --- a/tests/test_cpp.py +++ b/src/greenlet/tests/test_cpp.py @@ -1,7 +1,10 @@ +from __future__ import print_function +from __future__ import absolute_import + import unittest import greenlet -import _test_extension_cpp +from . import _test_extension_cpp class CPPTests(unittest.TestCase): diff --git a/tests/test_extension_interface.py b/src/greenlet/tests/test_extension_interface.py index e7bfbfd..bc87452 100644 --- a/tests/test_extension_interface.py +++ b/src/greenlet/tests/test_extension_interface.py @@ -1,8 +1,11 @@ +from __future__ import print_function +from __future__ import absolute_import + import sys import unittest import greenlet -import _test_extension +from . import _test_extension class CAPITests(unittest.TestCase): diff --git a/tests/test_gc.py b/src/greenlet/tests/test_gc.py index a2a41ca..a2a41ca 100644 --- a/tests/test_gc.py +++ b/src/greenlet/tests/test_gc.py diff --git a/tests/test_generator.py b/src/greenlet/tests/test_generator.py index 62f9f26..62f9f26 100644 --- a/tests/test_generator.py +++ b/src/greenlet/tests/test_generator.py diff --git a/tests/test_generator_nested.py b/src/greenlet/tests/test_generator_nested.py index 6b4f023..6b4f023 100644 --- a/tests/test_generator_nested.py +++ b/src/greenlet/tests/test_generator_nested.py diff --git a/tests/test_greenlet.py b/src/greenlet/tests/test_greenlet.py index 5a3fe10..5a3fe10 100644 --- a/tests/test_greenlet.py +++ b/src/greenlet/tests/test_greenlet.py diff --git a/tests/test_leaks.py b/src/greenlet/tests/test_leaks.py index 2b24ea0..2b24ea0 100644 --- a/tests/test_leaks.py +++ b/src/greenlet/tests/test_leaks.py diff --git a/tests/test_stack_saved.py b/src/greenlet/tests/test_stack_saved.py index 6c7353b..6c7353b 100644 --- a/tests/test_stack_saved.py +++ b/src/greenlet/tests/test_stack_saved.py diff --git a/tests/test_throw.py b/src/greenlet/tests/test_throw.py index a2014a9..a2014a9 100644 --- a/tests/test_throw.py +++ b/src/greenlet/tests/test_throw.py diff --git a/tests/test_tracing.py b/src/greenlet/tests/test_tracing.py index 4f34b15..4f34b15 100644 --- a/tests/test_tracing.py +++ b/src/greenlet/tests/test_tracing.py diff --git a/src/greenlet/tests/test_version.py b/src/greenlet/tests/test_version.py new file mode 100755 index 0000000..f4ea056 --- /dev/null +++ b/src/greenlet/tests/test_version.py @@ -0,0 +1,49 @@ +#! /usr/bin/env python +from __future__ import absolute_import +from __future__ import print_function + +import sys +import os +import re +import unittest + +import greenlet + +class VersionTests(unittest.TestCase): + def test_version(self): + def find_dominating_file(name): + here = os.path.abspath(os.path.dirname(__file__)) + for i in range(10): + up = ['..'] * i + path = [here] + up + [name] + fname = os.path.join(*path) + fname = os.path.abspath(fname) + if os.path.exists(fname): + return fname + raise AssertionError("Could not find file " + name + "; last checked " + fname) + + try: + setup_py = find_dominating_file('setup.py') + except AssertionError as e: + raise unittest.SkipTest("Unable to find setup.py; must be out of tree. " + str(e)) + + try: + greenlet_h = find_dominating_file('greenlet.h') + except AssertionError as e: + if '.tox' in os.path.abspath(os.path.dirname(__file__)): + raise unittest.SkipTest("Unable to find greenlet.h while running in tox") + raise + + with open(greenlet_h) as f: + greenlet_h = f.read() + + hversion, = re.findall('GREENLET_VERSION "(.*)"', greenlet_h) + + + + invoke_setup = "%s %s --version" % (sys.executable, setup_py) + with os.popen(invoke_setup) as f: + sversion = f.read().strip() + + self.assertEqual(sversion, hversion) + self.assertEqual(sversion, greenlet.__version__) diff --git a/tests/test_weakref.py b/src/greenlet/tests/test_weakref.py index 6a2ff06..6a2ff06 100644 --- a/tests/test_weakref.py +++ b/src/greenlet/tests/test_weakref.py diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 3ea15d8..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import glob -import unittest - -def test_collector(): - """Collect all tests under the tests directory and return a - unittest.TestSuite - """ - tests_dir = os.path.realpath(os.path.dirname(__file__)) - test_module_list = [ - 'tests.%s' % os.path.splitext(os.path.basename(t))[0] - for t in glob.glob(os.path.join(tests_dir, 'test_*.py')) - ] - return unittest.TestLoader().loadTestsFromNames(test_module_list) diff --git a/tests/test_version.py b/tests/test_version.py deleted file mode 100755 index 5870e52..0000000 --- a/tests/test_version.py +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env python - -import sys, os, re, unittest, greenlet - -def readclose(f): - try: - return f.read() - finally: - f.close() - -def readfile(filename): - return readclose(open(filename)) - -class VersionTests(unittest.TestCase): - def test_version(self): - upfile = lambda p: os.path.join(os.path.dirname(__file__), "..", p) - hversion, = re.findall('GREENLET_VERSION "(.*)"', readfile(upfile("greenlet.h"))) - sversion = readclose(os.popen("%s %s --version" % (sys.executable, upfile("setup.py")))).strip() - self.assertFalse(sversion != hversion) - self.assertFalse(sversion != greenlet.__version__) @@ -3,7 +3,7 @@ envlist = py27,py35,py36,py37,py38,py39,docs [testenv] -commands=python run-tests.py +commands=python -m unittest discover -v greenlet.tests sitepackages=False |
