From f12666ce6304dab2f1b5ec910dcd913d40890de1 Mon Sep 17 00:00:00 2001 From: Gabi Roeger Date: Wed, 18 Dec 2024 13:13:54 +0100 Subject: [PATCH] Version 0.4.2: Update setuptools to use pyproject.toml Still based on Fast Downward 13.06 --- .github/workflows/main.yml | 134 +++++++++++++++--------------- CHANGES.md | 3 + pyproject.toml | 54 ++++++++++++ setup.py | 112 ++----------------------- up_fast_downward/_custom_build.py | 52 ++++++++++++ 5 files changed, 186 insertions(+), 169 deletions(-) create mode 100644 pyproject.toml create mode 100644 up_fast_downward/_custom_build.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0987173..74d40be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,99 +3,101 @@ name: Deploy on: push jobs: - build-linux: - name: Build linux Python wheels - runs-on: ubuntu-latest + build_wheels_mac_ubuntu: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner + os: [ubuntu-latest, macos-13] steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build manylinux Python wheels - uses: RalfG/python-wheels-manylinux-build@v0.4.2-manylinux2014_x86_64 - with: - python-versions: 'cp36-cp36m cp37-cp37m' + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + + - name: Install build tools + run: python -m pip install --upgrade pip setuptools==75.3.0 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 + env: + CIBW_SKIP: '*-musllinux_*' - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v4 with: - name: linux-wheels - path: dist/*-manylinux*.whl + name: cibw-wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl - build-windows: - name: Build windows Python wheel - runs-on: windows-2022 - env: - CC: cl - CXX: cl -# CIBW_BUILD_VERBOSITY: 3 + build_wheels_mac_arm64: + name: Build wheels on macos-14 + runs-on: macos-14 # apple silicon steps: - - name: Clone UP Fast Downward repository - uses: actions/checkout@v4 - - - uses: actions/setup-python@v3 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.15.0 - - - uses: ilammy/msvc-dev-cmd@v1 - - - name: Build 64-bit wheel - run: python -m cibuildwheel --output-dir dist + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + + - name: Install build tools + run: python -m pip install --upgrade pip setuptools==75.3.0 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 env: - CIBW_BUILD: cp36-win_amd64 + CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # skip repair step - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: windows-wheel - path: dist/*.whl + name: cibw-wheels-macos-14 + path: ./wheelhouse/*.whl + + build_wheels_windows: + name: Build wheels on windows-latest + runs-on: windows-latest + env: + CC: cl + CXX: cl - build-mac: - name: Build macOS Python wheel - runs-on: macOS-11 steps: - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + + - name: Install build tools + run: python -m pip install --upgrade pip setuptools==75.3.0 - - uses: actions/setup-python@v3 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.15.0 + - uses: ilammy/msvc-dev-cmd@v1 - - name: Build wheel - run: python -m cibuildwheel --output-dir dist + - name: Build wheels + uses: pypa/cibuildwheel@v2.22.0 env: - CIBW_ARCHS_MACOS: "x86_64 arm64" + CIBW_BUILD: cp38-win_amd64 - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: mac-wheel - path: dist/*.whl + name: cibw-wheels-windows-latest + path: ./wheelhouse/*.whl run-tox-test: - name: Test wheels - needs: [build-linux, build-mac] + name: Test wheels on mac and linux + needs: [build_wheels_mac_ubuntu, build_wheels_mac_arm64] runs-on: ${{ matrix.version.os }} strategy: matrix: version: - - {os: ubuntu-20.04, python: '3.8'} - - {os: ubuntu-22.04, python: '3.10'} - - {os: macOS-11, python: '3.10'} + - {os: ubuntu-latest, python: '3.10'} + - {os: macos-13, python: '3.10'} + - {os: macos-14, python: '3.12'} steps: - name: Clone repository uses: actions/checkout@v4 - uses: actions/download-artifact@master with: - name: linux-wheels - path: dist - - - uses: actions/download-artifact@master - with: - name: mac-wheel + name: cibw-wheels-${{ matrix.version.os }} path: dist - name: Install Python @@ -115,8 +117,8 @@ jobs: run-tox-test-windows: - name: Test wheels - needs: [build-windows] + name: Test wheels on windows + needs: [build_wheels_windows] runs-on: ${{ matrix.version.os }} strategy: matrix: @@ -129,7 +131,7 @@ jobs: - uses: actions/download-artifact@master with: - name: windows-wheel + name: cibw-wheels-windows-latest path: dist - name: Install Python @@ -156,17 +158,17 @@ jobs: steps: - uses: actions/download-artifact@master with: - name: linux-wheels + name: cibw-wheels-ubuntu-latest path: dist - uses: actions/download-artifact@master with: - name: windows-wheel + name: cibw-wheels-windows-latest path: dist - uses: actions/download-artifact@master with: - name: mac-wheel + name: cibw-wheels-macos-13 path: dist - run: ls dist diff --git a/CHANGES.md b/CHANGES.md index af372e7..f9601c0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,7 @@ # Release notes +UP Fast Downward 0.4.2 +- Update packaging (using pyproject.toml) + UP Fast Downward 0.4.1 - Generate Python wheels compatible with Mac Apple Silicon M1/M2 - Update README.md (current state of development and default configurations) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..df3e4ce --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +[project] +name = "up_fast_downward" +version = "0.4.2" +description = "Unified Planning Integration of the Fast Downward planning system" +readme = {text = "This package makes the [Fast Downward](https://www.fast-downward.org/) planning system available in the [unified_planning library](https://github.com/aiplan4eu/unified-planning).", content-type = "text/markdown"} +requires-python = ">=3.8" +license = {text = "GPL-3.0-only"} +authors = [ + {name = "UNIBAS Team"}, +] +maintainers = [ + {name = "Gabriele Röger", email = "gabriele.roeger@unibas.ch"}, +] +dependencies = ["setuptools>=59.6.0"] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] + +[project.urls] +Homepage = "https://github.com/aiplan4eu/up-fast-downward/" + +[tool.setuptools] +py-modules = ["up_fast_downward._custom_build"] + +[tool.setuptools.packages.find] +where = ["."] +include = ["up_fast_downward"] # ["*"] by default +#find = {} + +[tool.setuptools.package-data] +up_fast_downward = [ + 'fast_downward.py', + 'fast_downward_grounder.py', + 'utils.py', + 'downward/fast-downward.py', + 'downward/README.md', 'downward/LICENSE.md', + 'downward/builds/release/bin/*', + 'downward/builds/release/bin/translate/*', + 'downward/builds/release/bin/translate/pddl/*', + 'downward/builds/release/bin/translate/pddl_parser/*', + 'downward/driver/*', 'downward/driver/portfolios/*' +] + +[tool.setuptools.cmdclass] +build_py = "up_fast_downward._custom_build.install_fast_downward" +bdist_wheel = "up_fast_downward._custom_build.bdist_wheel" + +[build-system] +requires = ["setuptools>=59.6"] +build-backend = "setuptools.build_meta" + diff --git a/setup.py b/setup.py index 8912689..95f6771 100644 --- a/setup.py +++ b/setup.py @@ -1,108 +1,14 @@ -#!/usr/bin/env python3 -import subprocess +import setuptools +from setuptools import dist -from setuptools import setup -from setuptools.command.build_py import build_py -from setuptools.command.develop import develop -import os -import urllib -import shutil -import sys -try: - from wheel.bdist_wheel import bdist_wheel as _bdist_wheel +class BinaryDistribution(dist.Distribution): + """This class makes 'bdist_wheel' include an ABI tag on the wheel.""" - class bdist_wheel(_bdist_wheel): + def has_ext_modules(self): + return True - def finalize_options(self): - _bdist_wheel.finalize_options(self) - # Mark us as not a pure python package - self.root_is_pure = False - def get_tag(self): - python, abi, plat = _bdist_wheel.get_tag(self) - # We don't link with python ABI, but require python3 - python, abi = 'py3', 'none' - return python, abi, plat -except ImportError: - bdist_wheel = None - - - -FAST_DOWNWARD_REPO = 'https://github.com/aibasel/downward.git' -FAST_DOWNWARD_RELEASE = 'release-23.06' -#FAST_DOWNWARD_RELEASE = None -# CHANGESET is ignored if release is not None -FAST_DOWNWARD_CHANGESET = 'bd3c63647a42c9a5f103402615ca991d23a88d55' - - -def clone_and_compile_fast_downward(): - curr_dir = os.getcwd() - print("Cloning Fast Downward repository...") - if FAST_DOWNWARD_RELEASE is not None: - subprocess.run(['git', 'clone', '-b', FAST_DOWNWARD_RELEASE, FAST_DOWNWARD_REPO]) - else: - subprocess.run(['git', 'clone', FAST_DOWNWARD_REPO]) - - shutil.move('downward', 'up_fast_downward/downward') - os.chdir('up_fast_downward/downward') - if FAST_DOWNWARD_RELEASE is None: - subprocess.run(['git', 'checkout', FAST_DOWNWARD_CHANGESET]) - print("Building Fast Downward (this can take some time)...") - build = subprocess.run(['python', 'build.py', 'release'], - stdout = subprocess.PIPE, stderr = subprocess.PIPE, - universal_newlines = True) -# print(build.stdout) -# print(build.stderr) - os.chdir(curr_dir) - - -class install_fast_downward(build_py): - """Custom install command.""" - - def run(self): - clone_and_compile_fast_downward() - build_py.run(self) - - -class install_fast_downward_develop(develop): - """Custom install command.""" - def run(self): - clone_and_compile_fast_downward() - develop.run(self) - -long_description = "This package makes the [Fast Downward](https://www.fast-downward.org/) planning system available in the [unified_planning library](https://github.com/aiplan4eu/unified-planning) by the [AIPlan4EU project](https://www.aiplan4eu-project.eu/)." - -setup(name='up_fast_downward', - version='0.4.1', - description='Unified Planning Integration of the Fast Downward planning system', - long_description=long_description, - long_description_content_type="text/markdown", - author='UNIBAS Team', - author_email='gabriele.roeger@unibas.ch', - url='https://github.com/aiplan4eu/up-fast-downward/', - classifiers=['Development Status :: 4 - Beta', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering :: Artificial Intelligence' - ], - packages=['up_fast_downward'], - package_data={ - "": ['fast_downward.py', - 'fast_downward_grounder.py', - 'utils.py', - 'downward/fast-downward.py', - 'downward/README.md', 'downward/LICENSE.md', - 'downward/builds/release/bin/*', - 'downward/builds/release/bin/translate/*', - 'downward/builds/release/bin/translate/pddl/*', - 'downward/builds/release/bin/translate/pddl_parser/*', - 'downward/driver/*', 'downward/driver/portfolios/*'] - }, - cmdclass={ - 'bdist_wheel': bdist_wheel, - 'build_py': install_fast_downward, - 'develop': install_fast_downward_develop, - }, - has_ext_modules=lambda: True - ) +setuptools.setup( + distclass=BinaryDistribution, +) diff --git a/up_fast_downward/_custom_build.py b/up_fast_downward/_custom_build.py new file mode 100644 index 0000000..f1d94c5 --- /dev/null +++ b/up_fast_downward/_custom_build.py @@ -0,0 +1,52 @@ +from setuptools import Extension +from setuptools.command.build_py import build_py as _build_py +from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel +import os +import shutil +import subprocess +import sys + +def clone_and_compile_fast_downward(): + FAST_DOWNWARD_REPO = 'https://github.com/aibasel/downward.git' + FAST_DOWNWARD_RELEASE = 'release-23.06' + #FAST_DOWNWARD_RELEASE = None + # CHANGESET is ignored if release is not None + FAST_DOWNWARD_CHANGESET = 'bd3c63647a42c9a5f103402615ca991d23a88d55' + + curr_dir = os.getcwd() + print("Cloning Fast Downward repository...") + if FAST_DOWNWARD_RELEASE is not None: + subprocess.run(['git', 'clone', '-b', FAST_DOWNWARD_RELEASE, FAST_DOWNWARD_REPO]) + else: + subprocess.run(['git', 'clone', FAST_DOWNWARD_REPO]) + + shutil.move('downward', 'up_fast_downward/downward') + os.chdir('up_fast_downward/downward') + if FAST_DOWNWARD_RELEASE is None: + subprocess.run(['git', 'checkout', FAST_DOWNWARD_CHANGESET]) + print("Building Fast Downward (this can take some time)...") + build = subprocess.run(['python', 'build.py', 'release'], + stdout = subprocess.PIPE, stderr = subprocess.PIPE, + universal_newlines = True) + os.chdir(curr_dir) + +class install_fast_downward(_build_py): + """Custom install command.""" + + def run(self, *args, **kwargs): + clone_and_compile_fast_downward() + super().run(*args, **kwargs) + + +class bdist_wheel(_bdist_wheel): + + def finalize_options(self): + super().finalize_options() + # Mark us as not a pure python package + self.root_is_pure = False + + def get_tag(self): + python, abi, plat = super().get_tag() + # We don't link with python ABI, but require python3 + python, abi = 'py3', 'none' + return python, abi, plat