From 01e18f856d80c53e17002805d2e89d4eed1e1823 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 19 Jun 2026 06:35:57 +0200 Subject: [PATCH] luarocks --local make fails on macOS and Windows --- .github/workflows/ci.yml | 72 +++++++++++++++++++++++++++++++++++ Makefile.luarocks | 6 +++ lunatic-python-scm-0.rockspec | 3 +- setup.py | 10 ++--- 4 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f3d02a48 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: ci +on: + push: + pull_request: + workflow_dispatch: +jobs: + ci: + strategy: + fail-fast: false # https://github.com/actions/runner-images#available-images + matrix: # https://www.lua.org/versions.html + os: [ubuntu-latest, macos-latest, macos-26-intel] + runs-on: ${{ matrix.os }} + steps: + - run: echo "${{ runner.os }} on ${{ runner.arch }}" + - if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y luarocks + - if: runner.os == 'macOS' + run: brew install luarocks + - run: lua -v && luarocks --version # Lua 5.5.0 Luarocks 3.13.0 + + - uses: actions/checkout@v7 + - uses: actions/setup-python@v6 + with: + python-version: 3.x + pip-install: --editable . + - if: runner.os == 'macOS' && runner.arch == 'arm64' + # /opt/homebrew/opt/lua/lib --> /opt/homebrew/lib + run: luarocks config variables.LUA_LIBDIR "$HOMEBREW_PREFIX/lib" + - run: luarocks lint lunatic-python-scm-0.rockspec + - run: luarocks lint rockspecs/lunatic-python-1.0-1.rockspec + - env: + VERBOSE: 1 + run: luarocks --local make + - run: luarocks list + - run: luarocks show lunatic-python + + actions: + strategy: + fail-fast: false # https://github.com/actions/runner-images#available-images + matrix: # https://www.lua.org/versions.html + os: [macos-latest, macos-26-intel, ubuntu-latest] + gh-actions-lua: [leafo, luarocks] + runs-on: ${{ matrix.os }} + steps: + - run: echo "${{ runner.os }} on ${{ runner.arch }}" + - uses: actions/checkout@v7 + - uses: actions/setup-python@v6 + with: + python-version: 3.x + - if: matrix.gh-actions-lua == 'leafo' + uses: leafo/gh-actions-lua@v13 + with: + luaVersion: "5.1" + - if: matrix.gh-actions-lua == 'luarocks' + uses: luarocks/gh-actions-lua@master + with: + luaVersion: "5.1" + - if: matrix.gh-actions-lua == 'leafo' + uses: leafo/gh-actions-luarocks@v6 + - if: matrix.gh-actions-lua == 'luarocks' + uses: luarocks/gh-actions-luarocks@v6 + - run: lua -v && luarocks --version + - run: luarocks + - run: luarocks config + # [x] TODO: macOS: ld: unknown options: -shared --> LD = clang + # [ ] TODO: macOS: ld: symbol(s) not found for architecture arm64 + # - run: pip install --editable . + - env: + VERBOSE: 1 + run: luarocks --local make diff --git a/Makefile.luarocks b/Makefile.luarocks index b3238006..24194bc7 100644 --- a/Makefile.luarocks +++ b/Makefile.luarocks @@ -8,6 +8,7 @@ LIBEXT_S = .dll.a COPY = copy RM = del else ifeq ($(shell uname -s),Darwin) +LD = clang LIBEXT = .dylib LIBEXT_S = .a COPY = cp -v @@ -28,7 +29,12 @@ all: $(TARGET) $(TARGET_S) CFLAGS := -Isrc -fPIC $(shell python3-config --embed --cflags) -DPYTHON_LIBRT=$(shell pkg-config python3-embed --keep-system-libs --libs | sed -e 's/-L//g' -e 's/ -l/\/lib/g' | xargs echo -n)$(LIBEXT) -I$(LUA_INCDIR) +ifeq ($(shell uname -s),Darwin) +LDFLAGS := $(shell python3-config --embed --ldflags) $(if $(and $(LUA_LIBDIR_FILE),$(or $(LUA_LIBDIR),$(LUA_INCDIR))),$(or $(LUA_LIBDIR),$(patsubst %/include,%/lib,$(LUA_INCDIR)))/$(LUA_LIBDIR_FILE),$(if $(or $(LUA_LIBDIR),$(LUA_INCDIR)),-L$(or $(LUA_LIBDIR),$(patsubst %/include,%/lib,$(LUA_INCDIR))) -llua,)) +else LDFLAGS := $(shell python3-config --embed --ldflags) +endif + ARFLAGS = $(shell python3-config --configdir)/libpython*$(LIBEXT_S) OBJS := \ diff --git a/lunatic-python-scm-0.rockspec b/lunatic-python-scm-0.rockspec index 8626fa3a..d67535fc 100644 --- a/lunatic-python-scm-0.rockspec +++ b/lunatic-python-scm-0.rockspec @@ -13,6 +13,7 @@ build = { makefile = 'Makefile.luarocks', variables = { LIBDIR = '$(LIBDIR)', - LUA_INCDIR = '$(LUA_INCDIR)' + LUA_INCDIR = '$(LUA_INCDIR)', + LUA_LIBDIR = '$(LUA_LIBDIR)' } } diff --git a/setup.py b/setup.py index 93d6cf0f..1d60e2e1 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,9 @@ #!/usr/bin/python -import sys import os +import sys -if sys.version > '3': - PY3 = True -else: - PY3 = False +PY3 = sys.version_info >= (3, 0) if PY3: import subprocess as commands @@ -15,6 +12,9 @@ from distutils.core import setup, Extension from distutils.sysconfig import get_config_var, get_python_lib, get_python_version +if not os.environ.get("PKG_CONFIG_PATH"): # set this on macOS and Windows + os.environ["PKG_CONFIG_PATH"] = os.path.join(get_config_var("LIBDIR"), "pkgconfig") + if os.path.isfile("MANIFEST"): os.unlink("MANIFEST")