Skip to content

Conversation

aUsABuisnessman
Copy link

@aUsABuisnessman aUsABuisnessman commented Sep 11, 2025

Summary of changes

Closes

Pull Request Checklist

Summary by Sourcery

Enable static library builds with metadata support and enhance Nuitka-Python compatibility by disabling shared libraries, adjusting compiler/linker behavior, and updating packaging tags, plus introduce Pylint CI workflow.

New Features:

  • Add Pylint GitHub Actions workflow for code analysis.

Enhancements:

  • Switch build_ext to create static libraries and emit .link.json metadata while copying .lib files.
  • Disable shared library builds for Nuitka-Python and integrate extra_midargs support in linking routines.
  • Adapt Unix and MSVC compilers to use sysconfig toolchain settings, normalize SOABI tags, and configure MSVC to use the /MT runtime.

CI:

  • Add .github/workflows/pylint.yml to run Pylint on all Python files.

Copy link

sourcery-ai bot commented Sep 11, 2025

Reviewer's Guide

Refactors build and link processes to default to static libraries with metadata output, disable shared library support, adjust compiler configurations for Nuitka-Python, improve library resolution, and introduce a Pylint CI workflow.

Sequence diagram for static library build and metadata output

sequenceDiagram
  participant BuildExt as "build_ext.py:build_extension()"
  participant Compiler as "Compiler"
  participant FS as "Filesystem"
  BuildExt->>Compiler: create_static_lib(objects, ext_path, ...)
  Compiler->>FS: Write static library file
  BuildExt->>Compiler: library_filename(ext_path, output_dir)
  Compiler->>FS: Return library filename
  BuildExt->>FS: Write metadata to result_path.link.json
Loading

Sequence diagram for library file resolution and installation

sequenceDiagram
  participant BuildExt as "build_ext.py:build_extension()"
  participant FS as "Filesystem"
  loop for each library
    loop for each library_dir
      BuildExt->>FS: Check if lib file exists in dir
      alt If file exists and dir is relative
        BuildExt->>FS: Create install dir if needed
        BuildExt->>FS: Copy lib file to install dir
      end
    end
  end
Loading

Class diagram for updated UnixCCompiler and CCompiler methods

classDiagram
  class UnixCCompiler {
    +executables
    +link(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, build_temp, target_lang, extra_midargs)
    +find_library_file(dirs, lib, debug=False)
  }
  class CCompiler {
    +link(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, build_temp, target_lang, extra_midargs)
    +link_shared_lib(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, build_temp, target_lang)
    +link_shared_object(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, build_temp, target_lang)
    +link_executable(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, target_lang, extra_midargs)
    +library_filename(libname, lib_type, strip_dir)
    +gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries)
  }
  UnixCCompiler --|> CCompiler
Loading

Class diagram for updated MSVCCompiler methods

classDiagram
  class MSVCCompiler {
    +initialize(plat_name=None)
    +link(objects, output_dir, libraries, library_dirs, runtime_library_dirs, extra_preargs, extra_postargs, build_temp, target_lang, extra_midargs)
    +library_option(lib)
    +find_library_file(dirs, lib, debug=False)
    +compile_options
    +compile_options_debug
    +dumpbin
  }
Loading

File-Level Changes

Change Details Files
Refactored build_ext to create static libs and emit link metadata
  • Replaced shared object linking with static library creation
  • Generated a .link.json file containing link parameters
  • Copied .lib files from library directories to install paths
setuptools/_distutils/command/build_ext.py
setuptools/command/build_ext.py
Disabled shared library support throughout the toolchain
  • Bypass SWIG stub path with always-false condition
  • Raised NotImplementedError in link_shared_lib and link_shared_object methods
  • Removed shared lib building branches
setuptools/command/build_ext.py
setuptools/_distutils/ccompiler.py
setuptools/_distutils/_msvccompiler.py
Adjusted compiler configurations for Nuitka-Python
  • Set CC/CXX and linker executables from sysconfig vars
  • Added extra_midargs parameter and handling in link methods
  • Enforced no shared libs in UnixCCompiler by raising NotImplemented
setuptools/_distutils/unixccompiler.py
setuptools/_distutils/ccompiler.py
Enhanced library resolution logic
  • Prefer .a static libraries in gen_lib_options
  • MSVC find_library_file supports direct .lib files in single directory
  • Return normalized SOABI from packaging.tags
setuptools/_distutils/ccompiler.py
setuptools/_distutils/_msvccompiler.py
setuptools/_vendor/packaging/tags.py
Filtered out unwanted include flags in sysconfig
  • Removed -I paths containing Nuitka-Python dependencies from cflags
setuptools/_distutils/sysconfig.py
Added a Pylint GitHub Actions workflow
  • Created .github/workflows/pylint.yml to run Pylint across Python versions
.github/workflows/pylint.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


result_path = self.library_filename(basename, output_dir=os.path.abspath("."))

with open(result_path + '.link.json', 'w') as f:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Use f-string instead of string concatenation [×4] (use-fstring-for-concatenation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants