Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
synodriver committed Aug 14, 2022
2 parents a2ebf1c + f63d7f8 commit b9bc4a7
Show file tree
Hide file tree
Showing 16 changed files with 633 additions and 315 deletions.
38 changes: 27 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
fail-fast: false

matrix:
os: [windows-2019, ubuntu-18.04, macos-10.15]
python-version: ["2.7", "3.10", "3.9", "3.8", "3.7", "3.6", "3.5", "pypy-2.7", "pypy-3.7", "pypy-3.8"]
lua-version: ["bundle", "lua5.2", "lua5.3", "luajit-5.1"]
os: [windows-2019, ubuntu-20.04, macos-11, macos-12]
python-version: ["2.7", "3.10", "3.9", "3.8", "3.7", "3.6", "pypy-2.7", "pypy-3.7", "pypy-3.8"]
lua-version: ["bundle", "lua5.3", "lua5.2", "luajit-5.1"]

exclude:
- os: windows-2019
Expand All @@ -24,20 +24,36 @@ jobs:
- os: windows-2019
lua-version: lua5.3
- os: windows-2019
lua-version: lua5.4
- os: windows-2019
lua-version: luajit-5.1
- os: macos-11
python-version: 2.7
- os: macos-11
lua-version: lua5.2
- os: macos-11
lua-version: lua5.3
- os: macos-11
lua-version: lua5.4
- os: macos-11
lua-version: luajit-5.1
- os: macos-10.15
- os: macos-12
python-version: 2.7
- os: macos-10.15
- os: macos-12
lua-version: lua5.2
- os: macos-10.15
- os: macos-12
lua-version: lua5.3
- os: macos-10.15
- os: macos-12
lua-version: lua5.4
- os: macos-12
lua-version: luajit-5.1

runs-on: ${{ matrix.os }}

env:
CFLAGS_LTO: ${{ contains(matrix.lua-version, 'bundle') && (contains(matrix.os, 'windows') && '/LTCG' || '-flto') || '' }}
CFLAGS: ${{ contains(matrix.os, 'windows') && '/O2' || '-O2 -fPIC' }} -g
MACOSX_DEPLOYMENT_TARGET: "10.15"

steps:
- uses: actions/checkout@v2
Expand All @@ -51,25 +67,25 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Set up Python packages
run: python -m pip install -U "pip<21" "setuptools<45" wheel && python -m pip install -U tox virtualenv
run: python -m pip install -U "pip<21" "setuptools<45" wheel && python -m pip install -U tox virtualenv -r requirements.txt

- name: Set up Lua ${{ matrix.lua-version }}
if: ${{ contains(matrix.os, 'ubuntu') && !contains(matrix.lua-version, 'bundle') }}
run: sudo apt-get install lib${{ matrix.lua-version }}-dev

- name: Build wheel
run: python -m pip install -r requirements.txt && python setup.py sdist bdist_wheel
run: python setup.py sdist ${{ contains(matrix.python-version, '3.') && 'build_ext -j5' || '' }} bdist_wheel ${{ contains(matrix.os, 'macos-12') && '--universal' || '' }}
env:
SETUP_OPTIONS: ${{ !contains(matrix.lua-version, 'luajit') && (contains(matrix.lua-version, 'bundle') && '--use-bundle' || '--no-luajit') || '' }}
CFLAGS: ${{ env.CFLAGS_LTO }} -g
CFLAGS: ${{ env.CFLAGS }} ${{ env.CFLAGS_LTO }}
LDFLAGS: ${{ env.CFLAGS_LTO }}

- name: Run tests
run: python setup.py test
continue-on-error: ${{ contains(matrix.python-version, 'pypy') }}
env:
SETUP_OPTIONS: ${{ !contains(matrix.lua-version, 'luajit') && (contains(matrix.lua-version, 'bundle') && '--use-bundle' || '--no-luajit') || '' }}
CFLAGS: ${{ env.CFLAGS_LTO }} -g
CFLAGS: ${{ env.CFLAGS }} ${{ env.CFLAGS_LTO }}
LDFLAGS: ${{ env.CFLAGS_LTO }}

- name: Upload wheels
Expand Down
50 changes: 29 additions & 21 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,42 @@ jobs:

matrix:
image:
- manylinux1_x86_64
- manylinux1_i686
#- manylinux2010_x86_64
#- manylinux2010_i686
- manylinux_2_24_x86_64
- manylinux_2_24_i686
- manylinux_2_24_aarch64
- manylinux2014_x86_64
- manylinux2014_i686
- manylinux_2_28_x86_64
- manylinux_2_28_i686
- manylinux_2_28_aarch64
- musllinux_1_1_x86_64
- musllinux_1_1_aarch64
#- manylinux_2_24_ppc64le
#- manylinux_2_24_ppc64le
#- manylinux_2_24_s390x
pyversion: ["*"]

