This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 39b2fb3d1cfc2f3593820084dadb6c6f252260f1
Author: Andrew Stitcher <[email protected]>
AuthorDate: Thu Apr 14 17:53:53 2022 -0400

    PROTON-2536: Reworked python packaging for more modern tooling
    
    - This changes the development version from 0.38.0-SNAPSHOT to
      0.38.0-dev, as this is required to be strictly PEP440 compliant
      to use directly in setup.cfg.
    - Moved Python pep8 test directly into ctests from the tox tests.
      As it's hard to control the files that are checked in the tox
      environment
---
 VERSION.txt                          |  2 +-
 python/CMakeLists.txt                | 24 +++++++++++------
 python/MANIFEST.in                   |  1 +
 python/{README.rst.in => README.rst} |  2 +-
 python/setup.cfg                     | 51 ++++++++++++++++++++++++++++++++++++
 python/{setup.py.in => setup.py}     | 43 +++---------------------------
 python/tox.ini                       | 35 +------------------------
 7 files changed, 74 insertions(+), 84 deletions(-)

diff --git a/VERSION.txt b/VERSION.txt
index 3ba63480..c05b0f07 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-0.38.0-SNAPSHOT
+0.38.0-dev
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 196378bf..698ddbe1 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -78,6 +78,9 @@ set (pysrc
     )
 # extra files included in the source distribution
 set(py_dist_files
+    setup.py
+    setup.cfg
+    README.rst
     MANIFEST.in
     setuputils/__init__.py
     setuputils/log.py
@@ -159,14 +162,6 @@ set(py_dist_dir ${CMAKE_CURRENT_BINARY_DIR}/dist)
 add_custom_target(py_src_dist ALL)
 add_dependencies(py_src_dist generated_c_files 
${SWIG_MODULE_cproton_REAL_NAME})
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README.rst.in
-               ${py_dist_dir}/README.rst
-)
-
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
-               ${py_dist_dir}/setup.py
-)
-
 add_custom_command(TARGET py_src_dist
                    COMMAND ${CMAKE_COMMAND} -E copy_directory 
${PN_C_INCLUDE_DIR} "${py_dist_dir}/include"
                    COMMAND ${CMAKE_COMMAND} -E copy_directory 
${PN_C_SOURCE_DIR}/core "${py_dist_dir}/src/core"
@@ -174,6 +169,7 @@ add_custom_command(TARGET py_src_dist
                    COMMAND ${CMAKE_COMMAND} -E copy_directory 
${PN_C_SOURCE_DIR}/platform "${py_dist_dir}/src/platform"
                    COMMAND ${CMAKE_COMMAND} -E copy_directory 
${PN_C_SOURCE_DIR}/ssl "${py_dist_dir}/src/ssl"
                    COMMAND ${CMAKE_COMMAND} -E copy_directory 
${PN_C_SOURCE_DIR}/sasl "${py_dist_dir}/src/sasl"
+                   COMMAND ${CMAKE_COMMAND} -E copy 
${CMAKE_SOURCE_DIR}/VERSION.txt "${py_dist_dir}"
                    COMMAND ${CMAKE_COMMAND} -E copy 
${PN_C_SOURCE_DIR}/encodings.h "${py_dist_dir}/src"
                    COMMAND ${CMAKE_COMMAND} -E copy 
${PN_C_SOURCE_DIR}/protocol.h "${py_dist_dir}/src")
 
@@ -244,6 +240,18 @@ pn_add_test(
       ${python_coverage_options}
       ${PYTHON_TEST_COMMAND} discover -v -s "${py_tests}/integration")
 
+check_python_module("flake8" FLAKE_MODULE_FOUND)
+if (FLAKE_MODULE_FOUND)
+  option(ENABLE_PEP8_TEST "Enable pep8 python testing with flake8" ON)
+  if (ENABLE_PEP8_TEST)
+    pn_add_test(
+      INTERPRETED
+      NAME python-pep8-test
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+      COMMAND ${Python_EXECUTABLE} -m flake8)
+  endif ()
+endif ()
+
 check_python_module("tox" TOX_MODULE_FOUND)
 if (NOT TOX_MODULE_FOUND)
   message(STATUS "The tox tool is not available; skipping the 
python-tox-tests")
diff --git a/python/MANIFEST.in b/python/MANIFEST.in
index 250083b0..35558b54 100644
--- a/python/MANIFEST.in
+++ b/python/MANIFEST.in
@@ -1,3 +1,4 @@
+include VERSION.txt
 graft docs
 graft setuputils
 graft src
diff --git a/python/README.rst.in b/python/README.rst
similarity index 78%
rename from python/README.rst.in
rename to python/README.rst
index 8be1dd31..9c7310c8 100644
--- a/python/README.rst.in
+++ b/python/README.rst
@@ -1,7 +1,7 @@
 Python bindings for Qpid Proton
 ===============================
 
-This module provides version 
@PN_VERSION_MAJOR@.@PN_VERSION_MINOR@.@PN_VERSION_POINT@ of the Proton AMQP 
messaging toolkit.
+This module provides a Python binding to the Proton AMQP messaging toolkit.
 
 Qpid Proton is a high-performance, lightweight messaging library. It
 can be used in the widest range of messaging applications, including
diff --git a/python/setup.cfg b/python/setup.cfg
new file mode 100644
index 00000000..26ec60cb
--- /dev/null
+++ b/python/setup.cfg
@@ -0,0 +1,51 @@
+[metadata]
+version = file: VERSION.txt
+description = An AMQP based messaging library.
+long_description = file: README.rst
+author = Apache Qpid
+author_email = [email protected]
+url = http://qpid.apache.org/proton/
+license = Apache Software License
+classifiers =
+  License :: OSI Approved :: Apache Software License
+  Intended Audience :: Developers
+  Programming Language :: Python
+  Programming Language :: Python :: 3
+  Programming Language :: Python :: 3 :: Only
+  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
+
+[options]
+packages = proton
+py_modules = cproton
+
+[options.extras_require]
+opentracing = opentracing; jaeger_client
+
+[flake8]
+# TODO(PROTON-2322) decrease the limit
+max-line-length = 150
+
+# TODO(PROTON-2322) re-enable all these warnings
+ignore =
+    # do not use bare 'except'
+    E722,
+    # imported but unused
+    F401,
+    # ambiguous variable name 'l'
+    E741,
+    # local variable 'int_nodes' is assigned to but never used
+    F841,
+    # TODO(PROTON-2322) decide which of these two warnings we want disabled
+    #  _transport.py:908:21: W503 line break before binary operator
+    #  _transport.py:907:56: W504 line break after binary operator
+    W504,
+
+exclude =
+    # TODO(PROTON-2095) generated by SWIG
+    cproton.py,
+    # ignore the tests as they are not shipped
+    tests
diff --git a/python/setup.py.in b/python/setup.py
similarity index 81%
rename from python/setup.py.in
rename to python/setup.py
index f658064a..f677570a 100644
--- a/python/setup.py.in
+++ b/python/setup.py
@@ -31,18 +31,6 @@ using the installed Qpid Proton C library and header files. 
If the library and
 headers are not installed, or the installed version does not match the version
 of these python bindings, then the script will attempt to build the extension
 using the Proton C sources included in the python source distribution package.
-
-While the above removes the need of *always* having Qpid Proton C development
-files installed, it does not solve the need of having `swig` and the libraries
-qpid-proton requires installed to make this setup work.
-
-From the Python side, this scripts overrides 1 command - build_ext - and it 
adds a
-new one. The latter - Configure - is called from the former to setup/discover 
what's
-in the system. The rest of the commands and steps are done normally without 
any kind
-of monkey patching.
-
-TODO: On windows we now only support VS2015 and above and python 3, we should 
check
-for this and produce an appropriate error if the requirements are not met.
 """
 
 import os
@@ -54,10 +42,6 @@ from setuputils import log
 from setuputils import misc
 
 
-_PROTON_VERSION = (@PN_VERSION_MAJOR@, @PN_VERSION_MINOR@, @PN_VERSION_POINT@)
-_PROTON_VERSION_STR = "%d.%d.%d" % _PROTON_VERSION
-
-
 class BuildExtension(build_ext):
     description = "Build Qpid Proton extension"
 
@@ -167,11 +151,11 @@ class BuildExtension(build_ext):
         _cproton.libraries = libraries
         _cproton.extra_compile_args = ['-DPROTON_DECLARE_STATIC']
 
-    def libqpid_proton_installed(self, version):
+    def libqpid_proton_installed(self):
         """Check to see if the proper version of the Proton development library
         and headers are already installed
         """
-        return misc.pkg_config_version_installed('libqpid-proton-core', 
version)
+        return misc.pkg_config_version_installed('libqpid-proton-core', 
atleast='0')
 
     def use_installed_proton(self):
         """The Proton development headers and library are installed, update the
@@ -190,7 +174,7 @@ class BuildExtension(build_ext):
     def build_extensions(self):
         # check if the Proton library and headers are installed and are
         # compatible with this version of the binding.
-        if self.libqpid_proton_installed(_PROTON_VERSION_STR):
+        if self.libqpid_proton_installed():
             self.use_installed_proton()
         else:
             # Proton not installed or compatible, use bundled proton-c sources
@@ -199,30 +183,9 @@ class BuildExtension(build_ext):
 
 
 setup(name='python-qpid-proton',
-      version=_PROTON_VERSION_STR + os.environ.get('PROTON_VERSION_SUFFIX', 
''),
-      description='An AMQP based messaging library.',
-      author='Apache Qpid',
-      author_email='[email protected]',
-      url='http://qpid.apache.org/proton/',
-      packages=['proton'],
-      py_modules=['cproton'],
-      license="Apache Software License",
-      classifiers=["License :: OSI Approved :: Apache Software License",
-                   "Intended Audience :: Developers",
-                   "Programming Language :: Python",
-                   "Programming Language :: Python :: 3",
-                   "Programming Language :: Python :: 3 :: Only",
-                   "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"],
       cmdclass={
           'build_ext': BuildExtension
       },
-      extras_require={
-          'opentracing': ['opentracing', 'jaeger_client']
-      },
       # Note well: the following extension instance is modified during the
       # installation!  If you make changes below, you may need to update the
       # Configure class above
diff --git a/python/tox.ini b/python/tox.ini
index f0ae06e6..832b53df 100644
--- a/python/tox.ini
+++ b/python/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 # This will be overridden by ctest setting TOXENV for anything but this default
-envlist = pep8,py36,py37,py38,py39,py310
+envlist = py36,py37,py38,py39,py310
 minversion = 1.7.2
 setupdir = {toxinidir}/dist
 skip_missing_interpreters = True
@@ -19,39 +19,6 @@ passenv =
 commands =
     python {env:PY_TEST_DIR}/proton-test {posargs:--ignore-file 
"{env:PY_TEST_DIR}/tox-blacklist"}
 
-[testenv:pep8]
-deps =
-    flake8
-changedir = {[tox]setupdir}
-commands = flake8
-
-[flake8]
-# TODO(PROTON-2322) decrease the limit
-max-line-length = 150
-
-# TODO(PROTON-2322) re-enable all these warnings
-ignore =
-    # do not use bare 'except'
-    E722,
-    # imported but unused
-    F401,
-    # 'from proton import *' used; unable to detect undefined names
-    F403,
-    # may be undefined, or defined from star imports: proton
-    F405,
-    # ambiguous variable name 'l'
-    E741,
-    # local variable 'int_nodes' is assigned to but never used
-    F841,
-    # TODO(PROTON-2322) decide which of these two warnings we want disabled
-    #  _transport.py:908:21: W503 line break before binary operator
-    #  _transport.py:907:56: W504 line break after binary operator
-    W504,
-
-exclude =
-    # TODO(PROTON-2095) generated by SWIG
-    cproton.py,
-
 [testenv:docs]
 deps =
     sphinx


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to