Effortless Python Configuration Files

~Humberto ~Leave a comment

See mydev.to post

Python project creation on Mac OS X

~Humberto ~Leave a comment

See my articlehere.

Signing Git Commits on Mac OS via SmartGit

~Humberto ~Leave a comment

Introduction

Between thisarticle and thisarticle, I figured out how to sign my GitHub commits.

Essentially it showed me how to:

  • Check the GPG installation
  • Check the keys
  • Configure a single repository to use a signing key
  • Verify signed commits
  • It pointed mehere for instructions on how to add my GPG key to GitHub

SmartGit

The above article pre-supposes you use the Git CLI to manage your repositories. I prefer to useSmartGit.

In SmartGit you can configure signing by typing:

Smartgit → Settings → Git config

You will see the following dialog. Enter your information.

SmartGitSigningDialog

However, commits with SmartGit failed because pinentry (pin entry, get it !) was trying to popup a terminal based UI to ask me for the signing key passphrase.

Because I usehomebrew it is rather confusing as to where to configure gpg, the gpg-agent, and pinentry. Lots of the docmentation is for Linux and to make matters worse I am on Mac OS.

Earlier documentation suggested I had to update gpg.conf to configure pinentry.

Finally found thisarticle that correctly pointed to gpg-agent.conf

Actually it said:

~/.gnupg/gpg-agent.conf

But I deduced that the homebrew configuration files resided here:

/opt/homebrew/etc/gnupg

The file did not exist so I created it. Voila, on my next check-in SmartGit popped up the OS X pin entry dialog

SmartGitSigningDialog

Next Steps

I plan to delete my demo key and generate a new one that will be my “official” signing key.

The Cliff’s notes on key generation

gpg --full-generate-key

List the key to get the signing key

gpg --list-secret-keys --keyid-format LONG

Export public to import into GitHub

gpg --armor --export [my key] > public.gpg

Verify signed commits

git log --show-signature

Py2AppSigner Version 2.0

~Humberto ~Leave a comment

Introduction

This document is an update to the 1.0 version of the utility describedhereand implemented in thisGitHubRepository. Theprevious version of this utility was written as a set of bash scripts.As such, in order to update them for current Python versions theyrequired separate scripts.

I abandoned that approach and instead implemented them as Pythonscripts that could at runtime be notified of the current Python versionand other runtime options. These scripts are meant to be installed in aPython virtual environment ascommand lineutilities.

Steps Necessary to sign Py2App Applications

I observed that thePy2Appapplication does signing of some of the libraries and components whenyou build a Python application. My experience has been that this isinsufficient. Therefore, these set of signing utilities make an effortto overwrite all necessary components with the signing developer’snotarization.

These scripts still depend on the developer generating the signedcertificates, importing them into their Apple keychain, and setting theappropriate IDENTITY environment variable as described in theoriginaldocument.

Installation

As mentioned before these utilities arePython CLIScripts.They are published topypi.Install them in your virtual environment as follows:

pip install py2appsigner

Environment Variables

These scripts depend on the following environment variables:

PROJECTS_BASE – The local directory where the python projects are basedPROJECT – The name of the project; It should be a directory nameIDENTITY – Your Apple Developer ID

Signing Steps

You must build your application prior to using these utilities.

There are four mandatory steps to sign your application and two optionalsteps.

Mandatory

The mandatory steps are:

  • Signing the internal application zip file

  • Signing the application itself

  • Notarizing the application

  • Stapling the application

Optional

The optional steps are:

  • Verifying application signing

  • Viewing the notarization details

Environment Variables

The easiest way to use the utilities is to pre-specify the followingenvironment varaibles:

  • PROJECTS_BASE – The developer’s project base directory. This is afully qualified directory name.

  • PROJECT – This is just the simple project directory name located inthe PROJECTS_BASE directory

  • IDENTITY -The developer’s Apple code signing identity (Apple must betithed). As described in thisdocumentpre-specify the environment variable for code signing simplicity.For code signing, a digital identity must be stored in a keychainthat is on the calling user’s keychain search list.

The py2appsign command line has 2 sub-commands that the developer needsto execute

  • zipsign

  • appsign

I’ll describe them in the following 2 sections.

Sign the internal zip file

Assuming you have defined the above environment variables you can usethe simple command line. The command line supports both long and shortnames for the options. This document uses them interchangeably as a wayto showcase their use.

py2appSign --python-version 3.11 --application-name Pyut --verbosezipsign

In the above example we are doing the following:

  • Specified that the project was built using Python 3.11.x

  • The application name is Pyut. This is in\${PROJECTS_BASE}/\${PROJECT}/dist/Pyut.app

Sign the Application

Again, assuming you have defined the environment variables as specifiedin section 5.3, you can use the following simple command line.