exclude:
- image: manylinux_2_24_aarch64
- image: manylinux_2_28_aarch64
pyversion: "*"
- image: musllinux_1_1_aarch64
pyversion: "*"
include:
- image: manylinux2014_aarch64
pyversion: "cp36*"
- image: manylinux_2_24_aarch64
- image: manylinux_2_28_aarch64
pyversion: "cp37*"
- image: manylinux_2_24_aarch64
- image: manylinux_2_28_aarch64
pyversion: "cp38*"
- image: manylinux_2_24_aarch64
- image: manylinux_2_28_aarch64
pyversion: "cp39*"
- image: manylinux_2_24_aarch64
- image: manylinux_2_28_aarch64
pyversion: "cp310*"

- image: musllinux_1_1_aarch64
pyversion: "cp37*"
- image: musllinux_1_1_aarch64
pyversion: "cp38*"
- image: musllinux_1_1_aarch64
pyversion: "cp39*"
- image: musllinux_1_1_aarch64
pyversion: "cp310*"

steps:
Expand Down Expand Up @@ -111,21 +121,19 @@ jobs:
fail-fast: false

matrix:
os: [macos-10.15, windows-latest]
#os: [macos-10.15, windows-latest, macOS-M1]
#os: [macos-10.15, macOS-M1]
#os: [macos-10.15]
python_version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7-v7.3.3", "pypy-3.8-v7.3.7"]
os: [macos-12, windows-latest]
#os: [macos-11, windows-latest, macOS-M1]
#os: [macos-11, macOS-M1]
#os: [macos-11]
python_version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7-v7.3.3", "pypy-3.8-v7.3.7"]

exclude:
# outdated compilers and probably not worth supporting anymore
- os: windows-latest
python_version: 2.7
- os: windows-latest
python_version: 3.5

runs-on: ${{ matrix.os }}
env: { MACOSX_DEPLOYMENT_TARGET: 10.14 }
env: { MACOSX_DEPLOYMENT_TARGET: 10.15 }

steps:
- uses: actions/checkout@v2
Expand All @@ -148,7 +156,7 @@ jobs:
run: python -m pip install setuptools wheel -r requirements.txt

- name: Build wheels
run: make USE_BUNDLE=true sdist wheel
run: USE_BUNDLE=true python setup.py --with-cython sdist ${{ contains(matrix.python-version, '3.') && 'build_ext -j5' || '' }} bdist_wheel ${{ contains(matrix.os, 'macos-12') && '--universal' || '' }}

- name: Release
uses: softprops/action-gh-release@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ MANIFEST
*.patch
wheel*/
lupa/version.py
lupa/lua*.pyx

# Vim swapfiles
*.swp
13 changes: 8 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[submodule "third-party/lua54"]
path = third-party/lua54
url = https://github.com/lua/lua.git
[submodule "third-party/lua53"]
path = third-party/lua53
url = https://github.com/lua/lua.git
[submodule "third-party/lua54"]
path = third-party/lua54
[submodule "third-party/lua52"]
path = third-party/lua52
url = https://github.com/lua/lua.git
[submodule "third-party/luajit20"]
path = third-party/luajit20
url = https://luajit.org/git/luajit.git
[submodule "third-party/luajit21"]
path = third-party/luajit21
url = https://luajit.org/git/luajit.git
[submodule "third-party/luajit20"]
path = third-party/luajit20
url = https://luajit.org/git/luajit.git
13 changes: 12 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ Lupa change log
2.0a1 (2022-??-??)
------------------

* GH#217: Lua stack traces in Python exception messages are now reversed to
match the order of Python stack traces.

* GH#196: Lupa now ships separate extension modules built with Lua 5.3,
Lua 5.4, LuaJIT 2.0 and LuaJIT 2.1 beta. Note that this is build specific
and may depend on the platform. A normal Python import cascade can be used.

* GH#171: Python references in Lua are now more safely reference counted
to prevent garbage collection glitches.
(patch by Guilherme Dantas)

* GH#146: Lua integers in Lua 5.3+ are converted from and to Python integers.
(patch by Guilherme Dantas)

* GH#180: The ``python.enumerate()`` function now returns indices as integers
if supported by Lua.
(patch by Guilherme Dantas)

