Commits

Rui Pereira committed 6764724

New files.

  • Participants
  • Parent commits 189de92
  • Branches test-hg

Comments (0)

Files changed (11)

File virtualenvwrapper/virtualenvwrapper.csh/cdproject

+virtualenvwrapper_verify_workon_home || exit 1
+virtualenvwrapper_verify_active_environment || exit 1
+if ( -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ) then
+    set project_dir = `cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME"`
+    if ( "$project_dir" != "" ) then
+        cd "$project_dir"
+    else
+        echo "Project directory $project_dir does not exist" > /dev/stderr
+        unset project_dir
+        exit 1
+    endif
+else
+    echo "No project set in $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" > /dev/stderr
+    unset project_dir
+    exit 1
+endif
+unset project_dir
+exit 0

File virtualenvwrapper/virtualenvwrapper.csh/mkproject

+set in_args = ($*)
+set out_args = ()
+set i = 1
+set templates
+
+while ( $i <= $#argv )
+    set a = "$in_args[$i]"
+    # echo "arg $i : $a"
+    switch ( "$a" )
+        case -h:
+            mkproject_help
+            exit
+        case --help:
+            mkproject_help
+            exit
+        case -t:
+            @ i += 1
+            set templates = "$templates ${in_args[$i]}"
+            breaksw
+        default:
+            if ( ${#out_args} > 0 ) then
+                set out_args = ( ${out_args[*]} "$a" )
+            else
+                set out_args = ( "$a" )
+            endif
+    endsw
+    @ i += 1
+end
+unset in_args
+unset out_args
+unset a
+unset i
+
+# this conflicts with envname in mkvirtualenv
+set envpname = "$argv[$#argv]"
+virtualenvwrapper_verify_project_home || unset templates && unset envpname && exit 1
+# RP: will fail otherwise
+test \( ! -z $envpname \) || unset templates && unset envpname && exit 1
+
+if ( -d "$PROJECT_HOME/$envpname" ) then
+    echo "Project $envpname already exists." > /dev/stderr
+    unset templates
+    unset envpname
+    exit 1
+endif
+
+mkvirtualenv "$envpname" || unset templates && unset envpname && exit 1
+
+cd "$PROJECT_HOME"
+
+virtualenvwrapper_run_hook "project.pre_mkproject" $envpname
+
+echo "Creating $PROJECT_HOME/$envpname"
+mkdir -p "$PROJECT_HOME/$envpname"
+setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envpname"
+
+cd "$PROJECT_HOME/$envpname"
+
+foreach t ( $templates )
+    echo
+    echo "Applying template $t"
+    virtualenvwrapper_run_hook --name $t "project.template" $envpname
+end
+
+virtualenvwrapper_run_hook "project.post_mkproject"
+
+unset templates
+unset envpname

File virtualenvwrapper/virtualenvwrapper.csh/mkproject_help

+echo "Usage: mkproject [-t template] [virtualenv options] project_name"
+echo ""
+echo "Multiple templates may be selected.  They are applied in the order"
+echo "specified on the command line."
+echo
+echo "mkvirtualenv help:"
+echo
+mkvirtualenv -h;
+echo
+echo "Available project templates:"
+echo
+"$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template

File virtualenvwrapper/virtualenvwrapper.csh/mktmpenv

+# Generate a unique temporary name
+# RP: csh cannot redirect only stderr, so doing things a bit diferently
+"$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(str(uuid.uuid4())+"\n")'
+@ RC = $?
+if ( "$RC" == "0" ) then
+    set tmpenvname = `"$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(str(uuid.uuid4())+"\n")'`
+else
+    # This python does not support uuid
+    set tmpenvname = `"$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")'`
+endif
+
+# Create the environment
+mkvirtualenv "$@" "$tmpenvname"
+@ RC = $?
+if ( "$RC" != "0" ) then
+    unset tmpenvname
+    exit $RC
+fi
+
+# Change working directory
+cdvirtualenv
+
+# Create the tmpenv marker file
+echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv"
+
+# Update the postdeactivate script
+cat - >> "$VIRTUAL_ENV/bin/postdeactivate" <<EOF
+if [ -f "$VIRTUAL_ENV/README.tmpenv" ]
+then
+    echo "Removing temporary environment:" $(basename "$VIRTUAL_ENV")
+    rmvirtualenv $(basename "$VIRTUAL_ENV")
+fi
+EOF

File virtualenvwrapper/virtualenvwrapper.csh/mkvirtualenv_help

+echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name"
+echo
+echo " -a project_path"
+echo
+echo "    Provide a full path to a project directory to associate with"
+echo "    the new environment."
+echo
+echo " -i package"
+echo
+echo "    Install a package after the environment is created."
+echo "    This option may be repeated."
+echo
+echo " -r requirements_file"
+echo
+echo "    Provide a pip requirements file to install a base set of packages"
+echo "    into the new environment."
+echo;
+echo 'virtualenv help:';
+echo;
+"$VIRTUALENVWRAPPER_VIRTUALENV" $*;

File virtualenvwrapper/virtualenvwrapper.csh/setvirtualenvproject

+set venv = "$1"
+set prj="$2"
+if ( "$venv" == "" ) then
+    set venv = "$VIRTUAL_ENV"
+endif
+if ( "$prj" == "" ) then
+    set prj = "$(pwd)"
+endif
+echo "Setting project for `basename $venv` to $prj"
+echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME"
+unset venv
+unset prj

File virtualenvwrapper/virtualenvwrapper.csh/virtualenvwrapper_expandpath

+if ( "$#argv" == "0" ) then
+    exit 1
+else
+    "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars('$1')))+'\n')"
+    exit 0
+endif

File virtualenvwrapper/virtualenvwrapper.csh/virtualenvwrapper_get_python_version

+$VIRTUAL_ENV/bin/python -V |& cut -f2 -d' ' | cut -f-2 -d.

File virtualenvwrapper/virtualenvwrapper.csh/virtualenvwrapper_get_site_packages_dir

+"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())"

File virtualenvwrapper/virtualenvwrapper.csh/virtualenvwrapper_verify_project_home

+if ( $?PROJECT_HOME ) then
+    if ( $PROJECT_HOME == "" ) then
+        echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." > /dev/stderr
+        exit 1
+    endif
+    if ( ! -d "$PROJECT_HOME" ) then
+        test \( "$1" != "-q" \) && echo "ERROR: Project directory '$PROJECT_HOME' does not exist.  Create it or set PROJECT_HOME to an existing directory." > /dev/stderr
+        exit 1
+    endif
+    exit 0
+else
+    echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." > /dev/stderr
+    exit 1
+endif

File virtualenvwrapper/virtualenvwrapper.csh/virtualenvwrapper_verify_resource

+if ( $?GREP_OPTIONS ) then
+    set grep_options = "$GREP_OPTIONS"
+    unsetenv GREP_OPTIONS
+endif
+
+set exe_path = `w\hich "$1" | g\rep -v "not found"`
+if ( "$exe_path" == "" ) then
+    echo "ERROR: virtualenvwrapper could not find $1 in your path" > /dev/stderr
+    unset exe_path
+    exit 1
+endif
+if ( ! -e "$exe_path" ) then
+    echo "ERROR: Found $1 in path as \"$exe_path\" but that does not exist" > /dev/stderr
+    unset exe_path
+    exit 1
+endif
+
+if ( $?grep_options ) then
+    setenv GREP_OPTIONS $grep_options
+    unset grep_options
+endif
+
+unset exe_path
+exit 0