Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build and all deprecation warnings on Python 3. #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
sudo: required
language: python
dist: trusty

matrix:
include:
- os: linux
dist: trusty
python: 2.7
- os: linux
dist: trusty
python: 3.5
- os: linux
dist: trusty
python: 3.6
- os: linux
dist: xenial
python: 3.7
python:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9

install:
- pip install zc.buildout
Expand All @@ -25,4 +17,3 @@ install:

script:
- bin/test

8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
4.1.0 (unreleased)
------------------

- Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11 and 3.12.
- Fix building on Python 3 with certain compilers.
- Fix certain distance computation functions on Python 3.
- Fix all deprecation warnings on Python 3.

4.0.0 (2017/05/22)
------------------
- Added support for Python 3.4, 3.5 and 3.6.
Expand Down
19 changes: 13 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@


import sys
import os
from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension

unicode_arg = sys.maxunicode>0xffff and "-DUNICODE_WIDTH=4" or "-DUNICODE_WIDTH=2"
ext_args = sys.platform != "win32" and ['-Wall'] or []
unicode_arg = "-DUNICODE_WIDTH=4" if sys.maxunicode > 0xffff else "-DUNICODE_WIDTH=2"
ext_args = ["-Wall"] if sys.platform != "win32" else []

description_txt = open('README.txt').read()
with open('README.txt') as f:
description_txt = f.read()
description_txt += '\n\nChanges\n-------\n\n'
description_txt += open('CHANGES.txt').read()
with open('CHANGES.txt') as f:
description_txt += f.read()

version = '4.0.0'

Expand All @@ -39,6 +40,12 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
Expand Down
29 changes: 29 additions & 0 deletions zopyx/txng3/ext/compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>

#if PY_MAJOR_VERSION >= 3
# define PY3K
# define INT_FROM_LONG(x) PyLong_FromLong(x)
# define INT_CHECK(x) PyLong_Check(x)
# define UNICODE_LENGTH(x) PyUnicode_GET_LENGTH(x)
# define UNICODE_T wchar_t
# define PYSTR_TO_UNICODE_T(unicode, len) PyUnicode_AsWideCharString(unicode, len)
# define UNICODE_T_TO_PYSTR(chars, len) PyUnicode_FromWideChar(chars, len)
# define FREE_UNICODE_T(x) PyMem_Free(x)
#else /* Python 2 */
# define INT_FROM_LONG(x) PyInt_FromLong(x)
# define INT_CHECK(x) PyInt_Check(x)
# define UNICODE_LENGTH(x) PyUnicode_GET_SIZE(x)
# define UNICODE_T Py_UNICODE
static UNICODE_T* PYSTR_TO_UNICODE_T(PyObject* unicode, Py_ssize_t* len)
{
*len = UNICODE_LENGTH(unicode);
return PyUnicode_AS_UNICODE(unicode);
}
# define UNICODE_T_TO_PYSTR(chars, len) PyUnicode_FromUnicode(chars, len)
# define FREE_UNICODE_T(x)
#endif

#ifndef PyInt_AS_LONG
# define PyInt_AS_LONG(x) PyLong_AsLong(x)
#endif
10 changes: 2 additions & 8 deletions zopyx/txng3/ext/normalizer_src/normalizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,8 @@ static struct PyMethodDef Normalizer_methods[] =
static char NormalizerType__doc__[] = "Normalizer object";

static PyTypeObject NormalizerType = {
#ifndef PY3K
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"Normalizer", /*tp_name*/
#else
PyObject_HEAD_INIT(NULL)
"Normalizer", /*tp_name*/
#endif
PyVarObject_HEAD_INIT(NULL, 0)
"Normalizer", /*tp_yname*/
sizeof(Normalizer), /*tp_basicsize*/
0, /*tp_itemsize*/
/* methods */
Expand Down
Loading