anatoly techtonik avatar anatoly techtonik committed 33a5ae0

Add case with pure Python package with no dependencies, such as SCons.

Comments (0)

Files changed (2)

+#!/usr/bin/env python3
+# Run Python source code with no dependencies directly from checkout.
+# This stuff is placed into public domain by
+#    anatoly techtonik <>
+# Typical problem with running applications from source is that its
+# path is not included in the list of directories where Python looks
+# for imports. Usually the main script of an application is located
+# inside the source tree and does something like this:
+#   import SCons.Script
+#   SCons.Script.main()
+# If you run this script from source, and `SCons` package is not
+# installed or not immediately present in the script's directory,
+# you'll get standard:
+#   ImportError: No module named SCons.SCript
+# The solution here is to explicitly add local path with `SCons`
+# package to the sys.path variable.
+# --- 01. bootstrap - add local package path to sys.path  ---
+import sys
+import os
+# we assume that this script is located at the root of source code
+# tree, and we save its absolute path in the ROOT variable
+ROOT = os.path.abspath(os.path.dirname(__file__))
+# here we assume that imported packages are located in src/engine/
+sys.path.insert(0, ROOT + '/src/engine')
+# --- 02. launch application code ---
+import SCons.Script
-Public domain snippets to help with executing projects directly
-from the source code checkout without installing, i.e. locally.
+Public domain snippets to help with executing projects
+directly from a source code checkout. Locally, i.e.
+without installing.
+What is `locally` exactly and why would you need it
+There is a set of conventions, examples and helpers to
+run your Python applications without installing. This
+is useful for development, because it:
+  * lowers the barrier for contribution
+  * reduces time loss between checkout and run
+It is also useful for troubleshooting, because user
+will be able to try latest code versions without
+building and packaging things themselves.
+How to use `locally`
+Study by example starting from script to
+see what will work for you. Then copy/paste example
+into your and modify for your app.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.