From 186e84c8c0f17c7c44f29d34a51598e6363f0b92 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Tue, 7 May 2024 16:20:02 -0400 Subject: [PATCH 01/19] add cibuildwheel stock github template update action name --- .github/workflows/build_wheels.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/build_wheels.yml diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 000000000..b69377a84 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,30 @@ +name: Build wheels + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.17.0 + # env: + # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl From 686e70d4e38442a960d3dd47c5a6ed56f0db9984 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Tue, 7 May 2024 11:11:34 -0400 Subject: [PATCH 02/19] replace setup.py with pyproject.toml want it to actually compile stuff want something top-level use all versions of scikit-build-core bump python required to build wheel scikit_build_core not available on older versions set -j4 don't include .pc files in wheel --- lcm-python/setup.py | 110 -------------------------------------------- pyproject.toml | 33 +++++++++++++ 2 files changed, 33 insertions(+), 110 deletions(-) delete mode 100644 lcm-python/setup.py create mode 100644 pyproject.toml diff --git a/lcm-python/setup.py b/lcm-python/setup.py deleted file mode 100644 index e015d2075..000000000 --- a/lcm-python/setup.py +++ /dev/null @@ -1,110 +0,0 @@ -import subprocess -from distutils.core import setup, Extension -from distutils import msvccompiler -import os -import sys - -sources = [ \ - "module.c", - "pyeventlog.c", - "pylcm.c", - "pylcm_subscription.c", - os.path.join("..", "lcm", "eventlog.c"), - os.path.join("..", "lcm", "lcm.c"), - os.path.join("..", "lcm", "lcm_file.c"), - os.path.join("..", "lcm", "lcm_memq.c"), - os.path.join("..", "lcm", "lcm_mpudpm.c"), - os.path.join("..", "lcm", "lcm_tcpq.c"), - os.path.join("..", "lcm", "lcmtypes", "channel_port_map_update_t.c"), - os.path.join("..", "lcm", "lcmtypes", "channel_to_port_t.c"), - os.path.join("..", "lcm", "lcm_udpm.c"), - os.path.join("..", "lcm", "ringbuffer.c"), - os.path.join("..", "lcm", "udpm_util.c") - ] - - -lcm_version_info = {} -with open(os.path.join("..", "lcm", "lcm_version.h"), 'r') as lcm_version_file: - for line in lcm_version_file: - if line.startswith('#define LCM_VERSION'): - parts = line.strip().split() - lcm_version_info[parts[1]] = parts[2] - -lcm_version = \ - '%(LCM_VERSION_MAJOR)s.%(LCM_VERSION_MINOR)s.%(LCM_VERSION_PATCH)s' \ - % lcm_version_info - -include_dirs = [".."] -define_macros = [('LCM_PYTHON','')] -library_dirs = [] -libraries = [] -extra_compile_args = [] - -if os.name == 'nt': - # check for GLIB_PATH environment var, exit with error if not found - glibPath = os.getenv('GLIB_PATH') - if not glibPath: - sys.exit('GLIB_PATH environment variable not set.') - - include_dirs += [ \ - os.path.join("..", "WinSpecific\include"), - os.path.join("..", "WinSpecific"), - os.path.join(glibPath, "include", "glib-2.0"), - os.path.join(glibPath, "lib", "glib-2.0", "include") ] - library_dirs.append(os.path.join(glibPath, 'lib')) - - # define additional macro WIN32, used to discriminate win specific code - define_macros += [('WIN32', 1)] - - libraries = [ 'Ws2_32', 'glib-2.0' ] - - # compiler arguments - # /TP enforces compilation of code as c++ - extra_compile_args = [ '/TP' ] - - # we need to patch the msvccompiler.MSVCCompiler class to compile - # .c C files as C++ code (/TP switch for MSVC) - # the default behaviour generates the command line switch /Tc for - # every .c source file - msvccompiler.MSVCCompiler._c_extensions = [] - msvccompiler.MSVCCompiler._cpp_extensions.append('.c') - - sources.append(os.path.join("..", "lcm", "windows", "WinPorting.cpp")) - -else: - pkg_deps = "glib-2.0" - - # detect terminal encoding. If the encoding is not detected, default to UTF-8 - encoding = sys.stdout.encoding or 'UTF-8' - - # include path - pkgconfig_include_flags = subprocess.check_output( ["pkg-config", "--cflags-only-I", pkg_deps] ).decode(encoding) - include_dirs += [ t[2:] for t in pkgconfig_include_flags.split() ] - - # libraries - pkgconfig_lflags = subprocess.check_output( ["pkg-config", "--libs-only-l", pkg_deps] ).decode(encoding) - libraries = [ t[2:] for t in pkgconfig_lflags.split() ] - - # link directories - pkgconfig_biglflags = subprocess.check_output( ["pkg-config", "--libs-only-L", pkg_deps ] ).decode(encoding) - library_dirs = [ t[2:] for t in pkgconfig_biglflags.split() ] - - # other compiler flags - pkgconfig_cflags = subprocess.check_output( ["pkg-config", "--cflags", pkg_deps] ).decode(encoding).split() - extra_compile_args = [ \ - '-Wno-strict-prototypes', - "-D_FILE_OFFSET_BITS=64", - "-D_LARGEFILE_SOURCE", - "-std=gnu99" ] + pkgconfig_cflags - -pylcm_extension = Extension("lcm._lcm", - sources, - include_dirs=include_dirs, - define_macros=define_macros, - library_dirs=library_dirs, - libraries=libraries, - extra_compile_args=extra_compile_args) - -setup(name="lcm", version=lcm_version, - ext_modules=[pylcm_extension], - packages=["lcm"]) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..e9931fda3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,33 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "lcm" +version = "1.5.0" +description = "Lightweight Communication and Marshalling" +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + 'Development Status :: 4 - Beta', + 'Topic :: Communications', + 'Framework :: Robot Framework', +] + +[project.optional-dependencies] +test = ["pytest"] + +[tool.scikit-build] +cmake.args = ["-DLCM_INSTALL_PKGCONFIG=OFF"] +wheel.expand-macos-universal-tags = true +build.tool-args = ["-j4"] + +[tool.pytest.ini_options] +minversion = "6.0" +addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] +xfail_strict = true +log_cli_level = "INFO" +filterwarnings = ["error"] + +[tool.cibuildwheel] +build-verbosity = 1 From a8354d021f358721f6cc5f45e0dd064ba86f3323 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Tue, 7 May 2024 13:19:28 -0400 Subject: [PATCH 03/19] fix finding python --- lcm-python/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lcm-python/CMakeLists.txt b/lcm-python/CMakeLists.txt index 77a3b0d12..623e04e14 100644 --- a/lcm-python/CMakeLists.txt +++ b/lcm-python/CMakeLists.txt @@ -28,10 +28,10 @@ if (WIN32 AND NOT CYGWIN) set_target_properties(lcm-python PROPERTIES SUFFIX .pyd) endif () -find_package (Python COMPONENTS Interpreter Development) +find_package(Python3 COMPONENTS Interpreter Development.Module) target_include_directories(lcm-python PRIVATE - ${Python_INCLUDE_DIRS} + ${Python3_INCLUDE_DIRS} ) target_link_libraries(lcm-python PRIVATE From 963b8f303c91031ae97303559e996fc1b1ba8251 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Tue, 7 May 2024 15:32:22 -0400 Subject: [PATCH 04/19] link against static lcm library --- lcm-logger/CMakeLists.txt | 4 ++-- liblcm-test/CMakeLists.txt | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lcm-logger/CMakeLists.txt b/lcm-logger/CMakeLists.txt index e1f2f5a66..51e90c5e2 100644 --- a/lcm-logger/CMakeLists.txt +++ b/lcm-logger/CMakeLists.txt @@ -1,8 +1,8 @@ add_executable(lcm-logger lcm_logger.c glib_util.c) -target_link_libraries(lcm-logger lcm GLib2::glib) +target_link_libraries(lcm-logger lcm-static GLib2::glib) add_executable(lcm-logplayer lcm_logplayer.c) -target_link_libraries(lcm-logplayer lcm GLib2::glib) +target_link_libraries(lcm-logplayer lcm-static GLib2::glib) install(TARGETS lcm-logger diff --git a/liblcm-test/CMakeLists.txt b/liblcm-test/CMakeLists.txt index 3e28be162..5e05c481c 100644 --- a/liblcm-test/CMakeLists.txt +++ b/liblcm-test/CMakeLists.txt @@ -1,29 +1,29 @@ add_executable(lcm-sink lcm-sink.c) -target_link_libraries(lcm-sink lcm) +target_link_libraries(lcm-sink lcm-static) add_executable(lcm-source lcm-source.c) -target_link_libraries(lcm-source lcm) +target_link_libraries(lcm-source lcm-static) add_executable(lcm-tester lcm-tester.c) -target_link_libraries(lcm-tester lcm GLib2::glib) +target_link_libraries(lcm-tester lcm-static GLib2::glib) if(WIN32) target_link_libraries(lcm-tester wsock32 ws2_32) endif() add_executable(lcm-example lcm-example.c) -target_link_libraries(lcm-example lcm) +target_link_libraries(lcm-example lcm-static) if(WIN32) target_link_libraries(lcm-example ws2_32) endif() add_executable(lcm-logfilter lcm-logfilter.c) -target_link_libraries(lcm-logfilter lcm GLib2::glib) +target_link_libraries(lcm-logfilter lcm-static GLib2::glib) add_executable(lcm-buftest-receiver buftest-receiver.c) -target_link_libraries(lcm-buftest-receiver lcm GLib2::glib) +target_link_libraries(lcm-buftest-receiver lcm-static GLib2::glib) add_executable(lcm-buftest-sender buftest-sender.c) -target_link_libraries(lcm-buftest-sender lcm GLib2::glib) +target_link_libraries(lcm-buftest-sender lcm-static GLib2::glib) install(TARGETS lcm-sink From 623a09e91948fe45b367fc925e55e6d7c7d69437 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 10 May 2024 15:47:01 -0400 Subject: [PATCH 05/19] configure windows build pull windows out of the matrix into its own job specify msys2 shell --- .github/workflows/build_wheels.yml | 41 ++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index b69377a84..ff761b9da 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -3,16 +3,53 @@ name: Build wheels on: [push, pull_request] jobs: - build_wheels: + unix: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, windows-latest, macos-13, macos-14] + os: [ubuntu-latest, macos-13, macos-14] steps: - uses: actions/checkout@v4 + - name: Build wheels + uses: pypa/cibuildwheel@v2.17.0 + # env: + # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + windows: + name: Build wheels on windows + runs-on: windows-latest + + defaults: + run: + shell: msys2 {0} + + steps: + - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + with: + msystem: mingw64 + update: false + install: >- + git + make + pacboy: >- + toolchain:p + cmake:p + glib2:p + gtest:p - name: Build wheels uses: pypa/cibuildwheel@v2.17.0 From 0d9090c09998448a84bfe928083fe264c28ace8f Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 10 May 2024 15:57:19 -0400 Subject: [PATCH 06/19] drop building windows wheel --- .github/workflows/build_wheels.yml | 38 ------------------------------ 1 file changed, 38 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index ff761b9da..05d9d4bee 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -27,41 +27,3 @@ jobs: with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl - - windows: - name: Build wheels on windows - runs-on: windows-latest - - defaults: - run: - shell: msys2 {0} - - steps: - - uses: actions/checkout@v4 - - uses: msys2/setup-msys2@v2 - with: - msystem: mingw64 - update: false - install: >- - git - make - pacboy: >- - toolchain:p - cmake:p - glib2:p - gtest:p - - - name: Build wheels - uses: pypa/cibuildwheel@v2.17.0 - # env: - # CIBW_SOME_OPTION: value - # ... - # with: - # package-dir: . - # output-dir: wheelhouse - # config-file: "{package}/pyproject.toml" - - - uses: actions/upload-artifact@v4 - with: - name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} - path: ./wheelhouse/*.whl From d4a4f254a804750293b968e935a499a03e220a27 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 10 May 2024 16:09:26 -0400 Subject: [PATCH 07/19] find unversioned python on windows --- lcm-python/CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lcm-python/CMakeLists.txt b/lcm-python/CMakeLists.txt index 623e04e14..ef22894c3 100644 --- a/lcm-python/CMakeLists.txt +++ b/lcm-python/CMakeLists.txt @@ -28,11 +28,19 @@ if (WIN32 AND NOT CYGWIN) set_target_properties(lcm-python PROPERTIES SUFFIX .pyd) endif () -find_package(Python3 COMPONENTS Interpreter Development.Module) +if (WIN32) + find_package(Python COMPONENTS Interpreter Development.Module) -target_include_directories(lcm-python PRIVATE + target_include_directories(lcm-python PRIVATE + ${Python_INCLUDE_DIRS} + ) +else () + find_package(Python3 COMPONENTS Interpreter Development.Module) + + target_include_directories(lcm-python PRIVATE ${Python3_INCLUDE_DIRS} -) + ) +endif () target_link_libraries(lcm-python PRIVATE lcm-static From c573786d89fc10286961cff599700dd58c52756c Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Thu, 27 Jun 2024 15:45:58 -0400 Subject: [PATCH 08/19] bump cibuildwheel latest version has fixes for EOL centOS mirrors --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 05d9d4bee..c0ec2dcdc 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build wheels - uses: pypa/cibuildwheel@v2.17.0 + uses: pypa/cibuildwheel@v2.19.1 # env: # CIBW_SOME_OPTION: value # ... From 60f11aee54a84b10a7287260a979c0dcb8bd9c7e Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 28 Jun 2024 10:54:05 -0400 Subject: [PATCH 09/19] set MACOSX_DEPLOYMENT_TARGET --- .github/workflows/build_wheels.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index c0ec2dcdc..2953507f2 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -10,13 +10,18 @@ jobs: matrix: # macos-13 is an intel runner, macos-14 is apple silicon os: [ubuntu-latest, macos-13, macos-14] + include: + - os: macos-13 + macos_deployment_target: 13 + - os: macos-14 + macos_deployment_target: 14 steps: - uses: actions/checkout@v4 - name: Build wheels uses: pypa/cibuildwheel@v2.19.1 - # env: - # CIBW_SOME_OPTION: value + env: + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} # ... # with: # package-dir: . From 7fef1af8766c227a2b0cb1c737e81d837f31f3af Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Sun, 28 Jul 2024 10:13:41 -0400 Subject: [PATCH 10/19] remove unused stuff from CI YAML --- .github/workflows/build_wheels.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2953507f2..7a798e7fc 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -22,11 +22,6 @@ jobs: uses: pypa/cibuildwheel@v2.19.1 env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} - # ... - # with: - # package-dir: . - # output-dir: wheelhouse - # config-file: "{package}/pyproject.toml" - uses: actions/upload-artifact@v4 with: From 2f325c416f882a90f83f8cbb837b912ebcab2ce0 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 28 Jun 2024 15:26:37 -0400 Subject: [PATCH 11/19] build aarch64 wheels for linux --- .github/workflows/build_wheels.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 7a798e7fc..455eb05b2 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -10,11 +10,17 @@ jobs: matrix: # macos-13 is an intel runner, macos-14 is apple silicon os: [ubuntu-latest, macos-13, macos-14] + arch: [auto, aarch64] include: - os: macos-13 macos_deployment_target: 13 - os: macos-14 macos_deployment_target: 14 + exclude: + - os: macos-13 + arch: aarch64 + - os: macos-14 + arch: aarch64 steps: - uses: actions/checkout@v4 @@ -22,6 +28,7 @@ jobs: uses: pypa/cibuildwheel@v2.19.1 env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} + CIBW_ARCHS: ${{ matrix.arch }} - uses: actions/upload-artifact@v4 with: From c54340221cf01aa02d0cb6ad10304f147c99d938 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 28 Jun 2024 15:44:42 -0400 Subject: [PATCH 12/19] set up QEMU --- .github/workflows/build_wheels.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 455eb05b2..12b6b68f4 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -24,6 +24,13 @@ jobs: steps: - uses: actions/checkout@v4 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + - name: Build wheels uses: pypa/cibuildwheel@v2.19.1 env: From 48cc4149f982ea84f69db7311c7f7033eb93df47 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Sun, 30 Jun 2024 09:54:22 -0400 Subject: [PATCH 13/19] don't modify Python extension install location during pip builds --- lcm-python/CMakeLists.txt | 29 +++++++++++++++++++---------- pyproject.toml | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lcm-python/CMakeLists.txt b/lcm-python/CMakeLists.txt index ef22894c3..d65bfaf53 100644 --- a/lcm-python/CMakeLists.txt +++ b/lcm-python/CMakeLists.txt @@ -1,13 +1,22 @@ # FindPython added in 3.12 cmake_minimum_required(VERSION 3.12) -execute_process( - COMMAND "${Python_EXECUTABLE}" -c "if True: - from sysconfig import get_path - from os.path import sep - print(get_path('platlib').replace(get_path('data') + sep, ''))" - OUTPUT_VARIABLE PYTHON_SITE - OUTPUT_STRIP_TRAILING_WHITESPACE) +option(LCM_PIP_BUILD "When true, adjusts install path to something appropriate for a Python wheel" OFF) + +if (NOT LCM_PIP_BUILD) + execute_process( + COMMAND "${Python_EXECUTABLE}" -c "if True: + from sysconfig import get_path + from os.path import sep + print(get_path('platlib').replace(get_path('data') + sep, ''))" + OUTPUT_VARIABLE PYTHON_SITE + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(PYTHON_INSTALL_DIR ${PYTHON_SITE}/lcm) +else() + set(PYTHON_INSTALL_DIR lcm) +endif() + set(lcm_python_sources module.c @@ -55,8 +64,8 @@ else() endif() install(TARGETS lcm-python - RUNTIME DESTINATION ${PYTHON_SITE}/lcm - LIBRARY DESTINATION ${PYTHON_SITE}/lcm + RUNTIME DESTINATION ${PYTHON_INSTALL_DIR} + LIBRARY DESTINATION ${PYTHON_INSTALL_DIR} ) lcm_copy_file_target(lcm-python-init @@ -64,4 +73,4 @@ lcm_copy_file_target(lcm-python-init ${CMAKE_BINARY_DIR}/python/lcm/__init__.py ) -install(FILES lcm/__init__.py DESTINATION ${PYTHON_SITE}/lcm) +install(FILES lcm/__init__.py DESTINATION ${PYTHON_INSTALL_DIR}) diff --git a/pyproject.toml b/pyproject.toml index e9931fda3..4af63e9a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ test = ["pytest"] [tool.scikit-build] -cmake.args = ["-DLCM_INSTALL_PKGCONFIG=OFF"] +cmake.args = ["-DLCM_INSTALL_PKGCONFIG=OFF", "-DLCM_PIP_BUILD=ON"] wheel.expand-macos-universal-tags = true build.tool-args = ["-j4"] From ab069719a5c9e03ce5ee346791e05a1e7e4c4b03 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Tue, 16 Jul 2024 12:15:25 -0400 Subject: [PATCH 14/19] add shims to site-packages scripts --- lcm-python/lcm/__init__.py | 36 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 12 ++++++++++++ 2 files changed, 48 insertions(+) diff --git a/lcm-python/lcm/__init__.py b/lcm-python/lcm/__init__.py index e3e78caf9..5f83afe52 100644 --- a/lcm-python/lcm/__init__.py +++ b/lcm-python/lcm/__init__.py @@ -1,5 +1,6 @@ import os import sys +import subprocess # Attempt to be backwards compatible if sys.version_info >= (3, 6): @@ -164,3 +165,38 @@ def tell (self): @rtype: int """ return self.c_eventlog.ftell () + +LCM_BIN_DIR = os.path.join(os.path.dirname(__file__), '..', 'bin') + +def run_script(name: str, args) -> int: + return subprocess.call([os.path.join(LCM_BIN_DIR, name), *args], close_fds=False) + +def run_example(): + raise SystemExit(run_script('lcm-example', sys.argv[1:])) + +def run_gen(): + raise SystemExit(run_script('lcm-gen', sys.argv[1:])) + +def run_logfilter(): + raise SystemExit(run_script('lcm-logfilter', sys.argv[1:])) + +def run_logger(): + raise SystemExit(run_script('lcm-logger', sys.argv[1:])) + +def run_logplayer(): + raise SystemExit(run_script('lcm-logplayer', sys.argv[1:])) + +def run_logplayer_gui(): + raise SystemExit(run_script('lcm-logplayer-gui', sys.argv[1:])) + +def run_sink(): + raise SystemExit(run_script('lcm-sink', sys.argv[1:])) + +def run_source(): + raise SystemExit(run_script('lcm-source', sys.argv[1:])) + +def run_spy(): + raise SystemExit(run_script('lcm-spy', sys.argv[1:])) + +def run_tester(): + raise SystemExit(run_script('lcm-tester', sys.argv[1:])) diff --git a/pyproject.toml b/pyproject.toml index 4af63e9a9..9c79a1a7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,18 @@ classifiers = [ 'Framework :: Robot Framework', ] +[project.scripts] +lcm-example = "lcm:run_example" +lcm-gen = "lcm:run_gen" +lcm-logfilter = "lcm:run_logfilter" +lcm-logger = "lcm:run_logger" +lcm-logplayer = "lcm:run_logplayer" +lcm-logplayer-gui = "lcm:run_logplayer_gui" +lcm-sink = "lcm:run_sink" +lcm-source = "lcm:run_source" +lcm-spy = "lcm:run_spy" +lcm-tester = "lcm:run_tester" + [project.optional-dependencies] test = ["pytest"] From 7fdf42efb40d500de4ee55e9fe146bffb479e054 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 19 Jul 2024 10:00:12 -0400 Subject: [PATCH 15/19] document how to build and install the python module --- docs/content/build-instructions.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/content/build-instructions.md b/docs/content/build-instructions.md index 13cb60a85..7e976e35b 100644 --- a/docs/content/build-instructions.md +++ b/docs/content/build-instructions.md @@ -21,6 +21,14 @@ release or the latest `master`, we recommend referring to the copy of this document (`docs/content/build-instructions.md`) found in your source distribution. +## Installing the Python module + +To build the Python module from source and install it, run: + +``` +pip3 install -v . +``` + ## CMake Overview These instructions assume that you will build in a directory named `build` as From 5cfb0fb6f2d2de2f51f5916233047c3f21fb7520 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Fri, 19 Jul 2024 10:04:43 -0400 Subject: [PATCH 16/19] ignore more stuff local venv and macOS stuff --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 07ca244b8..64507593f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ docs/_build/ .idea/ .settings/ .project -.classpath \ No newline at end of file +.classpath +.venv +.DS_Store \ No newline at end of file From 0967b3b4fc800716772f6dd404137a6723946b9a Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Thu, 25 Jul 2024 12:41:39 -0400 Subject: [PATCH 17/19] install java for linux wheel builds bump cibuildwheel need a version that has a version of manylinux with past EOL centOS mirrors give up on java on muslinux cmake can't find javah --- .github/workflows/build_wheels.yml | 2 +- pyproject.toml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 12b6b68f4..271e4d914 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -32,7 +32,7 @@ jobs: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.19.1 + uses: pypa/cibuildwheel@v2.19.2 env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} CIBW_ARCHS: ${{ matrix.arch }} diff --git a/pyproject.toml b/pyproject.toml index 9c79a1a7b..d3912881b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,3 +43,10 @@ filterwarnings = ["error"] [tool.cibuildwheel] build-verbosity = 1 + +[tool.cibuildwheel.linux] +before-all = "yum install java-1.8.0-openjdk-devel -y" + +[[tool.cibuildwheel.overrides]] +select = "*-musllinux*" +before-all = "" From 7f92cd991b324a1c34f14037d9811326e562529c Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Wed, 31 Jul 2024 15:02:03 -0400 Subject: [PATCH 18/19] parallelize wheel-building no Python3.7 on macos-14 runner --- .github/workflows/build_wheels.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 271e4d914..adb24e069 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -11,6 +11,8 @@ jobs: # macos-13 is an intel runner, macos-14 is apple silicon os: [ubuntu-latest, macos-13, macos-14] arch: [auto, aarch64] + python: [cp37-*, cp38-*, cp39-*, cp310-*, cp311-*, cp312-*, + pp37-*, pp38-*, pp39-*, pp310-*] include: - os: macos-13 macos_deployment_target: 13 @@ -21,6 +23,10 @@ jobs: arch: aarch64 - os: macos-14 arch: aarch64 + - os: macos-14 + python: cp37-* + - os: macos-14 + python: pp37-* steps: - uses: actions/checkout@v4 @@ -36,6 +42,7 @@ jobs: env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} CIBW_ARCHS: ${{ matrix.arch }} + CIBW_BUILD: ${{ matrix.python }} - uses: actions/upload-artifact@v4 with: From c783f9eb7e2c76dd66e965c575066e5936665688 Mon Sep 17 00:00:00 2001 From: Daniel Carson Date: Wed, 31 Jul 2024 15:07:29 -0400 Subject: [PATCH 19/19] improve job name --- .github/workflows/build_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index adb24e069..4c9320cf6 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: unix: - name: Build wheels on ${{ matrix.os }} + name: ${{ matrix.os }} | ${{ matrix.arch }} | ${{ matrix.python }} runs-on: ${{ matrix.os }} strategy: matrix: