diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 626bbc7..7d8e642 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -1,75 +1,94 @@ -name: Build and publish pyfactxx +name: Build and publish pyfactxx on: release: types: [created] +permissions: + contents: read # access to check out code and install dependencies + jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-20.04", "windows-latest"] - python-version: ["3.7", "3.8", "3.9", "3.10"] + os: ["ubuntu-22.04", "windows-2025"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] defaults: run: working-directory: ./FaCT++.Python steps: - - uses: actions/checkout@v3 - - uses: ilammy/msvc-dev-cmd@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel auditwheel scikit-build cmake cython - - name: Build a wheel - run: | - python setup.py bdist_wheel - - name: Audit a wheel - if: runner.os == 'Linux' - run: | - auditwheel repair --plat manylinux_2_27_x86_64 dist/* - rm -rf dist/* - mv wheelhouse/* dist - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ runner.os }}-${{ matrix.python-version }} - path: FaCT++.Python/dist/pyfactxx* + - uses: actions/checkout@v5 + - uses: actions/setup-node@v6 + with: + node-version: "24" + # TODO: migrate to the upstream + - uses: knopki/msvc-dev-cmd@221ec3af3b87c0c8189236347c1c0788d2022272 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel scikit-build cmake cython + - name: Install Linux-only dependencies + if: runner.os == 'Linux' + run: | + pip install auditwheel patchelf + - name: Build a wheel + run: | + python setup.py bdist_wheel + - name: Audit a wheel + if: runner.os == 'Linux' + run: | + auditwheel repair --plat manylinux_2_34_x86_64 dist/*whl + rm -rf dist/* + mv wheelhouse/* dist + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ runner.os }}-${{ matrix.python-version }} + path: FaCT++.Python/dist/pyfactxx* publish: - runs-on: ubuntu-latest - needs: build + runs-on: ubuntu-24.04 + needs: build defaults: run: working-directory: ./FaCT++.Python + environment: + name: pypi + url: https://pypi.org/p/pyfactxx + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v3 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel auditwheel scikit-build cmake cython - - name: Build a source distribution - run: | - python setup.py sdist - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: FaCT++.Python/wheels/ - - name: Move wheels - run: | - mv wheels/*/*.whl dist/ - - name: Publish packages - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - packages_dir: FaCT++.Python/dist \ No newline at end of file + - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: 3.14 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel scikit-build cmake cython + - name: Build a source distribution + run: | + python setup.py sdist + - name: Download artifacts + uses: actions/download-artifact@v5 + with: + path: FaCT++.Python/wheels/ + - name: Move wheels + run: | + mv wheels/*/*.whl dist/ + - name: Publish packages + uses: pypa/gh-action-pypi-publish@v1.13.0 + with: + packages-dir: FaCT++.Python/dist/ + # # useful for testing: + # verbose: true + # repository-url: https://test.pypi.org/legacy/ + # user: __token__ + # password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 31dc8e8..0f7ddae 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -3,36 +3,37 @@ name: Build and test pyfactxx on: workflow_dispatch: push: - branches: [ $default-branch, "wheels" ] + branches: [master, "wheels"] pull_request: - branches: [ $default-branch, "wheels" ] + branches: [master, "wheels"] + +permissions: + contents: read # access to check out code and install dependencies jobs: build: - - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 defaults: run: working-directory: ./FaCT++.Python strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - uses: ilammy/msvc-dev-cmd@v1 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install scikit-build cmake cython pytest pytest-cov + pip install pytest pytest-cov - name: Install package - working-directory: ./FaCT++.Python run: | - pip install -e . + pip install . - name: Test with pytest run: | - pytest FaCT++.Python + pytest diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index e2eba20..2ade04b 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -2,12 +2,12 @@ name: Codacy Security Scan on: push: - branches: [ master ] + branches: [master] pull_request: # The branches below must be a subset of the branches above - branches: [ master ] + branches: [master] schedule: - - cron: '32 23 * * 5' + - cron: "32 23 * * 5" jobs: codacy-security-scan: @@ -16,7 +16,7 @@ jobs: steps: # Checkout the repository to the GitHub Actions runner - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v5 # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI @@ -36,6 +36,10 @@ jobs: # Upload the SARIF file generated in the previous step - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v4 + # Codacy is broken now + # https://github.com/codacy/codacy-analysis-cli/issues/541 + continue-on-error: true with: sarif_file: results.sarif + wait-for-processing: true diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0c5194d..3826736 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,17 +2,17 @@ name: "CodeQL" on: push: - branches: [ master ] + branches: [master] pull_request: # The branches below must be a subset of the branches above - branches: [ master ] + branches: [master] schedule: - - cron: '30 3 * * 0' + - cron: "30 3 * * 0" jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: actions: read contents: read @@ -21,37 +21,45 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'java', 'python' ] + language: ["cpp", "java", "python"] steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + if: matrix.language != 'cpp' + uses: github/codeql-action/autobuild@v3 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + - name: Install dependencies + if: matrix.language == 'cpp' + run: | + sudo apt-get update + sudo apt-get install cmake default-jdk + - name: Build + if: matrix.language == 'cpp' + run: | + cmake . + make + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 550231d..1b81c7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.15) project(factplusplus) # global definition diff --git a/FaCT++.C/CMakeLists.txt b/FaCT++.C/CMakeLists.txt index 93455fd..fec14d4 100644 --- a/FaCT++.C/CMakeLists.txt +++ b/FaCT++.C/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.15) set(SOURCE_FILES fact.cpp diff --git a/FaCT++.JNI/CMakeLists.txt b/FaCT++.JNI/CMakeLists.txt index 3c146d9..56a9b27 100644 --- a/FaCT++.JNI/CMakeLists.txt +++ b/FaCT++.JNI/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.15) # We are using JNI and need to #include find_package(JNI REQUIRED) diff --git a/FaCT++.Python/.gitignore b/FaCT++.Python/.gitignore index 77b9fe4..5db6e40 100644 --- a/FaCT++.Python/.gitignore +++ b/FaCT++.Python/.gitignore @@ -5,9 +5,9 @@ __pycache__/ dist/ MANIFEST -# cythonized files -pyfactxx/*.cpp -pyfactxx/*.so +# cythonized files +src/*.cpp +src/*.so # scikit-build files _skbuild/ diff --git a/FaCT++.Python/CMakeLists.txt b/FaCT++.Python/CMakeLists.txt index d372039..154d6e0 100644 --- a/FaCT++.Python/CMakeLists.txt +++ b/FaCT++.Python/CMakeLists.txt @@ -1,14 +1,16 @@ set(CMAKE_VERBOSE_MAKEFILE ON) -cmake_minimum_required(VERSION 3.13.0) +cmake_minimum_required(VERSION 3.15) set(CMAKE_CXX_STANDARD 11) -find_program(PYTHON "python") + +set(Python_FIND_VIRTUALENV FIRST) +find_package(Python3 COMPONENTS Interpreter) if (PYTHON) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") - set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/pyfactxx/__init__.py") + set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/src/__init__.py") set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") add_custom_command(OUTPUT ${OUTPUT} @@ -19,4 +21,4 @@ if (PYTHON) add_custom_target(pyfactxx-build ALL DEPENDS ${OUTPUT}) install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") -endif() \ No newline at end of file +endif() diff --git a/FaCT++.Python/MANIFEST.in b/FaCT++.Python/MANIFEST.in index 4f3040a..7fff1be 100644 --- a/FaCT++.Python/MANIFEST.in +++ b/FaCT++.Python/MANIFEST.in @@ -1,6 +1,5 @@ global-include CMakeLists.txt -prune _skbuild/ -recursive-include pyfactxx *.py *.pyx -prune pyfactxx/tests +prune _skbuild/ +recursive-include src *.py *.pyx graft lib include COPYING pyproject.toml README.md setup.py diff --git a/FaCT++.Python/pyproject.toml b/FaCT++.Python/pyproject.toml index a203ce9..bc76eb3 100644 --- a/FaCT++.Python/pyproject.toml +++ b/FaCT++.Python/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = [ - "setuptools>=42", +requires = [ + "setuptools>=64", "cython>0.25", "wheel", "scikit-build", - "cmake", + "cmake>=3.15", "ninja; platform_system!='Windows'" ] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" diff --git a/FaCT++.Python/setup.cfg b/FaCT++.Python/setup.cfg index 8c70520..cf97b83 100644 --- a/FaCT++.Python/setup.cfg +++ b/FaCT++.Python/setup.cfg @@ -8,27 +8,28 @@ maintainer_email = ir@tilde.pro url = https://github.com/tilde-lab/pyfactxx long_description = file: README.md long_description_content_type = text/markdown -license = GNU GPL 3.0 -license_files = file: COPYING +license = GPL-3.0-only +license_files = + COPYING classifiers = Development Status :: 4 - Beta Intended Audience :: Science/Research Topic :: Scientific/Engineering :: Artificial Intelligence - License :: OSI Approved :: GNU General Public License v3 (GPLv3) Programming Language :: C++ Programming Language :: Cython Programming Language :: Lisp Programming Language :: Python :: 3 - 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 + Programming Language :: Python :: 3.13 + Programming Language :: Python :: 3.14 [options] zip_safe = False include_package_data = True -python_requires = >=3.7 +python_requires = >=3.9 install_requires = rdflib tests_require = pytest, pytest-cov @@ -36,9 +37,8 @@ tests_require = pytest, pytest-cov formats = zip [tool:pytest] -addopts = --cov=pyfactxx +addopts = --cov=src [coverage:report] show_missing = 1 partial_branches = 1 - diff --git a/FaCT++.Python/setup.py b/FaCT++.Python/setup.py index a7f7996..01cc5e9 100644 --- a/FaCT++.Python/setup.py +++ b/FaCT++.Python/setup.py @@ -19,35 +19,29 @@ # along with this program. If not, see . # -import re import ast import pathlib -from skbuild import setup +import re +from skbuild import setup root = pathlib.Path(__file__).parent.resolve() DEBUG = False -_version_re = re.compile(r'__version__\s+=\s+(.*)') +_version_re = re.compile(r"__version__\s+=\s+(.*)") -with open('pyfactxx/__init__.py', 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) +with open("src/__init__.py", "rb") as f: + version = str( + ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1)) + ) -config = 'Debug' if DEBUG else 'Release' -cmake_args = [ - f'-DCMAKE_BUILD_TYPE={config}', - f'-DPYFACTXX_ROOT={root.as_posix()}' -] +config = "Debug" if DEBUG else "Release" +cmake_args = [f"-DCMAKE_BUILD_TYPE={config}", f"-DPYFACTXX_ROOT={root.as_posix()}"] setup( version=version, - packages=[ - "pyfactxx", - "pyfactxx.coras"], - package_dir={ - "pyfactxx": "pyfactxx", - "pyfactxx.coras": "pyfactxx/coras"}, - cmake_source_dir=str(root/'pyfactxx'), - cmake_args=cmake_args + packages=["pyfactxx", "pyfactxx.coras"], + package_dir={"pyfactxx": "src", "pyfactxx.coras": "src/coras"}, + cmake_source_dir=str(root / "src"), + cmake_args=cmake_args, ) diff --git a/FaCT++.Python/pyfactxx/CMakeLists.txt b/FaCT++.Python/src/CMakeLists.txt similarity index 89% rename from FaCT++.Python/pyfactxx/CMakeLists.txt rename to FaCT++.Python/src/CMakeLists.txt index 72243ab..6147375 100644 --- a/FaCT++.Python/pyfactxx/CMakeLists.txt +++ b/FaCT++.Python/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13.0) +cmake_minimum_required(VERSION 3.15) project(pyfactxx) set(CMAKE_CXX_STANDARD 11) include(CMakePrintHelpers) @@ -18,7 +18,7 @@ target_include_directories(lib_factxx PRIVATE ${FACT_DIR} Kernel) target_link_libraries(lib_factxx Kernel) python_extension_module(lib_factxx) -install(TARGETS lib_factxx LIBRARY DESTINATION pyfactxx) +install(TARGETS lib_factxx LIBRARY DESTINATION src) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) diff --git a/FaCT++.Python/pyfactxx/__init__.py b/FaCT++.Python/src/__init__.py similarity index 99% rename from FaCT++.Python/pyfactxx/__init__.py rename to FaCT++.Python/src/__init__.py index 3a64261..51019c5 100644 --- a/FaCT++.Python/pyfactxx/__init__.py +++ b/FaCT++.Python/src/__init__.py @@ -17,9 +17,8 @@ # along with this program. If not, see . # -from .lib_factxx import Reasoner # pylint: disable=no-name-in-module from .coras import Coras - +from .lib_factxx import Reasoner # pylint: disable=no-name-in-module __version__ = "1.8.1" diff --git a/FaCT++.Python/pyfactxx/coras b/FaCT++.Python/src/coras similarity index 100% rename from FaCT++.Python/pyfactxx/coras rename to FaCT++.Python/src/coras diff --git a/FaCT++.Python/pyfactxx/lib_factxx.pyx b/FaCT++.Python/src/lib_factxx.pyx similarity index 100% rename from FaCT++.Python/pyfactxx/lib_factxx.pyx rename to FaCT++.Python/src/lib_factxx.pyx diff --git a/FaCT++.Python/pyfactxx/tests/__init__.py b/FaCT++.Python/tests/__init__.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/__init__.py rename to FaCT++.Python/tests/__init__.py diff --git a/FaCT++.Python/pyfactxx/tests/conftest.py b/FaCT++.Python/tests/conftest.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/conftest.py rename to FaCT++.Python/tests/conftest.py diff --git a/FaCT++.Python/pyfactxx/tests/test_concept.py b/FaCT++.Python/tests/test_concept.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_concept.py rename to FaCT++.Python/tests/test_concept.py diff --git a/FaCT++.Python/pyfactxx/tests/test_d_role.py b/FaCT++.Python/tests/test_d_role.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_d_role.py rename to FaCT++.Python/tests/test_d_role.py diff --git a/FaCT++.Python/pyfactxx/tests/test_instance.py b/FaCT++.Python/tests/test_instance.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_instance.py rename to FaCT++.Python/tests/test_instance.py diff --git a/FaCT++.Python/pyfactxx/tests/test_o_role.py b/FaCT++.Python/tests/test_o_role.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_o_role.py rename to FaCT++.Python/tests/test_o_role.py diff --git a/FaCT++.Python/pyfactxx/tests/test_one_to_one.py b/FaCT++.Python/tests/test_one_to_one.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_one_to_one.py rename to FaCT++.Python/tests/test_one_to_one.py diff --git a/FaCT++.Python/pyfactxx/tests/test_query_instances.py b/FaCT++.Python/tests/test_query_instances.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_query_instances.py rename to FaCT++.Python/tests/test_query_instances.py diff --git a/FaCT++.Python/pyfactxx/tests/test_set_op.py b/FaCT++.Python/tests/test_set_op.py similarity index 100% rename from FaCT++.Python/pyfactxx/tests/test_set_op.py rename to FaCT++.Python/tests/test_set_op.py diff --git a/FaCT++/CMakeLists.txt b/FaCT++/CMakeLists.txt index 040bf38..305a317 100644 --- a/FaCT++/CMakeLists.txt +++ b/FaCT++/CMakeLists.txt @@ -1,5 +1,5 @@ project(FaCT++) -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.15) set(SOURCE_FILES AD.cpp diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index f287b74..1422d7e 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.15) set(SOURCE_FILES Actor.cpp diff --git a/Kernel/flags.h b/Kernel/flags.h index 418577a..213197b 100644 --- a/Kernel/flags.h +++ b/Kernel/flags.h @@ -16,6 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #ifndef FLAGS_H #define FLAGS_H