From a6a61bdf8c3af871882d43143117268666e24279 Mon Sep 17 00:00:00 2001 From: Gabriele Roeger Date: Tue, 17 Dec 2024 14:09:14 +0100 Subject: [PATCH] use pyproject.toml instead of setup.py --- _custom_build.py | 52 +++++++++++++++++++++++ pyproject.toml | 46 ++++++++++++++++++++ setup.py | 108 ----------------------------------------------- 3 files changed, 98 insertions(+), 108 deletions(-) create mode 100644 _custom_build.py create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/_custom_build.py b/_custom_build.py new file mode 100644 index 0000000..865242b --- /dev/null +++ b/_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): + _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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d475d56 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[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>=75.3.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 = ["_custom_build"] + +[tool.setuptools.cmdclass] +build_py = "_custom_build.install_fast_downward" +bdist_wheel = "_custom_build.bdist_wheel" + +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.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/*'] diff --git a/setup.py b/setup.py deleted file mode 100644 index 8912689..0000000 --- a/setup.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python3 -import subprocess - -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 bdist_wheel(_bdist_wheel): - - 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 - )