12

Short Description
The question is not meant to ask if using virtual environments are needed, but when using Ian Bicking's virtualenv what is the best way, if any, to manage environments in Windows. If you have multiple ideas, please answer multiple times so the best answers can be voted up. Thanks!

Background
When developing in python, I generally try use Mac osx / bash as much as possible. However there are always projects that I am forced to use Windows on for hardware/driver support. For these projects, I tend to rely on the 'double click' method to run the modules with the registered python.exe. The use of the 'double click' is such a simple way to run multiple threads / tests at the same time, without having to open a new command prompt, drill down to the directory needed, then typing 'python.exe module.py'.

The End Goal
I would like to have a way to manage and utilize virtual environments without having to be at the command prompt (Windows only)

Wish List
1. Be able to install modules from either pip (command line) or from binaries (for those that can't be installed with pip for whatever reason).
2. Manage environments, with virtualenv.exe, from a GUI. (Create, remove, list, activate, etc...)

Research
So far I have been able to do bits and pieces of my wish list using different scripts / methods, but have yet to find a way to combine them. I was planning to combine most of these into a GUI my self, but thought it would be wise to find out if there is a good reason this doesn't exist already.

Installing binaries to a virtual environment can be done fairly easy using a script that changes what version of python is registered in Windows. I have been using the script for several months now with nothing but great results. See SO Question

Managing the environments appears to the more difficult portion.

If using bash, there is virutalenvwrapper written by Doug Hellmann. I use this when working in Mac OSX and hightly recommend it.

There is a port of this exertion into Power Shell found here but still will require a third party command prompt interface to be installed.

One of the more unique ports to windows that I have seen ports virtualenvwrapper to bat files. I have not tested this, but it would still require a the use of the command prompt. Found here

The most promising helper function I have found to date is written by Justin Driscoll. While this exact example would require the command prompt, it would be trivial to convert this to something that a python GUI could call. This was the path I was going down before I thought I should check with the masses on the best way to achieve my goal.

Community
  • 1
  • 1
Adam Lewis
  • 7,017
  • 7
  • 44
  • 62
  • 1
    It seems like you could effectively use .bat files to accomplish this task, but I guess I'm not sure what you mean about "without having to be at the command prompt." A batch file would let you automate your command line input, and you could integrate it with a Windows Script or JScript file if you needed more functionality. The usage examples on Justin Driscoll's page could be put into a batch file that you could then just double-click. I know it's not exactly a GUI, but it would allow you to centralize your parameters/variables. Is that what you are thinking of? Or have I missed the gist? – Kit Z. Fox May 09 '11 at 16:11
  • @ Kit: If you wouldn't mind add this as an answer, it is close to the functionality I am searching for. I'll add more comments when it's an answer (So it can benefit others as well). – Adam Lewis May 09 '11 at 16:18

1 Answers1

2

You might want to take a look at zc.buildout. Assuming the user has Python installed, you can double click on the bootstrap.py python script to generate the environment.

Once created, doubleclicking on bin\buildout.exe will recursively install dependencies and run any pre/post hook methods you define. zc.buildout allows you to specify platform specific dependencies and non-python dependencies. Additionally, you may define your own scripts for buildout to place into the bin\ folder. For example, the Plone team has a good article running Buildout on Windows referencing their own script bin\instance.exe

While not quite a polished as virtualenv on Mac/Linux/BSD, the same buildout environment will be created (eg. bin/buildout instead of bin\buildout.exe) achieving the cross-platform requirements you have.

Erik Karulf
  • 473
  • 4
  • 10
  • I have never seen buildout before. After looking into it, I can see it's uses over all for deploying software. However I'm afraid I don't see it's strengths for developing software. That's the real strength I am looking for in virtualenv. On any given day, I can be working on 3 vastly different projects (each with their own python dependencies). Thanks for the info though! – Adam Lewis May 09 '11 at 02:36
  • 1
    Buildout can isolate you from your system packages similar to how virtualenv works. For example I will run a bin/python executable (bin is inside my project dir structure). That python will only have access to eggs inside my project dir. It achieves a similar effect as virtualenv. It is a bit more of a pain, and has the big win of super easy deployment. Choices, choices... – Brian O'Dell May 11 '11 at 14:54
  • @Brian: Thank you for that clarification. I will look into it again with that mind set. – Adam Lewis May 11 '11 at 15:37