From b8d5dcbd81593c18e6ed6bd7ed47fee0077cf8bc Mon Sep 17 00:00:00 2001 From: Thanatos Date: Wed, 3 Jan 2024 20:56:03 +0100 Subject: [PATCH] Workflow update --- .github/workflows/ci.yml | 201 ++++------ .github/workflows/wheels.yml | 405 ++++++++++---------- .gitignore | 4 +- .gitmodules | 15 - MANIFEST.in | 3 +- Makefile | 22 +- README.rst | 15 +- {lupa => randovania_lupa}/__init__.py | 2 +- {lupa => randovania_lupa}/_lupa.pyx | 2 +- {lupa => randovania_lupa}/lock.pxi | 0 {lupa => randovania_lupa}/luaapi.pxd | 6 +- {lupa => randovania_lupa}/tests/__init__.py | 10 +- {lupa => randovania_lupa}/tests/test.py | 28 +- setup.py | 37 +- tox.ini | 7 - 15 files changed, 337 insertions(+), 420 deletions(-) delete mode 100644 .gitmodules rename {lupa => randovania_lupa}/__init__.py (98%) rename {lupa => randovania_lupa}/_lupa.pyx (99%) rename {lupa => randovania_lupa}/lock.pxi (100%) rename {lupa => randovania_lupa}/luaapi.pxd (99%) rename {lupa => randovania_lupa}/tests/__init__.py (93%) rename {lupa => randovania_lupa}/tests/test.py (99%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7136b514..3c1b6574 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,133 +1,68 @@ -# name: Continuous Integration - -# on: [push, pull_request] - -# jobs: -# build: - -# strategy: -# # Allows for matrix sub-jobs to fail without canceling the rest -# fail-fast: false - -# matrix: -# os: -# - windows-2019 -# - ubuntu-20.04 -# - macos-11 -# - macos-latest -# python-version: -# - "2.7" -# - "3.12" -# - "3.11" -# - "3.10" -# - "3.9" -# - "3.8" -# - "3.7" -# - "3.6" -# - "pypy-2.7" -# - "pypy-3.7" -# - "pypy-3.8" -# - "pypy-3.9" -# - "pypy-3.10" -# lua-version: -# - "bundle" -# - "lua5.3" -# - "lua5.2" -# - "luajit-5.1" - -# exclude: -# - os: windows-2019 -# python-version: 2.7 -# - os: windows-2019 -# python-version: pypy-2.7 -# - os: windows-2019 -# lua-version: lua5.2 -# - 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-latest -# python-version: 2.7 -# - os: macos-latest -# lua-version: lua5.2 -# - os: macos-latest -# lua-version: lua5.3 -# - os: macos-latest -# lua-version: lua5.4 -# - os: macos-latest -# 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: "11.0" -# LUPA_WITH_LUA_DLOPEN: ${{ startsWith(matrix.os, 'windows') && 'false' || 'true' }} - -# steps: -# - uses: actions/checkout@v3 - -# - name: Check out recursively -# run: git submodule update --init --recursive - -# - name: Set up Python ${{ matrix.python-version }} -# if: ${{ !startsWith(matrix.os, 'ubuntu') || startsWith(matrix.python-version, '3.') || startsWith(matrix.python-version, 'pypy') }} -# uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.python-version }} - -# - name: Set up Python2 (Linux) -# if: ${{ matrix.python-version == '2.7' && startsWith(matrix.os, 'ubuntu') }} -# run: | -# sudo ln -fs python2 /usr/bin/python -# sudo apt-get update -# sudo apt-get install python-setuptools python2.7 python2.7-dev -# curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py -# sudo python2 get-pip.py -# ls -l /usr/bin/pip* /usr/local/bin/pip* -# which pip - -# - name: Set up Python packages -# run: | -# python -m pip install -U ${{ startsWith(matrix.python-version, '2.7') && '"pip<21" "setuptools<45"' || 'pip setuptools' }} -# python -m pip install -U wheel 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 setup.py sdist ${{ contains(matrix.python-version, '3.') && 'build_ext -j6' || '' }} bdist_wheel -# env: -# SETUP_OPTIONS: ${{ !contains(matrix.lua-version, 'luajit') && (contains(matrix.lua-version, 'bundle') && '--use-bundle' || '--no-luajit') || '' }} -# 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 }} ${{ env.CFLAGS_LTO }} -# LDFLAGS: ${{ env.CFLAGS_LTO }} - -# - name: Upload wheels -# if: ${{ contains(matrix.lua-version, 'bundle') }} -# uses: actions/upload-artifact@v3 -# with: -# name: wheels-${{ runner.os }} -# path: dist/*.whl -# if-no-files-found: ignore +name: Continuous Integration + +on: [push, pull_request] + +jobs: + build: + + strategy: + # Allows for matrix sub-jobs to fail without canceling the rest + fail-fast: false + + matrix: + os: + - windows-latest + - ubuntu-latest + # - macos-11 + - macos-latest + python-version: + - "3.10" + - "3.11" + - "3.12" + lua-version: + - "bundle" + + # exclude: + + 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: "11.0" + LUPA_WITH_LUA_DLOPEN: ${{ startsWith(matrix.os, 'windows') && 'false' || 'true' }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + if: ${{ !startsWith(matrix.os, 'ubuntu') || startsWith(matrix.python-version, '3.') || startsWith(matrix.python-version, 'pypy') }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up Python packages + run: | + python -m pip install -U pip setuptools + python -m pip install -U wheel tox virtualenv -r requirements.txt + - name: Build wheel + run: python setup.py sdist ${{ contains(matrix.python-version, '3.') && 'build_ext -j6' || '' }} bdist_wheel + env: + SETUP_OPTIONS: --use-bundle --no-luajit + CFLAGS: ${{ env.CFLAGS }} ${{ env.CFLAGS_LTO }} + LDFLAGS: ${{ env.CFLAGS_LTO }} + + - name: Run tests + run: python setup.py test + env: + SETUP_OPTIONS: --use-bundle --no-luajit + CFLAGS: ${{ env.CFLAGS }} ${{ env.CFLAGS_LTO }} + LDFLAGS: ${{ env.CFLAGS_LTO }} + + - name: Upload wheels + if: ${{ contains(matrix.lua-version, 'bundle') }} + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.python-version }}-${{ matrix.os }} + path: dist/*.whl + if-no-files-found: ignore diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 919249f5..3a5cb1ce 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,201 +1,204 @@ -# name: Wheel build - -# on: -# release: -# types: [created] -# workflow_dispatch: - -# concurrency: -# group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} -# cancel-in-progress: true - -# permissions: -# contents: write # to create GitHub release (softprops/action-gh-release) - -# jobs: -# sdist: -# runs-on: ubuntu-20.04 - -# steps: -# - uses: actions/checkout@v3 - -# - name: Check out recursively -# run: git submodule update --init --recursive - -# - name: Set up Python -# uses: actions/setup-python@v4 -# with: -# python-version: 3.9 - -# - name: Install Python dependencies -# run: python -m pip install -r requirements.txt - -# - name: Build sdist -# run: make sdist - -# - name: Release -# uses: softprops/action-gh-release@v1 -# if: startsWith(github.ref, 'refs/tags/') -# with: -# files: dist/*.tar.gz - -# - name: Upload sdist -# uses: actions/upload-artifact@v3 -# with: -# name: sdist -# path: dist/*.tar.gz - -# Linux: -# runs-on: ubuntu-latest - -# strategy: -# # Allows for matrix sub-jobs to fail without canceling the rest -# fail-fast: false - -# matrix: -# image: -# - manylinux2014_x86_64 -# - manylinux2014_i686 -# - manylinux_2_28_x86_64 -# - manylinux_2_24_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: ["*"] - -# include: -# - image: manylinux2014_aarch64 -# pyversion: "cp36*" -# - image: manylinux_2_24_aarch64 -# pyversion: "cp37*" -# - image: manylinux_2_24_aarch64 -# pyversion: "cp38*" -# - image: manylinux_2_28_aarch64 -# pyversion: "cp39*" -# - image: manylinux_2_28_aarch64 -# pyversion: "cp310*" -# - image: manylinux_2_28_aarch64 -# pyversion: "cp311*" -# - image: manylinux_2_28_aarch64 -# pyversion: "cp312*" - -# - 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*" -# - image: musllinux_1_1_aarch64 -# pyversion: "cp311*" -# - image: musllinux_1_1_aarch64 -# pyversion: "cp312*" - -# steps: -# - uses: actions/checkout@v3 - -# - name: Check out recursively -# run: git submodule update --init --recursive - -# - name: Set up Python -# uses: actions/setup-python@v4 -# with: -# python-version: 3.9 - -# - name: Install dependencies -# run: python -m pip install -r requirements.txt - -# - name: Build Linux wheels -# run: make USE_BUNDLE=true sdist wheel_${{ matrix.image }} -# env: { PYTHON_BUILD_VERSION: "${{ matrix.pyversion }}" } - -# - name: Release -# uses: softprops/action-gh-release@v1 -# if: startsWith(github.ref, 'refs/tags/') -# with: -# files: wheelhouse_*/*-m*linux*.whl # manylinux / musllinux - -# - name: Upload wheels -# uses: actions/upload-artifact@v3 -# with: -# name: wheels-${{ matrix.image }} -# path: wheelhouse_*/*-m*linux*.whl # manylinux / musllinux -# if-no-files-found: ignore - -# non-Linux: -# strategy: -# # Allows for matrix sub-jobs to fail without canceling the rest -# fail-fast: false - -# matrix: -# os: -# - macos-latest -# - windows-latest -# #os: [macos-11, windows-latest, macOS-M1] -# #os: [macos-11, macOS-M1] -# #os: [macos-11] -# pyversion: -# - "2.7" -# - "3.6" -# - "3.7" -# - "3.8" -# - "3.9" -# - "3.10" -# - "3.11" -# - "3.12" -# - "pypy-3.7-v7.3.7" -# - "pypy-3.8-v7.3.7" -# - "pypy-3.9-v7.3.11" -# - "pypy-3.10-v7.3.13" - -# exclude: -# # outdated compilers and probably not worth supporting anymore -# - os: windows-latest -# pyversion: 2.7 - -# runs-on: ${{ matrix.os }} -# env: -# MACOSX_DEPLOYMENT_TARGET: 11.0 -# LUPA_WITH_LUA_DLOPEN: ${{ startsWith(matrix.os, 'windows') && 'false' || 'true' }} - -# steps: -# - uses: actions/checkout@v3 - -# - name: Check out recursively -# run: git submodule update --init --recursive - -# - name: Set up Python -# uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.pyversion }} - -# - name: Install MacOS dependencies -# if: startsWith(matrix.os, 'mac') -# run: | -# brew install automake libtool -# ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize - -# - name: Install dependencies -# run: python -m pip install setuptools wheel -r requirements.txt - -# - name: Build wheels -# run: | -# set USE_BUNDLE=true -# python setup.py --with-cython sdist ${{ contains(matrix.pyversion, '3.') && 'build_ext -j6' || '' }} bdist_wheel - -# - name: Release -# uses: softprops/action-gh-release@v1 -# if: startsWith(github.ref, 'refs/tags/') -# with: -# files: dist/*.whl - -# - name: Upload wheels -# uses: actions/upload-artifact@v3 -# with: -# name: wheels-${{ matrix.os }} -# path: dist/*.whl -# if-no-files-found: ignore +name: Wheel build + +on: + release: + types: [created] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: write # to create GitHub release (softprops/action-gh-release) + +jobs: + sdist: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install Python dependencies + run: python -m pip install -r requirements.txt + + - name: Build sdist + run: make sdist + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: dist/*.tar.gz + + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: sdist + path: dist/*.tar.gz + + Linux: + runs-on: ubuntu-latest + + strategy: + # Allows for matrix sub-jobs to fail without canceling the rest + fail-fast: false + + matrix: + image: + # - manylinux2014_x86_64 + # - manylinux2014_i686 + - manylinux_2_28_x86_64 + # - manylinux_2_24_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: ["cp310-cp310", "cp311-cp311", "cp312-cp312"] + + #include: + # - image: manylinux_2_28_aarch64 + # pyversion: "cp311*" + # - image: manylinux_2_28_aarch64 + # pyversion: "cp312*" + + # - image: musllinux_1_1_aarch64 + # pyversion: "cp311*" + # - image: musllinux_1_1_aarch64 + # pyversion: "cp312*" + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install dependencies + run: python -m pip install -r requirements.txt + + - name: Build Linux wheels + run: make USE_BUNDLE=true sdist wheel_${{ matrix.image }} + env: { PYTHON_BUILD_VERSION: "${{ matrix.pyversion }}" } + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: wheelhouse_*/*-m*linux*.whl # manylinux / musllinux + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.image }}-${{ matrix.pyversion }} + path: wheelhouse_${{ matrix.image}}/*-m*linux*.whl + if-no-files-found: ignore + + non-Linux: + strategy: + # Allows for matrix sub-jobs to fail without canceling the rest + fail-fast: false + + matrix: + os: + - macos-latest + - windows-latest + pyversion: + - "3.10" + - "3.11" + - "3.12" + + runs-on: ${{ matrix.os }} + env: + MACOSX_DEPLOYMENT_TARGET: 11.0 + LUPA_WITH_LUA_DLOPEN: ${{ startsWith(matrix.os, 'windows') && 'false' || 'true' }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.pyversion }} + + - name: Install MacOS dependencies + if: startsWith(matrix.os, 'mac') + run: | + brew install automake libtool + ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize + + - name: Install dependencies + run: python -m pip install setuptools wheel -r requirements.txt + + - name: Build wheels + run: | + set USE_BUNDLE=true + python setup.py --with-cython sdist ${{ contains(matrix.pyversion, '3.') && 'build_ext -j6' || '' }} bdist_wheel + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: dist/*.whl + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }}-${{ matrix.pyversion }} + path: dist/*.whl + if-no-files-found: ignore + + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + needs: + - Linux + - non-Linux + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/randovania-lupa + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + # publish-to-testpypi: + # name: Publish Python 🐍 distribution 📦 to TestPyPI + # needs: + # - Linux + # - non-Linux + # runs-on: ubuntu-latest + + # environment: + # name: testpypi + # url: https://test.pypi.org/p/randovania-lupa + + # permissions: + # id-token: write # IMPORTANT: mandatory for trusted publishing + + # steps: + # - name: Download all the dists + # uses: actions/download-artifact@v4 + # with: + # merge-multiple: true + # path: dist/ + # - name: Publish distribution 📦 to TestPyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # repository-url: https://test.pypi.org/legacy/ diff --git a/.gitignore b/.gitignore index 3ab8a74f..07262695 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,8 @@ MANIFEST *.c *.patch wheel*/ -lupa/version.py -lupa/lua*.pyx +randovania_lupa/version.py +randovania_lupa/lua*.pyx # Vim swapfiles *.swp diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 38d012bc..00000000 --- a/.gitmodules +++ /dev/null @@ -1,15 +0,0 @@ -[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/lua52"] - path = third-party/lua52 - url = https://github.com/lua/lua.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 diff --git a/MANIFEST.in b/MANIFEST.in index 2791b84a..1560d9c6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include MANIFEST.in include CHANGES.rst INSTALL.rst LICENSE.txt README.rst include logo/logo-220x200.png -recursive-include lupa *.py *.pyx *.pxd *.pxi *.c +include requirements.txt +recursive-include randovania_lupa *.py *.pyx *.pxd *.pxi *.c recursive-include third-party * diff --git a/Makefile b/Makefile index 85d819e5..616da95a 100644 --- a/Makefile +++ b/Makefile @@ -25,18 +25,18 @@ all: local local: LUPA_WITH_LUA_DLOPEN=$(WITH_LUA_DLOPEN) ${PYTHON} setup.py build_ext --inplace $(WITH_CYTHON) -sdist dist/lupa-$(VERSION).tar.gz: +sdist dist/randovania-lupa-$(VERSION).tar.gz: ${PYTHON} setup.py sdist test: local - PYTHONPATH=. $(PYTHON) -m unittest lupa.tests.test + PYTHONPATH=. $(PYTHON) -m unittest randovania_lupa.tests.test clean: - rm -fr build lupa/_lupa*.so lupa/lua*.pyx lupa/*.c + rm -fr build randovania_lupa/_lupa*.so randovania_lupa/lua*.pyx lupa/*.c @for dir in third-party/*/; do $(MAKE) -C $${dir} clean; done realclean: clean - rm -fr lupa/_lupa.c + rm -fr randovania_lupa/_lupa.c wheel: LUPA_WITH_LUA_DLOPEN=$(WITH_LUA_DLOPEN) $(PYTHON) setup.py bdist_wheel $(WITH_CYTHON) @@ -47,8 +47,8 @@ qemu-user-static: wheel_manylinux: $(addprefix wheel_,$(MANYLINUX_IMAGES)) $(addprefix wheel_,$(filter-out %_x86_64, $(filter-out %_i686, $(MANYLINUX_IMAGES)))): qemu-user-static -wheel_%: dist/lupa-$(VERSION).tar.gz - @echo "Building $(subst wheel_,,$@) wheels for Lupa $(VERSION)" +wheel_%: dist/randovania-lupa-$(VERSION).tar.gz + @echo "Building $(subst wheel_,,$@) wheels for Randovania-Lupa $(VERSION)" mkdir -p wheelhouse_$(subst wheel_,,$@) time docker run --rm -t \ -v $(shell pwd):/io \ @@ -67,10 +67,10 @@ wheel_%: dist/lupa-$(VERSION).tar.gz $$PYBIN/python -V; \ { time $$PYBIN/pip wheel -v -w /io/$$WHEELHOUSE /io/$< & } ; \ done; wait; \ - for whl in /io/$$WHEELHOUSE/lupa-$(VERSION)-*-linux_*.whl; do auditwheel repair $$whl -w /io/$$WHEELHOUSE; done; \ - for whl in /io/$$WHEELHOUSE/lupa-$(VERSION)-*-m*linux*.whl; do \ - pyver=$${whl#*/lupa-$(VERSION)-}; pyver=$${pyver%%-m*}; \ + for whl in /io/$$WHEELHOUSE/randovania_lupa-$(VERSION)-*-linux_*.whl; do auditwheel repair $$whl -w /io/$$WHEELHOUSE; done; \ + for whl in /io/$$WHEELHOUSE/randovania_lupa-$(VERSION)-*-m*linux*.whl; do \ + pyver=$${whl#*/randovania_lupa-$(VERSION)-}; pyver=$${pyver%%-m*}; \ echo "Installing in $${pyver}: $${whl}"; \ - /opt/python/$${pyver}/bin/python -m pip install -U $${whl} && /opt/python/$${pyver}/bin/python -c "import lupa" || exit 1; \ - /opt/python/$${pyver}/bin/python -m pip uninstall -y lupa; \ + /opt/python/$${pyver}/bin/python -m pip install -U $${whl} && /opt/python/$${pyver}/bin/python -c "import randovania_lupa" || exit 1; \ + /opt/python/$${pyver}/bin/python -m pip uninstall -y randovania-lupa; \ done; true' diff --git a/README.rst b/README.rst index 40ec9a0c..9852b2c7 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,12 @@ +Randovania-Lupa +=============== + +This is a fork of Lupa https://github.com/scoder/lupa + +Intended to be used with Randovania projects. + +See the following for the original Readme and authorship. (Slightly modified to pass doctest) + Lupa ==== @@ -119,8 +128,8 @@ Examples .. code:: python - >>> import lupa - >>> from lupa import LuaRuntime + >>> import randovania_lupa as lupa + >>> from randovania_lupa import LuaRuntime >>> lua = LuaRuntime(unpack_returned_tuples=True) >>> lua.eval('1+1') @@ -800,7 +809,7 @@ implementation`_ for the `Computer Language Benchmarks Game`_. image_size = 1280 # == 1280 x 1280 thread_count = 8 - from lupa import LuaRuntime + from randovania_lupa import LuaRuntime lua_funcs = [ LuaRuntime(encoding=None).eval(lua_code) for _ in range(thread_count) ] diff --git a/lupa/__init__.py b/randovania_lupa/__init__.py similarity index 98% rename from lupa/__init__.py rename to randovania_lupa/__init__.py index 7b05b6e8..98dcb684 100644 --- a/lupa/__init__.py +++ b/randovania_lupa/__init__.py @@ -103,6 +103,6 @@ def __getattr__(name): del sys try: - from lupa.version import __version__ + from randovania_lupa.version import __version__ except ImportError: pass diff --git a/lupa/_lupa.pyx b/randovania_lupa/_lupa.pyx similarity index 99% rename from lupa/_lupa.pyx rename to randovania_lupa/_lupa.pyx index 25e5b30f..47527d11 100644 --- a/lupa/_lupa.pyx +++ b/randovania_lupa/_lupa.pyx @@ -239,7 +239,7 @@ cdef class LuaRuntime: Example usage:: - >>> from lupa import LuaRuntime + >>> from randovania_lupa import LuaRuntime >>> lua = LuaRuntime() >>> lua.eval('1+1') diff --git a/lupa/lock.pxi b/randovania_lupa/lock.pxi similarity index 100% rename from lupa/lock.pxi rename to randovania_lupa/lock.pxi diff --git a/lupa/luaapi.pxd b/randovania_lupa/luaapi.pxd similarity index 99% rename from lupa/luaapi.pxd rename to randovania_lupa/luaapi.pxd index 58f956f7..39c4d0c7 100644 --- a/lupa/luaapi.pxd +++ b/randovania_lupa/luaapi.pxd @@ -148,7 +148,6 @@ cdef extern from "lua.h" nogil: char *chunkname) int lua_dump (lua_State *L, lua_Writer writer, void *data) - int luaU_dump (lua_State *L, const Proto* f, lua_Writer writer, void *data, int strip) # coroutine functions int lua_yield (lua_State *L, int nresults) @@ -273,7 +272,7 @@ cdef extern from "lua.h" nogil: cdef extern from "lstate.h" nogil: cppclass Proto: pass - + ctypedef struct LClosure: Proto* p @@ -297,6 +296,9 @@ cdef extern from "lstate.h" nogil: cdef extern from "lobject.h": Closure* clvalue(TValue *o) # clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +cdef extern from "lundump.h" nogil: + int luaU_dump (lua_State *L, const Proto* f, lua_Writer writer, void *data, int strip) + ################################################################################ # lauxlib.h ################################################################################ diff --git a/lupa/tests/__init__.py b/randovania_lupa/tests/__init__.py similarity index 93% rename from lupa/tests/__init__.py rename to randovania_lupa/tests/__init__.py index 55b21148..5f728f1e 100644 --- a/lupa/tests/__init__.py +++ b/randovania_lupa/tests/__init__.py @@ -6,23 +6,23 @@ import os.path as os_path import sys -import lupa +import randovania_lupa class LupaTestCase(unittest.TestCase): """ Subclasses can use 'self.lupa' to get the test module, which build_suite_for_module() below will vary. """ - lupa = lupa + lupa = randovania_lupa def find_lua_modules(): - modules = [lupa] + modules = [randovania_lupa] imported = set() for filename in os.listdir(os.path.dirname(os.path.dirname(__file__))): if not filename.startswith('lua'): continue - module_name = "lupa." + filename.partition('.')[0] + module_name = "randovania_lupa." + filename.partition('.')[0] if module_name in imported: continue try: @@ -77,7 +77,7 @@ def suite(): tests = [] for filename in os.listdir(test_dir): if filename.endswith('.py') and not filename.startswith('_'): - tests.append('lupa.tests.' + filename[:-3]) + tests.append('randovania_lupa.tests.' + filename[:-3]) suite = unittest.defaultTestLoader.loadTestsFromNames(tests) diff --git a/lupa/tests/test.py b/randovania_lupa/tests/test.py similarity index 99% rename from lupa/tests/test.py rename to randovania_lupa/tests/test.py index cbb13580..83f811bc 100644 --- a/lupa/tests/test.py +++ b/randovania_lupa/tests/test.py @@ -10,9 +10,9 @@ import time import unittest -import lupa -import lupa.tests -from lupa.tests import LupaTestCase +import randovania_lupa +import randovania_lupa.tests +from randovania_lupa.tests import LupaTestCase try: import platform @@ -59,10 +59,10 @@ def _run_gc_test(self, run_test, off_by_one=False): if off_by_one and old_count == new_count + 1: # FIXME: This happens in test_attrgetter_refcycle - need to investigate why! self.assertEqual(old_count, new_count + 1) - elif off_by_one and old_count == new_count + 2 and ( + elif off_by_one and old_count == new_count + 3 and ( sys.version_info[:2] == (3,7) or sys.version_info >= (3,11)): # FIXME: This happens in test_attrgetter_refcycle - need to investigate why! - self.assertEqual(old_count, new_count + 2) + self.assertEqual(old_count, new_count + 3) else: self.assertEqual(old_count, new_count) @@ -2247,35 +2247,35 @@ def test_method_call_bound(self): # tests for the lupa.unpacks_lua_table and lupa.unpacks_lua_table_method # decorators -@lupa.unpacks_lua_table +@randovania_lupa.unpacks_lua_table def func_1(x): return ("x=%s" % (x, )) -@lupa.unpacks_lua_table +@randovania_lupa.unpacks_lua_table def func_2(x, y): return ("x=%s, y=%s" % (x, y)) -@lupa.unpacks_lua_table +@randovania_lupa.unpacks_lua_table def func_3(x, y, z='default'): return ("x=%s, y=%s, z=%s" % (x, y, z)) class MyCls_1(object): - @lupa.unpacks_lua_table_method + @randovania_lupa.unpacks_lua_table_method def meth(self, x): return ("x=%s" % (x,)) class MyCls_2(object): - @lupa.unpacks_lua_table_method + @randovania_lupa.unpacks_lua_table_method def meth(self, x, y): return ("x=%s, y=%s" % (x, y)) class MyCls_3(object): - @lupa.unpacks_lua_table_method + @randovania_lupa.unpacks_lua_table_method def meth(self, x, y, z='default'): return ("x=%s, y=%s, z=%s" % (x, y, z)) @@ -3096,14 +3096,14 @@ def test_set_max(self): # Load tests for different Lua version modules def load_tests(loader, standard_tests, pattern): - return lupa.tests.build_suite_for_modules(loader, globals()) + return randovania_lupa.tests.build_suite_for_modules(loader, globals()) if __name__ == '__main__': def print_version(): - version = lupa.LuaRuntime().lua_implementation - print('Running Lupa %s tests against %s.' % (lupa.__version__, version)) + version = randovania_lupa.LuaRuntime().lua_implementation + print('Running Lupa %s tests against %s.' % (randovania_lupa.__version__, version)) print_version() unittest.main() diff --git a/setup.py b/setup.py index 6f90e083..14310619 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ except ImportError: from distutils.core import setup, Extension -VERSION = '2.1' +VERSION = '2.0' extra_setup_args = {} @@ -29,7 +29,7 @@ # support 'test' target if setuptools/distribute is available if 'setuptools' in sys.modules: - extra_setup_args['test_suite'] = 'lupa.tests.suite' + extra_setup_args['test_suite'] = 'randovania_lupa.tests.suite' class PkgConfigError(RuntimeError): @@ -385,7 +385,7 @@ def prepare_extensions(use_cython=True): ext_libraries = [] for config in configs: ext_name = config.get('libversion', 'lua') - src, dst = os.path.join('lupa', '_lupa.pyx'), os.path.join('lupa', ext_name + '.pyx') + src, dst = os.path.join('randovania_lupa', '_lupa.pyx'), os.path.join('randovania_lupa', ext_name + '.pyx') if not os.path.exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src): with open(dst, 'wb') as f_out: f_out.write(b'####### DO NOT EDIT - BUILD TIME COPY OF "_lupa.pyx" #######\n\n') @@ -394,7 +394,7 @@ def prepare_extensions(use_cython=True): libs = config.get('ext_libraries') ext_modules.append(Extension( - 'lupa.' + ext_name, + 'randovania_lupa.' + ext_name, sources=[dst] + (libs[0][1]['sources'] if libs else []), extra_objects=config.get('extra_objects'), include_dirs=config.get('include_dirs'), @@ -402,7 +402,7 @@ def prepare_extensions(use_cython=True): )) if not use_cython: - if not os.path.exists(os.path.join(basedir, 'lupa', '_lupa.c')): + if not os.path.exists(os.path.join(basedir, 'randovania_lupa', '_lupa.c')): print("generated sources not available, need Cython to build") use_cython = True @@ -442,14 +442,14 @@ def write_file(filename, content): read_file(os.path.join(basedir, text_file)) for text_file in ['README.rst', 'INSTALL.rst', 'CHANGES.rst', "LICENSE.txt"]]) -write_file(os.path.join(basedir, 'lupa', 'version.py'), u"__version__ = '%s'\n" % VERSION) +write_file(os.path.join(basedir, 'randovania_lupa', 'version.py'), u"__version__ = '%s'\n" % VERSION) dll_files = [] for config in configs: if config.get('libfile'): # include Lua DLL in the lib folder if we are on Windows dll_file = os.path.splitext(config['libfile'])[0] + ".dll" - shutil.copy(dll_file, os.path.join(basedir, 'lupa')) + shutil.copy(dll_file, os.path.join(basedir, 'randovania_lupa')) dll_files.append(os.path.basename(dll_file)) if dll_files: @@ -463,15 +463,12 @@ def write_file(filename, content): # call distutils setup( - name="lupa", + name="randovania-lupa", version=VERSION, - author="Stefan Behnel", - author_email="stefan_ml@behnel.de", - maintainer="Lupa-dev mailing list", - maintainer_email="lupa-dev@freelists.org", - url="https://github.com/scoder/lupa", + author="Randovania", + url="https://github.com/randovania/randovania-lupa", - description="Python wrapper around Lua and LuaJIT", + description="Python wrapper around Lua for usage in Randovania projects", long_description=long_description, license='MIT style', @@ -481,14 +478,6 @@ def write_file(filename, content): 'Intended Audience :: Information Technology', 'License :: OSI Approved :: MIT License', 'Programming Language :: Cython', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - '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', @@ -498,9 +487,9 @@ def write_file(filename, content): 'Topic :: Software Development', ], - packages=['lupa'], + packages=['randovania_lupa'], setup_requires=[cython_dependency], ext_modules=ext_modules, libraries=ext_libraries, **extra_setup_args -) +) \ No newline at end of file diff --git a/tox.ini b/tox.ini index 2bd84e89..64db1902 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,5 @@ [tox] envlist= - py27, - py35, - py36, - py37, - py38, - py39, - py310, py311 [testenv]