Skip to content

Commit

Permalink
Drop using setup_requires. (#98)
Browse files Browse the repository at this point in the history
* Drop using ``setup_requires`` due to constant problems on GHA.

* Add preliminary support for Python 3.12a7
  • Loading branch information
Michael Howitz committed Apr 20, 2023
1 parent 7c93404 commit 869deee
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 40 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12.0-alpha.5"
- "3.12.0-alpha.7"
os: [ubuntu-20.04, macos-11]
exclude:
- os: macos-11
Expand Down Expand Up @@ -179,15 +179,15 @@ jobs:
python setup.py build_ext -i
python setup.py bdist_wheel
- name: Install zope.security and dependencies (3.12.0-alpha.5)
if: matrix.python-version == '3.12.0-alpha.5'
- name: Install zope.security and dependencies (3.12.0-alpha.7)
if: matrix.python-version == '3.12.0-alpha.7'
run: |
# Install to collect dependencies into the (pip) cache.
# Use "--pre" here because dependencies with support for this future
# Python release may only be available as pre-releases
pip install --pre .[test]
- name: Install zope.security and dependencies
if: matrix.python-version != '3.12.0-alpha.5'
if: matrix.python-version != '3.12.0-alpha.7'
run: |
# Install to collect dependencies into the (pip) cache.
pip install .[test]
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
&& startsWith(github.ref, 'refs/tags')
&& startsWith(runner.os, 'Mac')
&& !startsWith(matrix.python-version, 'pypy')
&& !startsWith(matrix.python-version, '3.12.0-alpha.5')
&& !startsWith(matrix.python-version, '3.12.0-alpha.7')
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
run: |
Expand All @@ -250,7 +250,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12.0-alpha.5"
- "3.12.0-alpha.7"
os: [ubuntu-20.04, macos-11]
exclude:
- os: macos-11
Expand Down Expand Up @@ -287,8 +287,8 @@ jobs:
with:
name: zope.security-${{ runner.os }}-${{ matrix.python-version }}.whl
path: dist/
- name: Install zope.security 3.12.0-alpha.5
if: ${{ startsWith(matrix.python-version, '3.12.0-alpha.5') }}
- name: Install zope.security 3.12.0-alpha.7
if: ${{ startsWith(matrix.python-version, '3.12.0-alpha.7') }}
run: |
pip install -U wheel setuptools
# coverage has a wheel on PyPI for a future python version which is
Expand All @@ -302,7 +302,7 @@ jobs:
# Python release may only be available as pre-releases
pip install --pre -U -e .[test]
- name: Install zope.security
if: ${{ !startsWith(matrix.python-version, '3.12.0-alpha.5') }}
if: ${{ !startsWith(matrix.python-version, '3.12.0-alpha.7') }}
run: |
pip install -U wheel setuptools
pip install -U coverage
Expand Down
3 changes: 2 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zopefoundation/meta/tree/master/config/c-code
[meta]
template = "c-code"
commit-id = "f0962ac8"
commit-id = "fe63cb4c"

[python]
with-appveyor = true
Expand Down Expand Up @@ -30,6 +30,7 @@ fail-under = 99.5
additional-rules = [
"include *.sh",
"recursive-include docs *.bat",
"recursive-include include *.h",
"recursive-include src *.zcml",
]

Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
PEP 3114), and drop support for the Python 2 ``next`` method name from
pure-Python proxies.

- Add preliminary support for Python 3.12 as of 3.12a5.
- Add preliminary support for Python 3.12 as of 3.12a7.

- Drop using ``setup_requires`` due to constant problems on GHA.


6.1 (2023-01-18)
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ recursive-include docs Makefile
recursive-include src *.py
include *.sh
recursive-include docs *.bat
recursive-include include *.h
recursive-include src *.zcml
53 changes: 53 additions & 0 deletions include/zope.proxy/zope/proxy/proxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef _proxy_H_
#define _proxy_H_ 1

typedef struct {
PyObject_HEAD
PyObject *proxy_object;
} ProxyObject;

#define Proxy_GET_OBJECT(ob) (((ProxyObject *)(ob))->proxy_object)

typedef struct {
PyTypeObject *proxytype;
int (*check)(PyObject *obj);
PyObject *(*create)(PyObject *obj);
PyObject *(*getobject)(PyObject *proxy);
} ProxyInterface;

#ifndef PROXY_MODULE

/* These are only defined in the public interface, and are not
* available within the module implementation. There we use the
* classic Python/C API only.
*/

static ProxyInterface *_proxy_api = NULL;

static int
Proxy_Import(void)
{
if (_proxy_api == NULL) {
PyObject *m = PyImport_ImportModule("zope.proxy");
if (m != NULL) {
PyObject *tmp = PyObject_GetAttrString(m, "_CAPI");
if (tmp != NULL) {
if (PyCapsule_CheckExact(tmp))
_proxy_api = (ProxyInterface *)
PyCapsule_GetPointer(tmp, NULL);
Py_DECREF(tmp);
}
}
}
return (_proxy_api == NULL) ? -1 : 0;
}

#define ProxyType (*_proxy_api->proxytype)
#define Proxy_Check(obj) (_proxy_api->check((obj)))
#define Proxy_CheckExact(obj) ((obj)->ob_type == ProxyType)
#define Proxy_New(obj) (_proxy_api->create((obj)))
#define Proxy_GetObject(proxy) (_proxy_api->getobject((proxy)))

#endif /* PROXY_MODULE */

#endif /* _proxy_H_ */
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ignore =
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources, pytz
known_third_party = docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
Expand Down
30 changes: 2 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,12 @@ def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()

# Include directories for C extensions
# Sniff the location of the headers in the package distribution


class ModuleHeaderDir:

def __init__(self, require_spec, where='../..'):
# By default, assume top-level pkg has the same name as the dist.
# Also assume that headers are located in the package dir, and
# are meant to be included as follows:
# #include "module/header_name.h"
self._require_spec = require_spec
self._where = where

def __str__(self):
from pkg_resources import require
from pkg_resources import resource_filename
require(self._require_spec)
path = resource_filename(self._require_spec, self._where)
return os.path.abspath(path)


include = [ModuleHeaderDir('zope.proxy')]

codeoptimization = [
Extension(
"zope.security._proxy",
[os.path.join('src', 'zope', 'security', "_proxy.c")],
include_dirs=include,
include_dirs=[os.path.join('include', 'zope.proxy')],
sources=[os.path.join('src', 'zope', 'security', "_proxy.c")]
),
Extension(
"zope.security._zope_security_checker",
Expand All @@ -111,10 +88,8 @@ def __str__(self):
is_jython = 'java' in sys.platform

if is_pypy or is_jython:
setup_requires = []
ext_modules = []
else:
setup_requires = ['zope.proxy >= 4.3.0']
ext_modules = codeoptimization


Expand Down Expand Up @@ -169,7 +144,6 @@ def __str__(self):
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
setup_requires=setup_requires,
cmdclass={
'build_ext': optional_build_ext,
},
Expand Down

0 comments on commit 869deee

Please sign in to comment.