making it easier to add linked projects core_developer_branch
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sun, 31 May 2026 14:38:50 +0000 (14:38 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Sun, 31 May 2026 14:38:50 +0000 (14:38 +0000)
administrator/tool/install_Python [new file with mode: 0755]
setup
shared/tool/PATH.sh [new file with mode: 0644]
shared/tool/setup
shared/tool/version

diff --git a/administrator/tool/install_Python b/administrator/tool/install_Python
new file mode 100755 (executable)
index 0000000..bfc18df
--- /dev/null
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# Enforce execution for this administrative tool
+if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then
+  echo "$script_afp:: This script must be executed, not sourced."
+  return 1
+fi
+
+# without this bash takes non-matching globs literally
+shopt -s nullglob
+
+# does not presume sharing or world permissions
+umask 0077
+
+# Ensure required environment variables exist
+if [[ -z "$REPO_HOME" || -z "$PROJECT" ]]; then
+  echo "Error: REPO_HOME or PROJECT variables are undefined. Please source the setup administrator first."
+  exit 1
+fi
+
+echo "Repository Home: $REPO_HOME"
+echo "Project Name: $PROJECT"
+
+# The scratchpad must exist at the top level of the project for scanning clarity
+scratchpad="$REPO_HOME"/scratchpad
+if [[ ! -d "$scratchpad" ]]; then
+  echo "Error: scratchpad directory missing at $scratchpad"
+  exit 1
+fi
+
+#--------------------------------------------------------------------------------
+# Python name/version
+#
+
+version=3.12.3
+Python_dn=Python-"$version"
+tarf="$Python_dn".tgz
+
+# Python install directory, sibling to this project
+Python_da="$(realpath "$REPO_HOME"/../)"/"$Python_dn"
+
+#--------------------------------------------------------------------------------
+
+# Verify if the requested Python version is already built
+if [[ -x "$Python_da/bin/python3" ]]; then
+  echo "Python $version is already built and installed at $Python_da."
+else
+  # Download only if the archive is absent
+  wget -nc -P "$scratchpad" https://www.python.org/ftp/python/"$version"/"$tarf"
+  
+  # Extract into the scratchpad to prevent source and installation collisions
+  source_dn="$scratchpad"/Python-src-"$version"
+  mkdir -p "$source_dn"
+  tar xzf "$scratchpad"/"$tarf" -C "$source_dn" --strip-components=1
+
+  # Explicit error reporting prevents silent administrative failures
+  cd "$source_dn" || { 
+    echo "Error: Failed to change directory to $source_dn. Extraction likely failed."
+    exit 1 
+  }
+
+  # Configure with developer baseline (--enable-shared) required for C extensions
+  LDFLAGS="-Wl,-rpath=$Python_da/lib" ./configure --prefix="$Python_da" --enable-optimizations --enable-shared
+
+  make -j8
+  make install
+fi
+
+# Establish the versioned executable link
+link_dir="$REPO_HOME"/shared/linked-project
+mkdir -p "$link_dir"
+cd "$link_dir" || {
+  echo "Error: Failed to navigate to linked-project directory at $link_dir"
+  exit 1
+}
+
+if [[ ! -L "$Python_dn" ]]; then
+  # The depth accurately escapes linked-project, shared, and REPO_HOME
+  ln -s ../../../"$Python_dn"/ "$Python_dn"
+  echo "Successfully created symlink for $Python_dn"
+else
+  echo "The symlink for $Python_dn already exists."
+fi
+
+# --------------------------------------------------------------------------------
+# Path & Environment Configuration Plugin 
+# --------------------------------------------------------------------------------
+path_sh="$REPO_HOME"/shared/tool/PATH.sh
+touch "$path_sh"
+
+# Define the cluster of variables required by the python plugin environment
+line_env="export VIRTUAL_ENV=\"\$REPO_HOME/shared/linked-project/$Python_dn\""
+line_home="export PYTHON_HOME=\"\$VIRTUAL_ENV\""
+line_unset="unset PYTHONHOME"
+line_path="PATH=\"\$VIRTUAL_ENV/bin:\$PATH\""
+
+# Append the variables sequentially if they are missing from the configuration file
+for line in "$line_env" "$line_home" "$line_unset" "$line_path"; do
+  if ! grep -Fq "$line" "$path_sh"; then
+    echo "$line" >> "$path_sh"
+    echo "Appended plugin configuration line to PATH.sh."
+  else
+    echo "Configuration line already present in PATH.sh."
+  fi
+done
+
diff --git a/setup b/setup
index ebc1244..7603f3e 100644 (file)
--- a/setup
+++ b/setup
@@ -41,18 +41,6 @@ fi
     source shared/authored/setup
   fi
 
-# setup tools
-#
-  export PYTHON_HOME="${REPO_HOME}/shared/linked-project/Python"
-  if [[ ":${PATH}:" != *":${PYTHON_HOME}/bin:"* ]]; then
-    export PATH="${PYTHON_HOME}/bin:${PATH}"
-  fi
-
-  RT_gcc="${REPO_HOME}/shared/linked-project/RT_gcc/release"
-  if [[ ":${PATH}:" != *":${RT_gcc}:"* ]]; then
-    export PATH="${RT_gcc}:${PATH}"
-  fi
-
 # setup the role
 #
   export ROLE="${1}"
diff --git a/shared/tool/PATH.sh b/shared/tool/PATH.sh
new file mode 100644 (file)
index 0000000..e69de29
index 58af6d9..6cfc738 100644 (file)
@@ -14,15 +14,13 @@ umask 0077
 # --------------------------------------------------------------------------------
 # project definition
 
-# actual absolute director path for this script file
-
+# actual absolute directory path for this script file
   script_adp(){
     dirname "$script_afp"
   }
 
-# assume this script is located  $REPO_HOME/tools_shared/authored and work backwards
-# to get $REPO_HOME, etc.
-
+# This script is located at $REPO_HOME/shared/tool/setup.
+# Ascend two directories to discover the absolute $REPO_HOME path.
   REPO_HOME=$(dirname "$(dirname "$(script_adp)")")
   echo REPO_HOME "$REPO_HOME"
 
@@ -34,30 +32,6 @@ umask 0077
 
   export REPO_HOME PROJECT PROMPT_DECOR
 
-# --------------------------------------------------------------------------------
-# Project wide Tool setup
-#
-
-export VIRTUAL_ENV="$REPO_HOME/shared/linked-project/Python"
-export PYTHON_HOME="$VIRTUAL_ENV"
-unset PYTHONHOME
-
-
-# --------------------------------------------------------------------------------
-# PATH
-#   precedence: last defined, first discovered
-  
-  PATH="$REPO_HOME/shared/authored:$PATH"
-  PATH="$REPO_HOME/shared/made:$PATH"
-  PATH="$REPO_HOME/shared/tool:$PATH"
-
-  # Remove duplicates
-  clean_path() {
-    PATH=$(echo ":$PATH" | awk -v RS=: -v ORS=: '!seen[$0]++' | sed 's/^://; s/:$//')
-  }
-  clean_path
-  export PATH
-
 # --------------------------------------------------------------------------------
 # the following functions are provided for other scripts to use.
 # at the top of files that make use of these functions put the following line:
@@ -69,7 +43,7 @@ unset PYTHONHOME
     basename "$script_afp"
   }
 
