<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: enzo cocca</title>
    <description>The latest articles on DEV Community by enzo cocca (@enzo_cocca_d5689569fc7186).</description>
    <link>https://dev.to/enzo_cocca_d5689569fc7186</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1532047%2F0f64ccc6-8f3f-48ad-acab-02813ee4d27c.png</url>
      <title>DEV Community: enzo cocca</title>
      <link>https://dev.to/enzo_cocca_d5689569fc7186</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/enzo_cocca_d5689569fc7186"/>
    <language>en</language>
    <item>
      <title>Adding a Python extension to a photogrammetry application: the documented workflow</title>
      <dc:creator>enzo cocca</dc:creator>
      <pubDate>Fri, 30 Oct 2026 12:13:51 +0000</pubDate>
      <link>https://dev.to/enzo_cocca_d5689569fc7186/adding-a-python-extension-to-a-photogrammetry-application-the-documented-workflow-3nim</link>
      <guid>https://dev.to/enzo_cocca_d5689569fc7186/adding-a-python-extension-to-a-photogrammetry-application-the-documented-workflow-3nim</guid>
      <description>&lt;p&gt;This walkthrough describes the plugin interface in my PyArchInit Photogrammetry project. It follows the existing plugin documentation: generating a package, registering it through a Python entry point, developing it locally, and distributing a wheel.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/enzococca/pyarchinit-photogrammetry" rel="noopener noreferrer"&gt;core repository&lt;/a&gt; contains the photogrammetry application and API. The &lt;a href="https://github.com/enzococca/pyarchinit-photogrammetry-plugins" rel="noopener noreferrer"&gt;plugin repository&lt;/a&gt; contains the plugin index, a template and specialist extensions. Keeping these separate lets a plugin have its own repository and releases.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Start with a generated package
&lt;/h2&gt;

&lt;p&gt;In an environment with a compatible installation of the application, the documented generator command is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ppg plugins new chunk-summary &lt;span class="nt"&gt;--dir&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--parts&lt;/span&gt; &lt;span class="nb"&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generator supports several starting components: &lt;code&gt;action&lt;/code&gt;, &lt;code&gt;background&lt;/code&gt;, &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;exporter&lt;/code&gt;. It creates a package, tests, documentation and a release workflow. Pick the components the extension needs rather than adding a user interface to a command-only task.&lt;/p&gt;

&lt;p&gt;For a minimal manually created package, discovery is configured in &lt;code&gt;pyproject.toml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="k"&gt;[&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="k"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entry-points&lt;/span&gt;&lt;span class="k"&gt;.&lt;/span&gt;&lt;span class="s"&gt;"pyarchinit_photogrammetry.plugins"&lt;/span&gt;&lt;span class="k"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;chunk-summary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"ppg_chunk_summary:SummaryPlugin"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The entry-point group is the application's discovery mechanism. The value points to the plugin class in the Python package; it does not require adding an import to the application's core.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Register a command when the plugin activates
&lt;/h2&gt;

&lt;p&gt;The documented base class receives a context in &lt;code&gt;activate&lt;/code&gt;. This small example adapts the summary example in the plugin guide:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pyarchinit_photogrammetry.plugins&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Plugin&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SummaryPlugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Plugin&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Chunk summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Counts the photos and markers in a project chunk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;summary&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize a project chunk&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyarchinit_photogrammetry&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ppg&lt;/span&gt;

        &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ppg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Photos: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cameras&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Aligned photos: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aligned_cameras&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Markers: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;markers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;context.add_command&lt;/code&gt; makes the callback available through the application's plugin command group. Its positional arguments arrive as strings, and an integer return value becomes the exit code.&lt;/p&gt;

&lt;p&gt;An action uses &lt;code&gt;context.add_action&lt;/code&gt;, and an export format uses &lt;code&gt;context.add_exporter&lt;/code&gt;. These are separate registrations, so an extension can expose one or several ways to use the same underlying operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Develop in the application's Python environment
&lt;/h2&gt;

&lt;p&gt;From the plugin project directory, the guide's local development steps are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
pytest &lt;span class="nt"&gt;-q&lt;/span&gt; tests
ppg plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The editable installation must use the Python environment running the application. &lt;code&gt;ppg plugin&lt;/code&gt; lists the registered plugin commands. After installing a desktop extension, restart the application so it can discover the package.&lt;/p&gt;

&lt;p&gt;These are documented instructions and an illustrative code adaptation, rather than a report of a fresh execution or benchmark for this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keep background work separate from widgets
&lt;/h2&gt;

&lt;p&gt;For longer tasks, the context provides &lt;code&gt;run(title, function, done=None)&lt;/code&gt;. The work function receives a progress callback; the completion callback runs in the interface thread. The plugin guide specifically keeps widget access in interface callbacks rather than the worker function.&lt;/p&gt;

&lt;p&gt;A useful consequence is that numerical processing can remain separate from interface updates. The same extension can provide a CLI command while adding a progress-reporting action to the desktop application.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Distribute with explicit compatibility metadata
&lt;/h2&gt;

&lt;p&gt;For installation through the application's plugin manager, build a pure-Python wheel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; build &lt;span class="nt"&gt;--wheel&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index entry records the plugin's entry-point name, version, API version, minimum application version, dependencies, download URL and SHA-256. The application checks the wheel against the index hash. Plugins execute with the application's permissions; a matching hash verifies the downloaded artifact, not whether its code is safe.&lt;/p&gt;

&lt;p&gt;A plugin using a newer context method must declare a minimum application version that provides it. The guide annotates those methods with their introduction versions.&lt;/p&gt;

&lt;p&gt;For the full interface and distribution procedure, see the &lt;a href="https://github.com/enzococca/pyarchinit-photogrammetry/blob/main/docs/plugins.md" rel="noopener noreferrer"&gt;plugin guide&lt;/a&gt;. The &lt;a href="https://github.com/enzococca/pyarchinit-photogrammetry-plugins" rel="noopener noreferrer"&gt;plugin repository&lt;/a&gt; provides the template and examples of terrain, geophysics, geoarchaeology and GIS archive extensions.&lt;/p&gt;

&lt;p&gt;Disclosure: this article was generated by an AI agent using the author's existing project documentation. The code is adapted from the documented example.&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
