add pypy3 support
This commit is contained in:
parent
dd237bb395
commit
1477189b9a
@ -62,6 +62,18 @@
|
|||||||
|
|
||||||
#define EXT3
|
#define EXT3
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_HAVE_CLASS
|
||||||
|
#define Py_TPFLAGS_HAVE_CLASS (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_HAVE_WEAKREFS
|
||||||
|
#define Py_TPFLAGS_HAVE_WEAKREFS (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_TPFLAGS_HAVE_ITER
|
||||||
|
#define Py_TPFLAGS_HAVE_ITER (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PyMODINIT_FUNC
|
#ifndef PyMODINIT_FUNC
|
||||||
#define EXT_INIT_FUNC PyObject *CONCATENATE(PyInit_, EXT_MODULE)(void)
|
#define EXT_INIT_FUNC PyObject *CONCATENATE(PyInit_, EXT_MODULE)(void)
|
||||||
#else
|
#else
|
||||||
@ -85,10 +97,17 @@ static struct PyModuleDef EXT_DEFINE_VAR = { \
|
|||||||
#define EXT_INIT_ERROR(module) do {Py_XDECREF(module); return NULL;} while(0)
|
#define EXT_INIT_ERROR(module) do {Py_XDECREF(module); return NULL;} while(0)
|
||||||
#define EXT_INIT_RETURN(module) return module
|
#define EXT_INIT_RETURN(module) return module
|
||||||
|
|
||||||
|
#define EXT_DOC_UNICODE(m)
|
||||||
|
|
||||||
#else /* end py3k */
|
#else /* end py3k */
|
||||||
|
|
||||||
#define EXT2
|
#define EXT2
|
||||||
|
|
||||||
|
#ifndef PyVarObject_HEAD_INIT
|
||||||
|
#define PyVarObject_HEAD_INIT(type, size) \
|
||||||
|
PyObject_HEAD_INIT(type) size,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PyMODINIT_FUNC
|
#ifndef PyMODINIT_FUNC
|
||||||
#define EXT_INIT_FUNC void CONCATENATE(init, EXT_MODULE)(void)
|
#define EXT_INIT_FUNC void CONCATENATE(init, EXT_MODULE)(void)
|
||||||
#else
|
#else
|
||||||
@ -117,6 +136,25 @@ static struct EXT_DEFINE__STRUCT EXT_DEFINE_VAR = { \
|
|||||||
#define EXT_INIT_ERROR(module) return
|
#define EXT_INIT_ERROR(module) return
|
||||||
#define EXT_INIT_RETURN(module) return
|
#define EXT_INIT_RETURN(module) return
|
||||||
|
|
||||||
|
#define EXT_DOC_UNICODE(m) do { \
|
||||||
|
PyObject *doc__, *uni__; \
|
||||||
|
int res__; \
|
||||||
|
\
|
||||||
|
if ((doc__ = PyObject_GetAttrString(m, "__doc__"))) { \
|
||||||
|
uni__ = PyUnicode_FromEncodedObject(doc__, "utf-8", "strict"); \
|
||||||
|
Py_DECREF(doc__); \
|
||||||
|
if (!uni__) \
|
||||||
|
EXT_INIT_ERROR(m); \
|
||||||
|
res__ = PyObject_SetAttrString(m, "__doc__", uni__); \
|
||||||
|
Py_DECREF(uni__); \
|
||||||
|
if (res__ == -1) \
|
||||||
|
EXT_INIT_ERROR(m); \
|
||||||
|
} \
|
||||||
|
else if (!(PyErr_Occurred() \
|
||||||
|
&& PyErr_ExceptionMatches(PyExc_AttributeError))) \
|
||||||
|
EXT_INIT_ERROR(m); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#endif /* end py2K */
|
#endif /* end py2K */
|
||||||
|
|
||||||
#define EXT_INIT_TYPE(module, type) do { \
|
#define EXT_INIT_TYPE(module, type) do { \
|
||||||
@ -232,13 +270,17 @@ typedef int Py_ssize_t;
|
|||||||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_GENERIC_DEALLOC(prefix) \
|
#ifndef Py_TYPE
|
||||||
static void prefix##_dealloc(void *self) \
|
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||||
{ \
|
#endif
|
||||||
if (PyType_IS_GC(((PyObject *)self)->ob_type)) \
|
|
||||||
PyObject_GC_UnTrack(self); \
|
#define DEFINE_GENERIC_DEALLOC(prefix) \
|
||||||
(void)prefix##_clear(self); \
|
static void prefix##_dealloc(void *self) \
|
||||||
((PyObject *)self)->ob_type->tp_free((PyObject *)self); \
|
{ \
|
||||||
|
if (PyType_IS_GC(Py_TYPE(self))) \
|
||||||
|
PyObject_GC_UnTrack(self); \
|
||||||
|
(void)prefix##_clear(self); \
|
||||||
|
(Py_TYPE(self))->tp_free((PyObject *)self); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SETUP_CEXT_H */
|
#endif /* SETUP_CEXT_H */
|
||||||
|
@ -41,7 +41,7 @@ def _cleanup_epydoc(target):
|
|||||||
"""
|
"""
|
||||||
search = _re.compile(r'<table[^<>]+width="100%%"').search
|
search = _re.compile(r'<table[^<>]+width="100%%"').search
|
||||||
for filename in _shell.files(target, '*.html'):
|
for filename in _shell.files(target, '*.html'):
|
||||||
fp = open(filename, 'r', encoding='latin-1')
|
fp = open(filename, 'r')
|
||||||
try:
|
try:
|
||||||
html = fp.read()
|
html = fp.read()
|
||||||
finally:
|
finally:
|
||||||
@ -53,7 +53,7 @@ def _cleanup_epydoc(target):
|
|||||||
if end >= 0:
|
if end >= 0:
|
||||||
end += len('</table>') + 1
|
end += len('</table>') + 1
|
||||||
html = html[:start] + html[end:]
|
html = html[:start] + html[end:]
|
||||||
fp = open(filename, 'w', encoding='latin-1')
|
fp = open(filename, 'w')
|
||||||
try:
|
try:
|
||||||
fp.write(html)
|
fp.write(html)
|
||||||
finally:
|
finally:
|
||||||
|
@ -87,7 +87,7 @@ def find_description(docs):
|
|||||||
summary = None
|
summary = None
|
||||||
filename = docs.get('meta.summary', 'SUMMARY').strip()
|
filename = docs.get('meta.summary', 'SUMMARY').strip()
|
||||||
if filename and _os.path.isfile(filename):
|
if filename and _os.path.isfile(filename):
|
||||||
fp = open(filename, encoding='utf-8')
|
fp = open(filename)
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
summary = fp.read().strip().splitlines()[0].rstrip()
|
summary = fp.read().strip().splitlines()[0].rstrip()
|
||||||
@ -99,7 +99,7 @@ def find_description(docs):
|
|||||||
description = None
|
description = None
|
||||||
filename = docs.get('meta.description', 'DESCRIPTION').strip()
|
filename = docs.get('meta.description', 'DESCRIPTION').strip()
|
||||||
if filename and _os.path.isfile(filename):
|
if filename and _os.path.isfile(filename):
|
||||||
fp = open(filename, encoding='utf-8')
|
fp = open(filename)
|
||||||
try:
|
try:
|
||||||
description = fp.read().rstrip()
|
description = fp.read().rstrip()
|
||||||
finally:
|
finally:
|
||||||
@ -125,7 +125,7 @@ def find_classifiers(docs):
|
|||||||
"""
|
"""
|
||||||
filename = docs.get('meta.classifiers', 'CLASSIFIERS').strip()
|
filename = docs.get('meta.classifiers', 'CLASSIFIERS').strip()
|
||||||
if filename and _os.path.isfile(filename):
|
if filename and _os.path.isfile(filename):
|
||||||
fp = open(filename, encoding='utf-8')
|
fp = open(filename)
|
||||||
try:
|
try:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
finally:
|
finally:
|
||||||
@ -144,7 +144,7 @@ def find_provides(docs):
|
|||||||
"""
|
"""
|
||||||
filename = docs.get('meta.provides', 'PROVIDES').strip()
|
filename = docs.get('meta.provides', 'PROVIDES').strip()
|
||||||
if filename and _os.path.isfile(filename):
|
if filename and _os.path.isfile(filename):
|
||||||
fp = open(filename, encoding='utf-8')
|
fp = open(filename)
|
||||||
try:
|
try:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
finally:
|
finally:
|
||||||
@ -163,7 +163,7 @@ def find_license(docs):
|
|||||||
"""
|
"""
|
||||||
filename = docs.get('meta.license', 'LICENSE').strip()
|
filename = docs.get('meta.license', 'LICENSE').strip()
|
||||||
if filename and _os.path.isfile(filename):
|
if filename and _os.path.isfile(filename):
|
||||||
fp = open(filename, encoding='utf-8')
|
fp = open(filename)
|
||||||
try:
|
try:
|
||||||
return fp.read().rstrip()
|
return fp.read().rstrip()
|
||||||
finally:
|
finally:
|
||||||
@ -338,7 +338,7 @@ def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
|
|||||||
ext = []
|
ext = []
|
||||||
|
|
||||||
cfg = _util.SafeConfigParser()
|
cfg = _util.SafeConfigParser()
|
||||||
cfg.read(config, encoding='utf-8')
|
cfg.read(config)
|
||||||
pkg = dict(cfg.items('package'))
|
pkg = dict(cfg.items('package'))
|
||||||
python_min = pkg.get('python.min') or None
|
python_min = pkg.get('python.min') or None
|
||||||
python_max = pkg.get('python.max') or None
|
python_max = pkg.get('python.max') or None
|
||||||
@ -368,13 +368,13 @@ def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
|
|||||||
keywords = keywords.split()
|
keywords = keywords.split()
|
||||||
revision = pkg.get('version.revision', '').strip()
|
revision = pkg.get('version.revision', '').strip()
|
||||||
if revision:
|
if revision:
|
||||||
revision = "-r%s" % (revision,)
|
revision = int(revision)
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'name': pkg['name'],
|
'name': pkg['name'],
|
||||||
'version': "%s%s" % (
|
'version': "%s%s" % (
|
||||||
pkg['version.number'],
|
pkg['version.number'],
|
||||||
["", "-dev%s" % (revision,)][_util.humanbool(
|
["", ".dev%d" % (revision,)][_util.humanbool(
|
||||||
'version.dev', pkg.get('version.dev', 'false')
|
'version.dev', pkg.get('version.dev', 'false')
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: ascii -*-
|
# -*- coding: ascii -*-
|
||||||
#
|
#
|
||||||
# Copyright 2007, 2008, 2009, 2010, 2011
|
# Copyright 2007 - 2015
|
||||||
# Andr\xe9 Malo or his licensors, as applicable
|
# Andr\xe9 Malo or his licensors, as applicable
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -54,8 +54,7 @@ class _INFO(dict):
|
|||||||
""" Make color control string """
|
""" Make color control string """
|
||||||
seq = _curses.tigetstr('setaf')
|
seq = _curses.tigetstr('setaf')
|
||||||
if seq is not None:
|
if seq is not None:
|
||||||
# XXX may fail - need better logic
|
seq = _curses.tparm(seq, color)
|
||||||
seq = seq.replace("%p1", "") % color
|
|
||||||
return seq
|
return seq
|
||||||
|
|
||||||
self['NORMAL'] = _curses.tigetstr('sgr0')
|
self['NORMAL'] = _curses.tigetstr('sgr0')
|
||||||
@ -71,7 +70,7 @@ class _INFO(dict):
|
|||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
""" Deliver always """
|
""" Deliver always """
|
||||||
dict.get(self, key) or ""
|
return dict.get(self, key) or ""
|
||||||
|
|
||||||
|
|
||||||
def terminfo():
|
def terminfo():
|
||||||
@ -111,5 +110,3 @@ def announce(fmt, **kwargs):
|
|||||||
write(fmt, **kwargs)
|
write(fmt, **kwargs)
|
||||||
_sys.stdout.write("\n")
|
_sys.stdout.write("\n")
|
||||||
_sys.stdout.flush()
|
_sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,14 +250,14 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
kwargs['packages'] = list(kwargs.get('packages') or ()) + [
|
kwargs['packages'] = list(kwargs.get('packages') or ()) + [
|
||||||
'_setup', '_setup.py2', '_setup.py3',
|
'_setup', '_setup.py2', '_setup.py3',
|
||||||
] + list(manifest.get('packages.extra', '').split() or ())
|
] + list(manifest.get('packages.extra', '').split() or ())
|
||||||
_core._setup_stop_after = "commandline"
|
_core._setup_stop_after = "commandline" # noqa pylint: disable = protected-access
|
||||||
try:
|
try:
|
||||||
dist = _core.setup(**kwargs)
|
dist = _core.setup(**kwargs)
|
||||||
finally:
|
finally:
|
||||||
_core._setup_stop_after = None
|
_core._setup_stop_after = None # pylint: disable = protected-access
|
||||||
|
|
||||||
result = ['MANIFEST', 'PKG-INFO', 'setup.py'] + list(config)
|
result = ['MANIFEST', 'PKG-INFO', 'setup.py'] + list(config)
|
||||||
# TODO: work with default values:
|
# xx: work with default values?
|
||||||
for key in ('classifiers', 'description', 'summary', 'provides',
|
for key in ('classifiers', 'description', 'summary', 'provides',
|
||||||
'license'):
|
'license'):
|
||||||
filename = docs.get('meta.' + key, '').strip()
|
filename = docs.get('meta.' + key, '').strip()
|
||||||
@ -266,7 +266,7 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
|
|
||||||
cmd = dist.get_command_obj("build_py")
|
cmd = dist.get_command_obj("build_py")
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
#from pprint import pprint; pprint(("build_py", cmd.get_source_files()))
|
# from pprint import pprint; pprint(("build_py", cmd.get_source_files()))
|
||||||
for item in cmd.get_source_files():
|
for item in cmd.get_source_files():
|
||||||
result.append(_posixpath.sep.join(
|
result.append(_posixpath.sep.join(
|
||||||
_os.path.normpath(item).split(_os.path.sep)
|
_os.path.normpath(item).split(_os.path.sep)
|
||||||
@ -274,7 +274,7 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
|
|
||||||
cmd = dist.get_command_obj("build_ext")
|
cmd = dist.get_command_obj("build_ext")
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
#from pprint import pprint; pprint(("build_ext", cmd.get_source_files()))
|
# from pprint import pprint; pprint(("build_ext", cmd.get_source_files()))
|
||||||
for item in cmd.get_source_files():
|
for item in cmd.get_source_files():
|
||||||
result.append(_posixpath.sep.join(
|
result.append(_posixpath.sep.join(
|
||||||
_os.path.normpath(item).split(_os.path.sep)
|
_os.path.normpath(item).split(_os.path.sep)
|
||||||
@ -288,7 +288,7 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
cmd = dist.get_command_obj("build_clib")
|
cmd = dist.get_command_obj("build_clib")
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
if cmd.libraries:
|
if cmd.libraries:
|
||||||
#import pprint; pprint.pprint(("build_clib", cmd.get_source_files()))
|
# import pprint; pprint.pprint(("build_clib", cmd.get_source_files()))
|
||||||
for item in cmd.get_source_files():
|
for item in cmd.get_source_files():
|
||||||
result.append(_posixpath.sep.join(
|
result.append(_posixpath.sep.join(
|
||||||
_os.path.normpath(item).split(_os.path.sep)
|
_os.path.normpath(item).split(_os.path.sep)
|
||||||
@ -301,7 +301,7 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
|
|
||||||
cmd = dist.get_command_obj("build_scripts")
|
cmd = dist.get_command_obj("build_scripts")
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
#import pprint; pprint.pprint(("build_scripts", cmd.get_source_files()))
|
# import pprint; pprint.pprint(("build_scripts", cmd.get_source_files()))
|
||||||
if cmd.get_source_files():
|
if cmd.get_source_files():
|
||||||
for item in cmd.get_source_files():
|
for item in cmd.get_source_files():
|
||||||
result.append(_posixpath.sep.join(
|
result.append(_posixpath.sep.join(
|
||||||
@ -310,7 +310,7 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
|
|
||||||
cmd = dist.get_command_obj("install_data")
|
cmd = dist.get_command_obj("install_data")
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
#from pprint import pprint; pprint(("install_data", cmd.get_inputs()))
|
# from pprint import pprint; pprint(("install_data", cmd.get_inputs()))
|
||||||
try:
|
try:
|
||||||
strings = str
|
strings = str
|
||||||
except NameError:
|
except NameError:
|
||||||
@ -335,11 +335,15 @@ def make_manifest(manifest, config, docs, kwargs):
|
|||||||
|
|
||||||
def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
|
def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
|
||||||
""" Main runner """
|
""" Main runner """
|
||||||
|
# pylint: disable = too-many-locals
|
||||||
if ext is None:
|
if ext is None:
|
||||||
ext = []
|
ext = []
|
||||||
|
|
||||||
cfg = _util.SafeConfigParser()
|
cfg = _util.SafeConfigParser()
|
||||||
cfg.read(config, encoding='utf-8')
|
if (3, 0, 0) <= _sys.version_info < (3, 2, 0):
|
||||||
|
cfg.read(config)
|
||||||
|
else:
|
||||||
|
cfg.read(config, encoding='utf-8')
|
||||||
pkg = dict(cfg.items('package'))
|
pkg = dict(cfg.items('package'))
|
||||||
python_min = pkg.get('python.min') or None
|
python_min = pkg.get('python.min') or None
|
||||||
python_max = pkg.get('python.max') or None
|
python_max = pkg.get('python.max') or None
|
||||||
@ -369,13 +373,13 @@ def run(config=('package.cfg',), ext=None, script_args=None, manifest_only=0):
|
|||||||
keywords = keywords.split()
|
keywords = keywords.split()
|
||||||
revision = pkg.get('version.revision', '').strip()
|
revision = pkg.get('version.revision', '').strip()
|
||||||
if revision:
|
if revision:
|
||||||
revision = "-r%s" % (revision,)
|
revision = int(revision)
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'name': pkg['name'],
|
'name': pkg['name'],
|
||||||
'version': "%s%s" % (
|
'version': "%s%s" % (
|
||||||
pkg['version.number'],
|
pkg['version.number'],
|
||||||
["", "-dev%s" % (revision,)][_util.humanbool(
|
["", ".dev%d" % (revision,)][_util.humanbool(
|
||||||
'version.dev', pkg.get('version.dev', 'false')
|
'version.dev', pkg.get('version.dev', 'false')
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: ascii -*-
|
# -*- coding: ascii -*-
|
||||||
#
|
#
|
||||||
# Copyright 2007, 2008, 2009, 2010, 2011
|
# Copyright 2007 - 2015
|
||||||
# Andr\xe9 Malo or his licensors, as applicable
|
# Andr\xe9 Malo or his licensors, as applicable
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -53,16 +53,16 @@ class _INFO(dict):
|
|||||||
try:
|
try:
|
||||||
_curses.tigetstr('sgr0')
|
_curses.tigetstr('sgr0')
|
||||||
except TypeError: # pypy3
|
except TypeError: # pypy3
|
||||||
|
# pylint: disable = invalid-name
|
||||||
bc = lambda val: val.encode('ascii')
|
bc = lambda val: val.encode('ascii')
|
||||||
else:
|
else:
|
||||||
bc = lambda val: val
|
bc = lambda val: val # pylint: disable = invalid-name
|
||||||
|
|
||||||
def make_color(color):
|
def make_color(color):
|
||||||
""" Make color control string """
|
""" Make color control string """
|
||||||
seq = _curses.tigetstr(bc('setaf')).decode('ascii')
|
seq = _curses.tigetstr(bc('setaf'))
|
||||||
if seq is not None:
|
if seq is not None:
|
||||||
# XXX may fail - need better logic
|
seq = _curses.tparm(seq, color).decode('ascii')
|
||||||
seq = seq.replace("%p1", "") % color
|
|
||||||
return seq
|
return seq
|
||||||
|
|
||||||
self['NORMAL'] = _curses.tigetstr(bc('sgr0')).decode('ascii')
|
self['NORMAL'] = _curses.tigetstr(bc('sgr0')).decode('ascii')
|
||||||
@ -79,7 +79,7 @@ class _INFO(dict):
|
|||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
""" Deliver always """
|
""" Deliver always """
|
||||||
dict.get(self, key) or ""
|
return dict.get(self, key) or ""
|
||||||
|
|
||||||
|
|
||||||
def terminfo():
|
def terminfo():
|
||||||
@ -119,5 +119,3 @@ def announce(fmt, **kwargs):
|
|||||||
write(fmt, **kwargs)
|
write(fmt, **kwargs)
|
||||||
_sys.stdout.write("\n")
|
_sys.stdout.write("\n")
|
||||||
_sys.stdout.flush()
|
_sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user