diff --git a/.github/workflows/image-main.yml b/.github/workflows/image-main.yml index 17470aab3..eb9646a91 100644 --- a/.github/workflows/image-main.yml +++ b/.github/workflows/image-main.yml @@ -49,8 +49,8 @@ jobs: - run: | # build and publish the main image - # Use {GITHUB_SHA::8} for shorter SHA - export VERSION="${GITHUB_SHA}" + # The version on main will be 0.0.0+-main + export VERSION="0.0.0+${GITHUB_SHA}-main" ./.github/scripts/image.sh env: CONTAINER_USER: '${{ secrets.DOCKER_USER }}' diff --git a/CMakeLists.txt b/CMakeLists.txt index a11d13726..843f5be09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,34 +152,34 @@ if(NOT DEFINED VERSION) # Git succeeded, we will use the DEFAULT_VERSION as the QPID_DISPATCH_VERSION set(QPID_DISPATCH_VERSION ${DEFAULT_VERSION}) else() - # The git command failed, set QPID_DISPATCH_VERSION to "UNKNOWN" - set(QPID_DISPATCH_VERSION "UNKNOWN") + # The git command failed, set QPID_DISPATCH_VERSION to "0.0.0" + set(QPID_DISPATCH_VERSION "0.0.0") endif(GIT_RESULT EQUAL 0) else(BRANCH_NAME STREQUAL "HEAD") - # If the BRANCH_NAME is not HEAD, get the commit sha of the latest commit and - # set that as the version. + # If the BRANCH_NAME is not HEAD (means you are on a branch, get the commit sha of the latest commit and + # set the version as 0.0.0+-branch name. This is PEP 440 compliant. # For example, if you are on the main branch and the most recent commit is 68df4e1346b9238ef8f71b9ae0dcdd49eec73c9a, - # the router version will print as 68df4e1346b9238ef8f71b9ae0dcdd49eec73c9a(main) + # the router version will print as 0.0.0+68df4e1346b9238ef8f71b9ae0dcdd49eec73c9a-main execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE COMMIT_SHA OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "COMMIT_SHA is ${COMMIT_SHA}") - set(QPID_DISPATCH_VERSION "${COMMIT_SHA}(${BRANCH_NAME})") + set(QPID_DISPATCH_VERSION "0.0.0+${COMMIT_SHA}-${BRANCH_NAME}") endif(BRANCH_NAME STREQUAL "HEAD") else(Git_FOUND) - # Git executable was not available, we will not be able to determine the version, just set it to "UNKNOWN" - set(QPID_DISPATCH_VERSION "UNKNOWN") + # Git executable was not available, we will not be able to determine the version, just set it to "0.0.0" + set(QPID_DISPATCH_VERSION "0.0.0") endif(Git_FOUND) else(NOT DEFINED VERSION) # What if VERSION is defined but someone passed in an empty value for VERSION? Deal with that case here. if (VERSION STREQUAL "") - set(QPID_DISPATCH_VERSION "UNKNOWN") + set(QPID_DISPATCH_VERSION "0.0.0") else() string(STRIP ${VERSION} VERSION) if (VERSION STREQUAL "") - set(QPID_DISPATCH_VERSION "UNKNOWN") + set(QPID_DISPATCH_VERSION "0.0.0") else() set(QPID_DISPATCH_VERSION ${VERSION}) endif() diff --git a/Containerfile b/Containerfile index cb2ff247b..102825162 100644 --- a/Containerfile +++ b/Containerfile @@ -39,7 +39,7 @@ ENV LWS_SOURCE_URL=${LWS_SOURCE_URL:-https://github.com/warmcat/libwebsockets/ar ENV LIBUNWIND_SOURCE_URL=${LIBUNWIND_SOURCE_URL:-https://github.com/libunwind/libunwind/archive/refs/tags/${LIBUNWIND_VERSION}.tar.gz} ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig -ARG VERSION=UNKNOWN +ARG VERSION=0.0.0 ENV VERSION=$VERSION RUN .github/scripts/compile.sh RUN tar zxpf /qpid-proton-image.tar.gz --one-top-level=/image && tar zxpf /skupper-router-image.tar.gz --one-top-level=/image && tar zxpf /libwebsockets-image.tar.gz --one-top-level=/image && tar zxpf /libunwind-image.tar.gz --one-top-level=/image diff --git a/packaging/skupper-router.spec b/packaging/skupper-router.spec index 510e7b608..6cd785799 100644 --- a/packaging/skupper-router.spec +++ b/packaging/skupper-router.spec @@ -44,7 +44,7 @@ %global libunwind_minimum_version 1.3.1 Name: skupper-router -Version: 2.x.y +Version: 0.0.0 Release: 1%{?dist} Summary: The skrouterd router daemon for Skupper.io License: ASL 2.0 @@ -65,6 +65,7 @@ BuildRequires: cmake # skupper-router requirements BuildRequires: python3-devel BuildRequires: python3-setuptools +BuildRequires: python3-pip BuildRequires: libwebsockets-devel >= %{libwebsockets_minimum_version} BuildRequires: libnghttp2-devel >= %{libnghttp2_minimum_version} BuildRequires: libunwind-devel >= %{libunwind_minimum_version} diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9af63a2fc..6fcbc24d8 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,15 +20,29 @@ # Private python modules, not in standard python site dir. install(DIRECTORY skupper_router_internal DESTINATION ${QPID_DISPATCH_HOME}/python) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in - ${CMAKE_CURRENT_BINARY_DIR}/setup.py) +# Copy the public python modules into a build/python/src folder. +# We do this because, pip install, by default, will look into a src folder +# and automatically figure out python packaging and installs the files +# in the appropriate location. -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/skupper_router_site.py.in - ${CMAKE_CURRENT_BINARY_DIR}/skupper_router_site.py) +add_custom_target(NAME ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_CURRENT_BINARY_DIR}/src/skupper_router + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/_skupper_router_site.py ${CMAKE_CURRENT_BINARY_DIR}/src/skupper_router) -# Install script for public python modules -install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py -v install --single-version-externally-managed --record=/dev/null --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") +configure_file(${CMAKE_SOURCE_DIR}/python/skupper_router/_skupper_router_site.py.in + ${CMAKE_CURRENT_BINARY_DIR}/_skupper_router_site.py) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml.in + ${CMAKE_CURRENT_BINARY_DIR}/pyproject.toml) + +# Use pip install to install the public python modules. +# --compile option compiles Python source files to bytecode +install(CODE + "execute_process( \ + COMMAND ${Python_EXECUTABLE} -m pip install ${CMAKE_CURRENT_BINARY_DIR} --ignore-installed --verbose --compile --prefix=\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX} \ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} \ + COMMAND_ECHO STDOUT \ + COMMAND_ERROR_IS_FATAL ANY)") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/skupper_router/management/skrouter.json ${CMAKE_CURRENT_SOURCE_DIR}/skupper_router/management/skrouter.json.readme.txt diff --git a/python/pyproject.toml.in b/python/pyproject.toml.in new file mode 100644 index 000000000..aa328bfa3 --- /dev/null +++ b/python/pyproject.toml.in @@ -0,0 +1,46 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +[project] +name="skupper_router" +description = "Skupper Router tools and libraries" +version = '${QPID_DISPATCH_VERSION}' +authors = [ + { name = "Skupper Project", email = "skupper@googlegroups.com" } +] +requires-python = ">=3.9" + +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.skupper_router] +homepage = "https://skupper.io/" +repository = "https://github.com/skupperproject/skupper-router/" + +[tool.setuptools] +# By default, include-package-data is true in pyproject.toml, so you do +# NOT have to specify this line. +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +"*" = ["*.json"] diff --git a/python/setup.py.in b/python/setup.py.in deleted file mode 100755 index d0b87f3d0..000000000 --- a/python/setup.py.in +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -from setuptools import setup -from setuptools.command.build_py import build_py -from os.path import join -from os import environ - -"""Install public packages and scripts for Qpid Dispatch.""" - - -class BuildPy(build_py): - """Extend standard build command, add generated modules from binary directory.""" - - MODULES = ['skupper_router_site.py'] - - def run(self): - build_py.run(self) # Run the standard build, copies source .py files into builddir - for m in self.MODULES: - build_py.copy_file(self, join('${CMAKE_CURRENT_BINARY_DIR}', m), join(self.build_lib, m)) - - def get_outputs(self, **kwargs): - return build_py.get_outputs(self, **kwargs) + [join(self.build_lib, m) for m in self.MODULES] - - -options = {} -destdir = environ.get("DESTDIR") -if destdir: - options["install"] = {"root": destdir} - -setup( - options=options, - - name='skupper_router', - description='Skupper Router tools and libraries.', - package_dir={'' : '${CMAKE_SOURCE_DIR}/python'}, - packages=['skupper_router', 'skupper_router.management'], - package_data={'skupper_router.management': ['*.json']}, - cmdclass={'build_py': BuildPy}, - - version='${QPID_DISPATCH_VERSION}', - author='Skupper Project', - author_email='skupper@googlegroups.com', - url='https://skupper.io/', - license='Apache Software License', - - zip_safe=False, -) diff --git a/python/skupper_router_site.py.in b/python/skupper_router/_skupper_router_site.py.in similarity index 100% rename from python/skupper_router_site.py.in rename to python/skupper_router/_skupper_router_site.py.in diff --git a/python/skupper_router_internal/management/agent.py b/python/skupper_router_internal/management/agent.py index 5fe807774..65e77ad73 100644 --- a/python/skupper_router_internal/management/agent.py +++ b/python/skupper_router_internal/management/agent.py @@ -74,7 +74,7 @@ from ctypes import c_void_p, py_object, c_long -import skupper_router_site +from skupper_router._skupper_router_site import SKIP_DELETE_HTTP_LISTENER from skupper_router.management.entity import camelcase from skupper_router.management.error import ManagementError, OK, CREATED, NO_CONTENT, STATUS_TEXT, \ BadRequestStatus, InternalServerErrorStatus, NotImplementedStatus, NotFoundStatus @@ -424,7 +424,7 @@ def __str__(self): return super(ListenerEntity, self).__str__().replace("Entity(", "ListenerEntity(") def _delete(self): - if self.http and skupper_router_site.SKIP_DELETE_HTTP_LISTENER: + if self.http and SKIP_DELETE_HTTP_LISTENER: raise BadRequestStatus("HTTP listeners cannot be deleted") self._qd.qd_connection_manager_delete_listener(self._dispatch, self._implementations[0].key) diff --git a/python/skupper_router_internal/tools/command.py b/python/skupper_router_internal/tools/command.py index df6cb35c7..5538cdb4b 100644 --- a/python/skupper_router_internal/tools/command.py +++ b/python/skupper_router_internal/tools/command.py @@ -24,7 +24,7 @@ import argparse import os -from skupper_router_site import VERSION +from skupper_router._skupper_router_site import VERSION from proton import SSLDomain, Url diff --git a/run.py.in b/run.py.in index 090472843..ceca55db0 100755 --- a/run.py.in +++ b/run.py.in @@ -41,8 +41,8 @@ run.py --sh # Print a shell script to set the run extra_paths = [ + "${CMAKE_BINARY_DIR}/python/src", "${CMAKE_SOURCE_DIR}/python", - "${CMAKE_BINARY_DIR}/python", "${CMAKE_SOURCE_DIR}/tests" ] diff --git a/tests/python-checker.sh.in b/tests/python-checker.sh.in index 11f9209fc..053794fdc 100644 --- a/tests/python-checker.sh.in +++ b/tests/python-checker.sh.in @@ -19,9 +19,9 @@ set -exo pipefail echo ----Starting flake8 checks---- -flake8 --verbose --count --show-source ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/skupper_router_site.py ${CMAKE_SOURCE_DIR}/tools/skstat ${CMAKE_SOURCE_DIR}/tools/skmanage +flake8 --verbose --count --show-source ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/_skupper_router_site.py ${CMAKE_SOURCE_DIR}/tools/skstat ${CMAKE_SOURCE_DIR}/tools/skmanage echo ----Starting pylint checks---- -pylint --jobs 4 --rcfile ${CMAKE_BINARY_DIR}/tests/pylintrc --ignore friendship_server.py,friendship_pb2.py,friendship_pb2_grpc.py ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/skupper_router_site.py ${CMAKE_SOURCE_DIR}/tools/skstat ${CMAKE_SOURCE_DIR}/tools/skmanage +pylint --jobs 4 --rcfile ${CMAKE_BINARY_DIR}/tests/pylintrc --ignore friendship_server.py,friendship_pb2.py,friendship_pb2_grpc.py ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/_skupper_router_site.py ${CMAKE_SOURCE_DIR}/tools/skstat ${CMAKE_SOURCE_DIR}/tools/skmanage echo ----Starting mypy checks---- -#mypy --verbose --config-file ${CMAKE_BINARY_DIR}/tests/mypy.ini ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/skupper_router_site.py +#mypy --verbose --config-file ${CMAKE_BINARY_DIR}/tests/mypy.ini ${CMAKE_SOURCE_DIR}/python/skupper_router ${CMAKE_SOURCE_DIR}/python/skupper_router_internal ${CMAKE_SOURCE_DIR}/docs ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/scripts ${CMAKE_BINARY_DIR}/python/_skupper_router_site.py diff --git a/tests/system_tests_http.py b/tests/system_tests_http.py index 9bd6c8ea0..360a28f6f 100644 --- a/tests/system_tests_http.py +++ b/tests/system_tests_http.py @@ -25,7 +25,7 @@ from urllib.request import urlopen, build_opener, HTTPSHandler from urllib.error import HTTPError, URLError -import skupper_router_site +from skupper_router._skupper_router_site import SKIP_DELETE_HTTP_LISTENER from system_test import Process, QdManager, retry from system_test import TestCase, Qdrouterd, main_module, DIR from system_test import unittest, AMQP_LISTENER_TYPE, ALLOCATOR_TYPE @@ -46,7 +46,7 @@ def ssl_file(name): def setUpClass(cls): super(RouterTestHttp, cls).setUpClass() # DISPATCH-1513, DISPATCH-2299: Http listener delete was broken in LWS v4 until v4.2.0 - cls.skip_delete_http_listener_test = skupper_router_site.SKIP_DELETE_HTTP_LISTENER + cls.skip_delete_http_listener_test = SKIP_DELETE_HTTP_LISTENER @classmethod def get(cls, url, use_ca=True): diff --git a/tools/skmanage b/tools/skmanage index 045490d57..aecd67f0b 100755 --- a/tools/skmanage +++ b/tools/skmanage @@ -24,8 +24,8 @@ import json import re from collections.abc import Mapping, Sequence -import skupper_router_site -skupper_router_site.populate_pythonpath() +from skupper_router._skupper_router_site import populate_pythonpath +populate_pythonpath() from skupper_router.management.client import Node from skupper_router_internal.tools.command import (UsageError, _skmanage_parser, check_args, diff --git a/tools/skstat b/tools/skstat index 1e02d9ff5..d559fc64d 100755 --- a/tools/skstat +++ b/tools/skstat @@ -23,8 +23,8 @@ import sys from datetime import datetime from time import ctime, strftime, gmtime -import skupper_router_site -skupper_router_site.populate_pythonpath() +from skupper_router._skupper_router_site import populate_pythonpath +populate_pythonpath() from skupper_router.management.client import Node from skupper_router_internal.management.qdrouter import QdSchema