Commits

Doug Hellmann committed 62bfaf8

add VIRTUALENVWRAPPER_PROJECT_FILENAME; resolves issue 120

  • Participants
  • Parent commits 6495c52

Comments (0)

Files changed (6)

File docs/en/history.rst

   - Shortcut initialization if it has run before.
   - Set hook log file permissions to be group-writable. (:bbissue:`62`
     reported by :bbuser:`hedgeddown`)
+  - Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the
+    ``.project`` file used to link a virtualenv to a project can be
+    renamed to avoid conflicts with other tools. (:bbissue:`120`
+    reported by :bbuser:`arthuralvim`)
 
 2.10.1
 

File docs/en/install.rst

 
    * :ref:`project-management`
 
+.. _variable-VIRTUALENVWRAPPER_PROJECT_FILENAME:
+
+Project Linkage Filename
+------------------------
+
+The variable ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` tells
+virtualenvwrapper how to name the file linking a virtualenv to a
+project working directory. The default is ``.project``.
+
+.. seealso::
+
+   * :ref:`project-management`
+
 .. _variable-VIRTUALENVWRAPPER_HOOK_DIR:
 
 Location of Hook Scripts

File docs/en/projects.rst

 .. seealso::
 
    * :ref:`extensions-templates`
+   * :ref:`variable-PROJECT_HOME`
+   * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME`

File tests/test_project_mk.sh

     PROJECT_HOME="$old_project_home"
 }
 
+test_alternate_linkage_filename () {
+    export VIRTUALENVWRAPPER_PROJECT_FILENAME=".not-project"
+    mkproject myproject6 >/dev/null 2>&1
+    assertSame "myproject6" $(basename "$VIRTUAL_ENV")
+    assertSame "$PROJECT_HOME/myproject6" "$(cat $VIRTUAL_ENV/.not-project)"
+    export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project"
+}
+
 . "$test_dir/shunit2"

File virtualenvwrapper.sh

 	VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts"
 fi
 
+# Let the user override the name of the file that holds the project
+# directory name.
+if [ "$VIRTUALENVWRAPPER_PROJECT_FILENAME" = "" ]
+then
+    export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project"
+fi
+
 function virtualenvwrapper_derive_workon_home {
     typeset workon_home_dir="$WORKON_HOME"
 
         prj="$(pwd)"
     fi
     echo "Setting project for $(basename $venv) to $prj"
-    echo "$prj" > "$venv/.project"
+    echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME"
 }
 
 # Show help for mkproject
 function cdproject {
     virtualenvwrapper_verify_workon_home || return 1
     virtualenvwrapper_verify_active_environment || return 1
-    if [ -f "$VIRTUAL_ENV/.project" ]
+    if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]
     then
-        project_dir=$(cat "$VIRTUAL_ENV/.project")
+        project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")
         if [ ! -z "$project_dir" ]
         then
             cd "$project_dir"
             return 1
         fi
     else
-        echo "No project set in $VIRTUAL_ENV/.project" 1>&2
+        echo "No project set in $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" 1>&2
         return 1
     fi
     return 0

File virtualenvwrapper/project.py

 #
 # Change to the project directory
 #
-[ -f "$VIRTUAL_ENV/.project" ] && cd "$(cat \"$VIRTUAL_ENV/.project\")"
+[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")"
 """