--- src/hugin1/hugin/huginApp.cpp.orig	2022-02-09 09:04:40.000000000 -0600
+++ src/hugin1/hugin/huginApp.cpp	2022-02-09 12:11:51.000000000 -0600
@@ -205,6 +205,19 @@
     // display always the file type list
     wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1);
 #endif
+#ifdef MACPORTS
+    // On macOS when Hugin.app is run from an application bundle the environment
+    // path doesn't inherit from the user and is set to something very limiting.
+    // Append the standard MacPorts bin location so functions like cpfind can be
+    // found.  The environment path gets used in AutoCtrlPointCreator.cpp method
+    // AutoCtrlPointCreator::automatch(...).
+    #define MACPORTS_BIN_PATH "@@MACPORTS_BIN_PATH@@"  /* Portfile may adjust */
+    wxString env_path;
+    wxGetEnv("PATH", &env_path);
+    env_path += ":";
+    env_path += MACPORTS_BIN_PATH;
+    wxSetEnv("PATH", env_path);
+#endif
 
     // register our custom pano tools dialog handlers
     registerPTWXDlgFcn();