* GH#178: The Lua integer limits can be read from the module as
``LUA_MAXINTEGER`` and ``LUA_MININTEGER``.
(patch by Guilherme Dantas)
Expand All @@ -26,7 +37,7 @@ Lupa change log
* GH#177: Tables that are not sequences raise ``IndexError`` when unpacking
them. Previously, non-sequential items were simply ignored.

* GH#165: Resolve some C compiler warnings about signed/unsigned comparisons.
* GH#179: Resolve some C compiler warnings about signed/unsigned comparisons.
(patch by Guilherme Dantas)


Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ MANYLINUX_IMAGES= \
manylinux_2_24_aarch64 \
manylinux_2_24_ppc64le \
manylinux_2_24_s390x \
musllinux_1_1_x86_64
musllinux_1_1_x86_64 \
musllinux_1_1_aarch64

.PHONY: all local sdist test clean realclean

Expand All @@ -26,10 +27,11 @@ sdist dist/lupa-$(VERSION).tar.gz:
${PYTHON} setup.py sdist

test: local
PYTHONPATH=. $(PYTHON) -m lupa.tests.test
PYTHONPATH=. $(PYTHON) -m unittest lupa.tests.test

clean:
rm -fr build lupa/_lupa.so
rm -fr build lupa/_lupa*.so lupa/lua*.pyx lupa/*.c
@for dir in third-party/*/; do $(MAKE) -C $${dir} clean; done

realclean: clean
rm -fr lupa/_lupa.c
Expand Down
29 changes: 27 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Major features

* tested with Python 2.7/3.5 and later

* written for LuaJIT2 (tested with LuaJIT 2.0.2), but also works
with the normal Lua interpreter (5.1 and later)
* ships with Lua 5.3 and 5.4 (works with Lua 5.1 and later)
as well as LuaJIT 2.0 and 2.1 on systems that support it.

* easy to hack on and extend as it is written in Cython, not C

Expand Down Expand Up @@ -80,6 +80,31 @@ switching between the two languages at runtime, based on the tradeoff
between simplicity and speed.


Which Lua version?
------------------

The binary wheels include different Lua versions as well as LuaJIT, if supported.
By default, ``import lupa`` uses the latest Lua version, but you can choose
a specific one via import:

.. code:: python
try:
import lupa.luajit20 as lupa
except ImportError:
try:
import lupa.lua54 as lupa
except ImportError:
try:
import lupa.lua53 as lupa
except ImportError:
import lupa
print(f"Using {lupa.LuaRuntime().lua_implementation} (compiled with {lupa.LUA_VERSION})")
Note that LuaJIT 2.1 may also be included (as ``luajit21``) but is currently in Alpha state.


Examples
--------

Expand Down
9 changes: 5 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ image: Visual Studio 2019

environment:
matrix:
- python: 27
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- python: 27-x64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
# Disable Py27 builds since they run into certificate issues when retrieving the LuaJIT git submodule.
# - python: 27
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
# - python: 27-x64
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- python: 310
- python: 310-x64
- python: 39
Expand Down
49 changes: 47 additions & 2 deletions lupa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,54 @@ def _try_import_with_global_library_symbols():

del _try_import_with_global_library_symbols

# the following is all that should stay in the namespace:

from lupa._lupa import *
# Find the implementation with the latest Lua version available.
_newest_lib = None


def _import_newest_lib():
global _newest_lib
if _newest_lib is not None:
return _newest_lib

import os.path
import re

package_dir = os.path.dirname(__file__)
modules = [
match.groups() for match in (
re.match(r"((lua[a-z]*)([0-9]*))\..*", filename)
for filename in os.listdir(package_dir)
)
if match
]
if not modules:
raise RuntimeError("Failed to import Lupa binary module.")
# prefer Lua over LuaJIT and high versions over low versions.
module_name = max(modules, key=lambda m: (m[1] == 'lua', tuple(map(int, m[2] or '0'))))
_newest_lib = __import__(module_name[0], level=1, fromlist="*", globals=globals())

return _newest_lib


def __getattr__(name):
"""
Get a name from the latest available Lua (or LuaJIT) module.
Imports the module as needed.
"""
lua = _newest_lib if _newest_lib is not None else _import_newest_lib()
return getattr(lua, name)


import sys
if sys.version_info < (3, 7):
# Module level "__getattr__" requires Py3.7 or later => import latest Lua now
_import_newest_lib()
globals().update(
(name, getattr(_newest_lib, name))
for name in _newest_lib.__all__
)
del sys

try:
from lupa.version import __version__
Expand Down
Loading

0 comments on commit b9bc4a7

Please sign in to comment.