Skip to content

Commit

Permalink
Merge pull request #208 from python-greenlet/issue184
Browse files Browse the repository at this point in the history
Move to the src/ layout, and make greenlet a package.
  • Loading branch information
jamadden committed Nov 12, 2020
2 parents c80fab9 + 8448b09 commit f1b7da0
Show file tree
Hide file tree
Showing 56 changed files with 185 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ python:

install: pip install -U -e .[test]

script: python run-tests.py
script: python -m unittest discover -v greenlet.tests
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
104 changes: 41 additions & 63 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand Down
18 changes: 0 additions & 18 deletions conftest.py

This file was deleted.

21 changes: 0 additions & 21 deletions make-manifest

This file was deleted.

44 changes: 0 additions & 44 deletions make-win-release

This file was deleted.

48 changes: 32 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# 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
Expand All @@ -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 = []

Expand All @@ -51,46 +61,52 @@ def _find_platform_headers():

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
# distributions. That's really not important, at least not once we have a clean
# 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(
name="greenlet",
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/',
'Documentation': 'https://greenlet.readthedocs.io/',
},
license="MIT License",
platforms=['any'],
package_dir={'': 'src'},
packages=find_packages('src'),
include_package_data=True,
headers=headers,
ext_modules=ext_modules,
classifiers=[
Expand All @@ -113,10 +129,10 @@ def _find_platform_headers():
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,
)
16 changes: 16 additions & 0 deletions src/greenlet/__init__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f1b7da0

Please sign in to comment.