py2appSign -p 3.11 -a Pyut -v appsign

The appsign sub-command uses the same options as the zipsign command.Notice that in this example we used the short form of the option names.

Notarize the Application

This is the critical step. In this step, the utilities contact the Applecode signing servers and submit the application for a final baptism bythe ultimate high priests at the holiest of holies. At this command’scompletion it provides a submission id. Be sure to stash this id in caseyou need to query the details of the notarization process.

appNotarize -d pyut -a Pyut --verbose

Staple the Application

Once notarization successfully completes, we staple the application viathe following command.

appStaple -d pyut -a Pyut --verbose

Verify Application Signing

For the sake of developer sanity run a final verification. If this stepfails use the command in section 5.9, to investigate the root cause ofthe failure.

appVerify -d pyut -a Pyut --verbose

View the Notarization Details

Use this command to inspect the notarization details.

notaryTool information -i {submission id}

Appendix

This section is an update to the 1.0 version of this document section 4

Updated instructions to generate notarization tool APP ID

In order to run the notarization tool, you need an Application ID (APPID in Apple parlance) associated with your Apple ID.

  1. Log in to your Apple ID account page. This is not the Appledeveloper site

  2. Click on theApp-Specific Passwords link

  3. Click on the + sign

  4. Use a memorable name

  5. ClickCreate (You may have to re-login depending on your securityconfiguration)

  6. Save the generated application id for use in the next step

Save the application ID in your keychain

The command to save you application ID has changed with recent update tothe XCode SDK. The new command is

xcrun notarytool store-credentials APP_PASSWORD --apple-id {your apple ID} --password {the generated application id}--team-id {your apple developer team id}

Pyut 9.0.0 Released

~Humberto ~Leave a comment

Big updates are:

  • A new plugin that allows the developer to auto-create orthogonal routing lines.
  • Added an option to auto-resize all classes on a diagram to fit their contents
  • Lollipop interfaces are now correctly shared across multiple implementors

Release Notes

See thedemonstration video.

Get ithere

Pyut 8.5.0 Released

~Humberto ~Leave a comment

Includes a significant update to Python Reverse Engineering

See theRelease Notes

Pyut 8.4.0 Released

~Humberto ~Leave a comment

Added new feature to UML class diagrams

  • New option to display or not Python dunder methods globally or on a class by class basis
  • Added the same for__init__ Python constructor

Get it here:https://github.com/hasii2011/pyut/releases/tag/8.4.0

Pyut 8.3.0 Released

~Humberto ~Leave a comment

Updated support for Python import. Classes with multiple inheritance are now better supported and visualized

Seerelease

Pyut 8.2.0 Released

~Humberto ~Leave a comment

This release was a longer time delivering than most releases. The bump in versions number does not capture the
update. Mainly because I rushed features in, I had some bugs that had crept in that were necessary to
correct. This also meant that I had re-architect some of the plugins to allow faster and better feature implementation
and updates. That work is not yet complete but, I have fixed the significant defects that had crept in.

Other significant updates

  • PDF generation is much much better (See issues associated with PyUmlDiagrams)
  • “Open Document” from Finder works as expected now
  • Enforce source and destinations for Aggregations, Inheritance, Interfaces and Note Links
  • The XML format has been revision’ed to Version 11; Has more intuitve names
  • All software components are now updated to Python 3.11.5
  • Fixed bug where incorrect UML objects were deleted
  • Fixed bug where Pyut allowed deletion of association Labels
  • Fixed bug where association labels were not deleted when the association link was deleted
  • Fixed bug where moving links or OglAssociation labels did not mark the diagram as ‘changed’

Get the applicationhere.

The full release notes arehere

Pyut 7.7.0 Release

~Humberto ~Leave a comment

This release focused on a bunch of internal improvements to remove duplicated code across the various shared dependencies. However, there were still plenty of enhancements and bug fixes to keep us entertained


Enhancements of Note

  • Association links (composition/aggregation) now have moveable labels. The source cardinality, destination cardinality and link names labels are now auto positioned. However, the developer can move them to more asethetically pleasing positions
  • Pyut via a new plugin supports exportingClass Diagrams andSequence Diagrams to theMermaid format

Notable bug fixes

  • The beta lollipop interface has been re-enabled
  • The methods and paramters advanced list box selection not correctly diasable unavailable options
  • We re-enabled the ability to view and edit method code

Fixed Issues