-  ## script's dirpath relative to $REPO_HOME
+  ## script's file path relative to $REPO_HOME
   script_fp(){
     realpath --relative-to="${REPO_HOME}" "$script_afp"
   }
@@ -81,10 +55,31 @@ unset PYTHONHOME
 
   export -f script_adp script_fn script_dp script_fp
 
+# --------------------------------------------------------------------------------
+# PATH & Plugin Sourcing
+#   precedence: last defined, first discovered
+  
+  PATH="$REPO_HOME/shared/authored:$PATH"
+  PATH="$REPO_HOME/shared/made:$PATH"
+  PATH="$REPO_HOME/shared/tool:$PATH"
+
+  # Remove duplicates
+  clean_path() {
+    PATH=$(echo ":$PATH" | awk -v RS=: -v ORS=: '!seen[$0]++' | sed 's/^://; s/:$//')
+  }
+  clean_path
+
+  # Sourcing is wrapped in a conditional guard to prevent failure on initial bootstrapping
+  installed_tool_sh="$REPO_HOME/$(script_dp)/PATH.sh"
+  if [[ -f "$installed_tool_sh" ]]; then
+    source "$installed_tool_sh"
+  fi
+
+  export PATH
+
 #--------------------------------------------------------------------------------
 # used by release scripts
 #
-
   install_file() {
     if [ "$#" -lt 3 ]; then
       echo "env::install_file usage: install_file <source1> <source2> ... <target_dir> <permissions>"
@@ -111,8 +106,6 @@ unset PYTHONHOME
       if ! install -m "$perms" "$source_fp" "$target_file"; then
         echo "env::install_file: Failed to install $(basename "$source_fp") to $target_dp"
         return 1
-      else
-        echo "env::install_file: installed $(basename "$source_fp") to $target_dp with permissions $perms"
       fi
     done
   }
@@ -125,4 +118,3 @@ unset PYTHONHOME
   if [[ -z "$ENV" ]]; then
     export ENV=$(script_fp)
   fi
-
index aced6ba..74007d0 100755 (executable)
@@ -1,4 +1,3 @@
-echo "Harmony v3.0 2026-05-10"
-
+echo "Harmony v3.2 2026-05-31"