Pull requests

#9 Declined
dhellmann dhellmann

workon dot will try to set basename as env

  1. Matias Saguir

If you type "workon ." it will try to set the virtualenv with the path basename.

Comments (8)

  1. Doug Hellmann repo owner

    I just realized I asked this question on the wrong screen.

    What's the use case for this? When is "workon ." going to be run? Are you already in the virtualenv? Or an associated project directory?

  2. Matias Saguir author

    It's going to be ran inside an associated project directory for example normally you would do something like

    cd /my/project/path/projectname
    workon projectname

    now, if the project folder has the same name as the virtualenv you would type

    cd /my/project/path/projectname
    workon .

    It's just a shortcut for not typing the project name twice.

  3. Tobias Herp

    One more thought: This would fail in any subdirectory of the virtualenv (unless it has the same name), or could (by accident) activate an unexpected environment. This could be solved easily, though, by a simple script which checks the parents and prints the name of the env, or nothing (if not below WORKON_HOME).

  4. Doug Hellmann repo owner

    That's backwards from what I usually do. I use setvirtualenvproject to associate a directory with each virtualenv, and then I just use workon to switch between them and change directories at the same time.

  5. Tobias Herp

    It's quite possible you came to that directory by another mechanism.

    E.g., before I was aware of virtualenvwrapper, I defined an environment variable PUTTY_HOME which is used by a script of mine, to change directory depending on this variable (I have several PuTTY sessions which include different colour setups as well). Sadly, it doesn't work to activate the virtualenv in the same step.

    I'd prefer workon . to . bin/activate.

    (By the way, I always want to change to the new environment when activating it by workon; I dislike the need for an additional command, be it cdvirtualenv or setvirtualenvproject. IMO, the "default project directory" should be the project root. This way, 90% of the folks won't need to bother about setvirtualenvproject ever. I consider this name as difficult to remember.)

  6. Matias Saguir author

    I didn't know about the setvirtualenvproject; it's quite usefull. I was just lazy about typing the same directory on workon after cd. Non the less I don't think that workon . would do any harm, but If you are not sure about adding it, it's fine by me.