Skip to content

Commit

Permalink
Merge branch 'master' into y/cppexc-bad
Browse files Browse the repository at this point in the history
Sync to 2.0 development where the test does not fail, at least on Linux.

* master: (219 commits)
  Another TODO comment [skip ci]
  Back to development: 2.0.0a2
  Preparing release 2.0.0a1
  Update MANIFEST.in to exclude results from benchmarks
  Update CHANGES for python-greenlet#280.
  Bump GHA Python 3.11 from a2 to a4
  Refactor for NULL datastack support
  Restore compatibility with Python 3.11
  Add back missing members
  Fix compatibility macro
  Revert unrelated change
  Fix exc_state usage for Python 3.11
  Add change note for python-greenlet#283. [skip ci]
  Add musllinux wheels
  Specify the python needed.
  Seems to not be running the compiler?
  Guess the language.
  Building like normal failed to find source; try autobuild.
  Try adding CodeQL analysis.
  Add 3.11 to tox.ini and tests.yml
  ...
  • Loading branch information
navytux committed Jan 20, 2022
2 parents a2985f0 + b9fd4b0 commit 5579556
Show file tree
Hide file tree
Showing 51 changed files with 8,974 additions and 2,579 deletions.
100 changes: 95 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
PYTHONUNBUFFERED: 1
PYTHONDONTWRITEBYTECODE: 1
PYTHONDEVMODE: 1
PYTHONFAULTHANDLER: 1
PIP_UPGRADE_STRATEGY: eager
# Don't get warnings about Python 2 support being deprecated. We
# know. The env var works for pip 20.
Expand All @@ -24,7 +25,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0-rc.1]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11.0-alpha.4"]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
Expand All @@ -43,10 +44,18 @@ jobs:
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U twine
python -m pip install -q -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"'
- name: Install greenlet
run: |
python setup.py bdist_wheel
python -m pip install -U -e ".[test,docs]"
env:
# Ensure we test with assertions enabled.
# As opposed to the manylinux builds, which we distribute and
# thus only use O3 (because Ofast enables fast-math, which has
# process-wide effects), we test with Ofast here, because we
# expect that some people will compile it themselves with that setting.
CPPFLAGS: "-Ofast -UNDEBUG"
- name: Check greenlet build
run: |
ls -l dist
Expand All @@ -58,11 +67,10 @@ jobs:
path: dist/*whl
- name: Test
run: |
python -c 'import faulthandler; assert faulthandler.is_enabled()'
python -c 'import greenlet._greenlet as G; assert G.GREENLET_USE_STANDARD_THREADING'
python -m unittest discover -v greenlet.tests
- name: Doctest
# FIXME: This conditional can go away when a Sphinx greater than 4.1.2
# is released. See https://github.com/sphinx-doc/sphinx/issues/9512
if: matrix.python-version != '3.10.0-rc.1'
run: |
sphinx-build -b doctest -d docs/_build/doctrees2 docs docs/_build/doctest2
- name: Publish package to PyPI (mac)
Expand All @@ -75,6 +83,82 @@ jobs:
run: |
twine upload --skip-existing dist/*
test_non_standard_thread:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [2.7, 3.5, "3.10"]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ns-${{ hashFiles('setup.*') }}
restore-keys: |
${{ runner.os }}-pip-ns-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U twine
python -m pip install -q -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"'
- name: Install greenlet
env:
CPPFLAGS: "-DG_USE_STANDARD_THREADING=0 -UNDEBUG -Ofast"
run: |
python setup.py bdist_wheel
python -m pip install -U -v -e ".[test,docs]"
- name: Test
run: |
python -c 'import faulthandler; assert faulthandler.is_enabled()'
python -c 'import greenlet._greenlet as G; assert not G.GREENLET_USE_STANDARD_THREADING'
python -m unittest discover -v greenlet.tests
CodeQL:
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ql-${{ hashFiles('setup.*') }}
restore-keys: |
${{ runner.os }}-pip-ql-
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools wheel
# Set the `CODEQL-PYTHON` environment variable to the Python executable
# that includes the dependencies
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: python, cpp
# Override the default behavior so that the action doesn't attempt
# to auto-install Python dependencies
setup-python-dependencies: false
- name: Install greenlet
run: |
python setup.py build
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

manylinux:

Expand All @@ -83,7 +167,13 @@ jobs:
strategy:
matrix:
python-version: [3.9]
image: [manylinux2010_x86_64, manylinux2014_aarch64, manylinux2014_ppc64le, manylinux2014_x86_64]
image:
- manylinux2010_x86_64
- manylinux2014_aarch64
- manylinux2014_ppc64le
- manylinux2014_x86_64
- musllinux_1_1_x86_64
name: ${{ matrix.image }}

steps:
- name: checkout
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ greenlet.egg-info/
__pycache__/
/.ropeproject/
/MANIFEST
benchmarks/*.json
124 changes: 124 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[MASTER]
extension-pkg-whitelist=greenlet._greenlet,greenlet.tests._test_extension
extension-pkg-allow-list=greenlet._greenlet,greenlet.tests._test_extension


[MESSAGES CONTROL]

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
# NOTE: comments must go ABOVE the statement. In Python 2, mixing in
# comments disables all directives that follow, while in Python 3, putting
# comments at the end of the line does the same thing (though Py3 supports
# mixing)


# invalid-name, ; We get lots of these, especially in scripts. should fix many of them
# protected-access, ; We have many cases of this; legit ones need to be examinid and commented, then this removed
# no-self-use, ; common in superclasses with extension points
# too-few-public-methods, ; Exception and marker classes get tagged with this
# exec-used, ; should tag individual instances with this, there are some but not too many
# global-statement, ; should tag individual instances
# multiple-statements, ; "from gevent import monkey; monkey.patch_all()"
# locally-disabled, ; yes, we know we're doing this. don't replace one warning with another
# cyclic-import, ; most of these are deferred imports
# too-many-arguments, ; these are almost always because that's what the stdlib does
# redefined-builtin, ; likewise: these tend to be keyword arguments like len= in the stdlib
# undefined-all-variable, ; XXX: This crashes with pylint 1.5.4 on Travis (but not locally on Py2/3
# ; or landscape.io on Py3). The file causing the problem is unclear. UPDATE: identified and disabled
# that file.
# see https://github.com/PyCQA/pylint/issues/846
# useless-suppression: the only way to avoid repeating it for specific statements everywhere that we
# do Py2/Py3 stuff is to put it here. Sadly this means that we might get better but not realize it.
# duplicate-code: Yeah, the compatibility ssl modules are much the same
# In pylint 1.8.0, inconsistent-return-statements are created for the wrong reasons.
# This code raises it, even though there's only one return (the implicit 'return None' is presumably
# what triggers it):
# def foo():
# if baz:
# return 1
# In Pylint 2dev1, needed for Python 3.7, we get spurious 'useless return' errors:
# @property
# def foo(self):
# return None # generates useless-return
# Pylint 2.4 adds import-outside-toplevel. But we do that a lot to defer imports because of patching.
# Pylint 2.4 adds self-assigning-variable. But we do *that* to avoid unused-import when we
# "export" the variable and don't have a __all__.
# Pylint 2.6+ adds some python-3-only things that don't apply: raise-missing-from, super-with-arguments, consider-using-f-string, redundant-u-string-prefix
disable=missing-docstring,
ungrouped-imports,
invalid-name,
protected-access,
no-self-use,
too-few-public-methods,
exec-used,
global-statement,
multiple-statements,
locally-disabled,
cyclic-import,
too-many-arguments,
redefined-builtin,
useless-suppression,
duplicate-code,
undefined-all-variable,
inconsistent-return-statements,
useless-return,
useless-object-inheritance,
import-outside-toplevel,
self-assigning-variable,
raise-missing-from,
super-with-arguments,
consider-using-f-string,
redundant-u-string-prefix

[FORMAT]
# duplicated from setup.cfg
max-line-length=160
max-module-lines=1100

[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
#notes=FIXME,XXX,TODO
# Disable that, we don't want them in the report (???)
notes=

[VARIABLES]

dummy-variables-rgx=_.*

[TYPECHECK]

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
# gevent: this is helpful for py3/py2 code.
generated-members=exc_clear

# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set). This can work
# with qualified names.
#ignored-classes=SSLContext, SSLSocket, greenlet, Greenlet, parent, dead


# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=gevent._corecffi,gevent.os,os,threading,gevent.libev.corecffi,gevent.socket,gevent.core,gevent.testing.support

[DESIGN]
max-attributes=12
max-parents=10

[BASIC]
bad-functions=input
# Prospector turns ot unsafe-load-any-extension by default, but
# pylint leaves it off. This is the proximal cause of the
# undefined-all-variable crash.
unsafe-load-any-extension = yes

# Local Variables:
# mode: conf
# End:
70 changes: 67 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,70 @@
Changes
=========

2.0.0a2 (unreleased)
====================

- Nothing changed yet.


2.0.0a1 (2022-01-20)
====================

Platforms
---------

- Add experimental, untested support for 64-bit Windows on ARM using
MSVC. See `PR 271 <https://github.com/python-greenlet/greenlet/pull/271>`_.

- Drop support for very old versions of GCC and MSVC.

- Compilation now requires a compiler that either supports C++11 or
has some other intrinsic way to create thread local variables; for
older GCC, clang and SunStudio we use ``__thread``, while for older
MSVC we use ``__declspec(thread)``.

- Wheels compatible with the musllinux specification are built,
tested, and uploaded to PyPI. (This was retroactively done for
version 1.1.2 as well.)

- This version of greenlet is known to compile and pass tests on
CPython 3.11.0a4. Earlier or later 3.11 releases may or may not
work. See `PR 280
<https://github.com/python-greenlet/greenlet/pull/280>`_. Special
thanks to Brandt Bucher and the CPython developers.

Fixes
-----

- Fix several leaks that could occur when using greenlets from
multiple threads. For example, it is no longer necessary to call
``getcurrent()`` before exiting a thread to allow its main greenlet
to be cleaned up. See `issue 252 <https://github.com/python-greenlet/greenlet/issues/251>`_.

- Fix the C API ``PyGreenlet_Throw`` to perform the same error
checking that the Python API ``greenlet.throw()`` does. Previously,
it did no error checking.

- Fix C++ exception handling on 32-bit Windows. This might have
ramifications if you embed Python in your application and also use
SEH on 32-bit windows, or if you embed Python in a C++ application.
Please contact the maintainers if you have problems in this area.

In general, C++ exception handling is expected to be better on most
platforms. This work is ongoing.

Changes
-------

- The repr of some greenlets has changed. In particular, if the
greenlet object was running in a thread that has exited, the repr
now indicates that. *NOTE:* The repr of a greenlet is not part of
the API and should not be relied upon by production code. It is
likely to differ in other implementations such as PyPy.

- Main greenlets from threads that have exited are now marked as dead.


1.1.2 (2021-09-29)
==================

Expand Down Expand Up @@ -223,9 +287,9 @@ Packaging Changes
=====
* Greenlet has an instance dictionary now, which means it can be
used for implementing greenlet local storage, etc. However, this
might introduce incompatibility if subclasses have __dict__ in their
__slots__. Classes like that will fail, because greenlet already
has __dict__ out of the box.
might introduce incompatibility if subclasses have ``__dict__`` in their
``__slots__``. Classes like that will fail, because greenlet already
has ``__dict__`` out of the box.
* Greenlet no longer leaks memory after thread termination, as long as
terminated thread has no running greenlets left at the time.
* Add support for debian sparc and openbsd5-sparc64
Expand Down
10 changes: 9 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
recursive-include src *.py
recursive-include src *.c
recursive-include src *.cpp
recursive-include src *.hpp
recursive-include src *.h
recursive-include src *.cmd
recursive-include src *.asm
recursive-include src *.obj
recursive-include benchmarks *

###
# Benchmarks and results
###
exclude benchmarks/*.json
recursive-include benchmarks *.py


###
# Documentation
Expand All @@ -28,6 +35,7 @@ include *.cfg
include *.py
include *.ini
include .clang-format
include .pylintrc

recursive-include appveyor *.cmd
recursive-include appveyor *.ps1
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The easiest way to get Greenlet is to install it with pip::
pip install greenlet


Source code archives and binary distributions are vailable on the
Source code archives and binary distributions are available on the
python package index at https://pypi.org/project/greenlet

The source code repository is hosted on github:
Expand Down
Loading

0 comments on commit 5579556

Please sign in to comment.