Skip to content

Commit bb630dc

Browse files
committed
Remove build and support for Python 2 and Python3 < 3.8.
Closes #276 Closes #267 Closes #277
1 parent b234f6a commit bb630dc

File tree

5 files changed

+23
-198
lines changed

5 files changed

+23
-198
lines changed

.github/workflows/ci.yml

+5-33
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ jobs:
1212
matrix:
1313
os:
1414
- windows-2019
15-
- ubuntu-20.04
15+
- ubuntu-latest
1616
- macos-latest
1717
python-version:
18-
- "2.7"
18+
- "3.14-dev"
19+
- "3.13"
1920
- "3.12"
2021
- "3.11"
2122
- "3.10"
2223
- "3.9"
2324
- "3.8"
24-
- "3.7"
25-
- "3.6"
26-
- "pypy-2.7"
27-
- "pypy-3.7"
2825
- "pypy-3.8"
2926
- "pypy-3.9"
3027
- "pypy-3.10"
@@ -35,10 +32,6 @@ jobs:
3532
- "luajit-5.1"
3633

3734
exclude:
38-
- os: windows-2019
39-
python-version: "2.7"
40-
- os: windows-2019
41-
python-version: pypy-2.7
4235
- os: windows-2019
4336
lua-version: lua5.2
4437
- os: windows-2019
@@ -48,15 +41,6 @@ jobs:
4841
- os: windows-2019
4942
lua-version: luajit-5.1
5043

51-
- os: macos-latest
52-
python-version: "2.7"
53-
- os: macos-latest
54-
python-version: "3.6"
55-
- os: macos-latest
56-
python-version: "3.7"
57-
- os: macos-latest
58-
python-version: pypy-3.7
59-
6044
- os: macos-latest
6145
lua-version: lua5.2
6246
- os: macos-latest
@@ -81,33 +65,21 @@ jobs:
8165
run: git submodule update --init --recursive
8266

8367
- name: Set up Python ${{ matrix.python-version }}
84-
if: startsWith(matrix.python-version, '3.') || startsWith(matrix.python-version, 'pypy') || !startsWith(matrix.os, 'ubuntu')
8568
uses: actions/setup-python@v5
8669
with:
8770
python-version: ${{ matrix.python-version }}
8871

89-
- name: Set up Python2 (Linux)
90-
if: matrix.python-version == '2.7' && startsWith(matrix.os, 'ubuntu')
91-
run: |
92-
sudo ln -fs python2 /usr/bin/python
93-
sudo apt-get update
94-
sudo apt-get install python-setuptools python2.7 python2.7-dev
95-
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
96-
sudo python2 get-pip.py
97-
ls -l /usr/bin/pip* /usr/local/bin/pip*
98-
which pip
99-
10072
- name: Set up Python packages
10173
run: |
102-
python -m pip install -U ${{ startsWith(matrix.python-version, '2.7') && '"pip<21" "setuptools<45"' || 'pip setuptools' }}
74+
python -m pip install -U pip setuptools
10375
python -m pip install -U wheel tox virtualenv -r requirements.txt
10476
10577
- name: Set up Lua ${{ matrix.lua-version }}
10678
if: contains(matrix.os, 'ubuntu') && matrix.lua-version != 'bundle'
10779
run: sudo apt-get install lib${{ matrix.lua-version }}-dev
10880

10981
- name: Build wheel
110-
run: python setup.py sdist ${{ contains(matrix.python-version, '3.') && 'build_ext -j6' || '' }} bdist_wheel
82+
run: python setup.py sdist build_ext -j6 bdist_wheel
11183
env:
11284
SETUP_OPTIONS: ${{ !contains(matrix.lua-version, 'luajit') && (contains(matrix.lua-version, 'bundle') && '--use-bundle' || '--no-luajit') || '' }}
11385
CFLAGS: ${{ env.CFLAGS }} ${{ env.CFLAGS_LTO }}

.github/workflows/wheels.yml

+4-69
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ permissions: {}
4040

4141
jobs:
4242
sdist:
43-
runs-on: ubuntu-20.04
43+
runs-on: ubuntu-latest
4444