Pyut

  • 492 Remove deprecated pkg_resources
  • 491 Cleanup unused files
  • 490 Update Unit Tests
  • 489 Fix downstream deprecated methods
  • 488 Fix icon path
  • 487 Update hasiicommon dependency
  • 485 Another Blunder – Forgot to do lollipop interfaces
  • 484 Fix Shared Identifier names
  • 483 PyutAdvancedListBox does not correctly disable buttons 🐛
  • 482 Use FileConfig for preferences
  • 480 Add ability to prune recently opened file list ✨
  • 479 “Put “”Code”” button back in DlgEditMethod 🐛 “
  • 478 Use new UI components from hasiicommon
  • 477 Use new Ogl Preferences 👽
  • 476 Bump dependencies
  • 475 Export to Xml does not put in XML version
  • 474 Put in try/catch in ProjectManager.openProject 🐛
  • 473 Cleanup UmlFrameShapeHandler cruft 🔥
  • 470 Sequence Diagrams Broken 🐛
  • 469 Include new plugin preferences
  • 468 Update dependencies
  • 462 Use OglPreference for parameter name
  • 461 Use New OglPreference in preferences dialog and in DlgEdit Class
  • 442 Use wx.PreferencesEditor
  • 338 Loading a file with multiple classes does not work 🐛

PyutPlugins

  • 67 Create PDF export filename preference
  • 65 Add Field support to Mermaid plugin
  • 64 Create Preferences Sized Panel
  • 63 Update TestGMLExporter 💄
  • 62 Make BaseFormat Abstract
  • 11 Update plugins to check for selected objects 🚸

Oglio

  • 15 Fix serialization and deserialization of PyutModifiers
  • 19 OglProject needs 1 more attribute

UnTanglePyut

  • 41 PyutModifiers do not deserialize correctly
  • 39 Bug in untangleXml
  • 37 ProjectInformation needs another attribute

Ogl

  • 59 Update OglPreferences UI
  • 52 Need default parameter name preference
  • 51 Need a default field name preference

PyutModel

UpdatedPyutStereotype from standard UML Profile

PyGitIssue2Todoist 1.0.0 Release

~Humberto ~Leave a comment

There was a long lag time between releases (June 2022). The motivation was to have a version that executed on the new M1 macOS Ventura. Additionally, the todoist team obsoleted version 8.x of their API. The new Python 9.x version was completely new and easier to use.

Besides the above here are the additional updates

* Usability updates
* Updated the license to AGPL
* Updated to Python 3.10.6
* Updated to wxPython 4.2
* Moved away from TravisCI to CircleCI

Download fromhere:
See therelease notes

Pyut 7.5.0 Release

~Humberto ~Leave a comment

It has been a while since the previous update. This was necessary to do many user interface improvements and internal code refactoring. These include the following:

Updates

  • Pyut uses the standard wxPython FileHistory mechanism instead of a home grown version
  • The Undo/Redo system was completely redone using the standard wxPython Command Processor mechanism. This is more reliable, robust and includes operations against all the UML artifacts
  • There is a major update to all of Pyut’s dialogs to make them conform more closely to Apple’s Human Interface Guidelines(HIG)
  • UML Class Diagrams now display the class images with a colored background. The color will be a Pyut preference in the future
  • Edit Link removed the unimplemented Roles option
  • Support for standardstereotypes when defining a class
  • Support for easier specification of class modifiers

Internal Improvements

  • Python 3.10.6
  • wxPython 4.2
  • All dialogs are SizedDialogs
  • Removed duplicated code with respect to advanced lists

See therelease notes anddownload here

In Defense of Long Source Code Lines

~Humberto ~Leave a comment

Is it just me or does any other programmer abhor many language’s code style guidelines that say, The maximum length of source code line is 80 characters.

Huh? Eighty characters. Do we still live in the time of green screen mainframe terminals? Do not get me wrong, I lived in those times and code longer than that wrapped around and made an ugly display mess.

However, here I am in the 21st century. I either have a giant 27 inch screen with which PyCharm has no problem dealing with. Or I have a dual/triple/quadruple screen setup that stretches across my gargantuan work from home desk.

So, I am over it. My default line length is 160 characters. And yes, my puny little developer mind can deal with all of that cognitive overload.

Pyut 7.0.0 Release

~Humberto ~Leave a comment

Version 7.0.0 introduces a series of major architectural changes to Pyut. The rationale was that developing big features in Pyut was becoming increasingly difficult given the state of the code. It took me several years to become comfortable with the code and to document the necessary changes.

See therelease notes

Pyut 6.8.1 Release

~Humberto ~Leave a comment
  • No functionality updates. This is just an architecture update of the Pyut UI.
  • We will use an eventing mechanism to communicate between the UI components.
  • This is a precursor to integrating external Pyut plugins which depending on an eventing mechanism.
  • Additionally, this version uses the latestwxPython (4.2.0) and a late version ofPython (3.10.6). We are trying to get on the latest version of our dependencies

See the full release notes