4545
permissions:
4646
contents: write # to create GitHub release (softprops/action-gh-release)
@@ -80,7 +80,7 @@ jobs:
8080
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
8181
- name: Install cibuildwheel
8282
# Nb. keep cibuildwheel version pin consistent with job below
83-
run: pipx install cibuildwheel==2.16.5
83+
run: pipx install cibuildwheel==2.22.0
8484
- id: set-matrix
8585
run: |
8686
MATRIX=$(
@@ -129,7 +129,7 @@ jobs:
129129
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
130130
131131
- name: Build wheels
132-
uses: pypa/cibuildwheel@v2.16.5
132+
uses: pypa/cibuildwheel@v2.22.0
133133
with:
134134
only: ${{ matrix.only }}
135135

@@ -195,7 +195,7 @@ jobs:
195195
- name: Set up Python
196196
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
197197
with:
198-
python-version: "3.9"
198+
python-version: "3.12"
199199

200200
- name: Install dependencies
201201
run: python -m pip install -r requirements.txt
@@ -210,68 +210,3 @@ jobs:
210210
name: wheels-${{ matrix.image }}
211211
path: wheelhouse_*/*-m*linux*.whl # manylinux / musllinux
212212
if-no-files-found: ignore
213-
214-
non-Linux:
215-
strategy:
216-
# Allows for matrix sub-jobs to fail without canceling the rest
217-
fail-fast: false
218-
219-
matrix:
220-
os:
221-
- macos-13
222-
#- windows-2019
223-
pyversion:
224-
- "2.7"
225-
- "3.6"
226-
#- "pypy-3.7-v7.3.7"
227-
#- "pypy-3.8-v7.3.7"
228-
#- "pypy-3.9-v7.3.11"
229-
#- "pypy-3.10-v7.3.13"
230-
231-
exclude:
232-
# outdated compilers and probably not worth supporting anymore
233-
- os: windows-2019
234-
pyversion: "2.7"
235-
236-
runs-on: ${{ matrix.os }}
237-
env:
238-
USE_BUNDLE: "true"
239-
MACOSX_DEPLOYMENT_TARGET: "11.0"
240-
LUPA_WITH_LUA_DLOPEN: ${{ startsWith(matrix.os, 'windows') && 'false' || 'true' }}
241-
PYTHON_BIN_DIR: ${{ startsWith(matrix.pyversion, '2.') && '/Library/Frameworks/Python.framework/Versions/2.7/bin' || '' }}
242-
243-
steps:
244-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
245-
246-
- name: Check out recursively
247-
run: git submodule update --init --recursive
248-
249-
- name: Set up Python
250-
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
251-
# macOS has Py2.7 installed system wide
252-
if: matrix.pyversion != '2.7'
253-
with:
254-
python-version: ${{ matrix.pyversion }}
255-
256-
- name: Install MacOS dependencies
257-
if: startsWith(matrix.os, 'mac')
258-
run: |
259-
brew install automake libtool
260-
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
261-
262-
- name: Install dependencies
263-
run: |
264-
export PATH=$PYTHON_BIN_DIR:$PATH
265-
python -m pip install setuptools wheel -r requirements.txt
266-
267-
- name: Build wheels
268-
run: |
269-
export PATH=$PYTHON_BIN_DIR:$PATH
270-
python setup.py --with-cython sdist ${{ contains(matrix.pyversion, '3.') && 'build_ext -j6' || '' }} bdist_wheel
271-
272-
- name: Upload wheels
273-
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
274-
with:
275-
name: wheels-${{ matrix.pyversion }}-${{ matrix.os }}
276-
path: dist/*.whl
277-
if-no-files-found: ignore

lupa/_lupa.pyx

+14-46
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,7 @@ from cpython.method cimport (
2424
from cpython.bytes cimport PyBytes_FromFormat
2525

2626
#from libc.stdint cimport uintptr_t
27-
cdef extern from *:
28-
"""
29-
#if PY_VERSION_HEX < 0x03040000 && defined(_MSC_VER)
30-
#ifndef _MSC_STDINT_H_
31-
#ifdef _WIN64 // [
32-
typedef unsigned __int64 uintptr_t;
33-
#else // _WIN64 ][
34-
typedef _W64 unsigned int uintptr_t;
35-
#endif // _WIN64 ]
36-
#endif
37-
#else
38-
#include <stdint.h>
39-
#endif
40-
"""
27+
cdef extern from "stdint.h":
4128
ctypedef size_t uintptr_t
4229
cdef const Py_ssize_t PY_SSIZE_T_MAX
4330
cdef const char CHAR_MIN, CHAR_MAX
@@ -51,10 +38,7 @@ from sys import exc_info
5138

5239
cdef object Mapping
5340
cdef object Sequence
54-
try:
55-
from collections.abc import Mapping, Sequence
56-
except ImportError:
57-
from collections import Mapping, Sequence # Py2
41+
from collections.abc import Mapping, Sequence
5842

5943
cdef object wraps
6044
from functools import wraps
@@ -75,12 +59,6 @@ DEF POBJECT = b"POBJECT" # as used by LunaticPython
7559
DEF LUPAOFH = b"LUPA_NUMBER_OVERFLOW_CALLBACK_FUNCTION"
7660
DEF PYREFST = b"LUPA_PYTHON_REFERENCES_TABLE"
7761

78-
cdef extern from *:
79-
"""
80-
#define IS_PY2 (PY_MAJOR_VERSION == 2)
81-
"""
82-
int IS_PY2
83-
8462
cdef enum WrappedObjectFlags:
8563
# flags that determine the behaviour of a wrapped object:
8664
OBJ_AS_INDEX = 1 # prefers the getitem protocol (over getattr)
@@ -165,7 +143,7 @@ def lua_type(obj):
165143
return 'userdata'
166144
else:
167145
lua_type_name = lua.lua_typename(L, ltype)
168-
return lua_type_name if IS_PY2 else lua_type_name.decode('ascii')
146+
return lua_type_name.decode('ascii')
169147
finally:
170148
lua.lua_settop(L, old_top)
171149
unlock_runtime(lua_object._runtime)
@@ -235,7 +213,7 @@ cdef class LuaRuntime:
235213
Normally, it should return the now well-behaved object that can be
236214
converted/wrapped to a Lua type. If the object cannot be precisely
237215
represented in Lua, it should raise an ``OverflowError``.
238-
216+
239217
* ``max_memory``: max memory usage this LuaRuntime can use in bytes.
240218
If max_memory is None, the default lua allocator is used and calls to
241219
``set_max_memory(limit)`` will fail with a ``LuaMemoryError``.
@@ -656,20 +634,20 @@ cdef class LuaRuntime:
656634
luaL_openlib(L, "python", py_lib, 0) # lib
657635
lua.lua_pushlightuserdata(L, <void*>self) # lib udata
658636
lua.lua_pushcclosure(L, py_args, 1) # lib function
659-
lua.lua_setfield(L, -2, "args") # lib
637+
lua.lua_setfield(L, -2, "args") # lib
660638

661639
# register our own object metatable
662640
lua.luaL_newmetatable(L, POBJECT) # lib metatbl
663641
luaL_openlib(L, NULL, py_object_lib, 0)
664-
lua.lua_pop(L, 1) # lib
642+
lua.lua_pop(L, 1) # lib
665643

666644
# create and store the python references table
667645
lua.lua_newtable(L) # lib tbl
668646
lua.lua_createtable(L, 0, 1) # lib tbl metatbl
669647
lua.lua_pushlstring(L, "v", 1) # lib tbl metatbl "v"
670648
lua.lua_setfield(L, -2, "__mode") # lib tbl metatbl
671649
lua.lua_setmetatable(L, -2) # lib tbl
672-
lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, PYREFST) # lib
650+
lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, PYREFST) # lib
673651

674652
# register global names in the module
675653
self.register_py_object(b'Py_None', b'none', None)
@@ -818,17 +796,14 @@ cdef tuple unpack_lua_table(LuaRuntime runtime, lua_State* L):
818796
while lua.lua_next(L, -2): # key value
819797
key = py_from_lua(runtime, L, -2)
820798
value = py_from_lua(runtime, L, -1)
821-
if isinstance(key, (int, long)) and not isinstance(key, bool):
799+
if isinstance(key, int) and not isinstance(key, bool):
822800
index = <Py_ssize_t>key
823801
if index < 1 or index > length:
824802
raise IndexError("table index out of range")
825803
cpython.ref.Py_INCREF(value)
826804
cpython.tuple.PyTuple_SET_ITEM(args, index-1, value)
827805
elif isinstance(key, bytes):
828-
if IS_PY2:
829-
kwargs[key] = value
830-
else:
831-
kwargs[(<bytes>key).decode(source_encoding)] = value
806+
kwargs[(<bytes>key).decode(source_encoding)] = value
832807
elif isinstance(key, unicode):
833808
kwargs[key] = value
834809
else:
@@ -1508,21 +1483,14 @@ cdef object py_from_lua(LuaRuntime runtime, lua_State *L, int n):
15081483
elif lua_type == lua.LUA_TNUMBER:
15091484
if lua.LUA_VERSION_NUM >= 503:
15101485
if lua.lua_isinteger(L, n):
1511-
integer = lua.lua_tointeger(L, n)
1512-
if IS_PY2 and (sizeof(lua.lua_Integer) <= sizeof(long) or LONG_MIN <= integer <= LONG_MAX):
1513-
return <long>integer
1514-
else:
1515-
return integer
1486+
return lua.lua_tointeger(L, n)
15161487
else:
15171488
return lua.lua_tonumber(L, n)
15181489
else:
15191490
number = lua.lua_tonumber(L, n)
15201491
integer = <lua.lua_Integer>number
15211492
if number == integer:
1522-
if IS_PY2 and (sizeof(lua.lua_Integer) <= sizeof(long) or LONG_MIN <= integer <= LONG_MAX):
1523-
return <long>integer
1524-
else:
1525-
return integer
1493+
return integer
15261494
else:
15271495
return number
15281496
elif lua_type == lua.LUA_TSTRING:
@@ -1632,7 +1600,7 @@ cdef int py_to_lua(LuaRuntime runtime, lua_State *L, object o, bint wrap_none=Fa
16321600
elif type(o) is float:
16331601
lua.lua_pushnumber(L, <lua.lua_Number>cpython.float.PyFloat_AS_DOUBLE(o))
16341602
pushed_values_count = 1
1635-
elif isinstance(o, (long, int)):
1603+
elif isinstance(o, int):
16361604
try:
16371605
lua.lua_pushinteger(L, <lua.lua_Integer>o)
16381606
pushed_values_count = 1
@@ -2013,7 +1981,7 @@ cdef void* _lua_alloc_restricted(void* ud, void* ptr, size_t old_size, size_t ne
20131981
return NULL
20141982
elif new_size == old_size:
20151983
return ptr
2016-
1984+
20171985
if memory_status.limit > 0 and new_size > old_size and memory_status.limit <= memory_status.used + new_size - old_size: # reached the limit
20181986
# print("REACHED LIMIT")
20191987
return NULL
@@ -2085,7 +2053,7 @@ cdef int py_object_gc_with_gil(py_object *py_obj, lua_State* L) noexcept with gi
20852053
return 0
20862054
finally:
20872055
py_obj.obj = NULL
2088-
2056+
20892057
cdef int py_object_gc(lua_State* L) noexcept nogil:
20902058
if not lua.lua_isuserdata(L, 1):
20912059
return 0

lupa/lock.pxi

-10
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22
from cpython cimport pythread
33

44
cdef extern from *:
5-
# Compatibility definitions for Python
65
"""
7-
#if PY_VERSION_HEX >= 0x030700a2
86
typedef unsigned long pythread_t;
9-
#else
10-
typedef long pythread_t;
11-
#endif
127
"""
13-
14-
# Just let Cython understand that pythread_t is
15-
# a long type, but be aware that it is actually
16-
# signed for versions of Python prior to 3.7.0a2 and
17-
# unsigned for later versions
188
ctypedef unsigned long pythread_t
199

2010

0 commit comments

Comments
 (0)