Portable Python Environment?

Jan 26 at 2:13 AM
Hello!

I'm trying to get PTVS to work with a python distribution that is portable (i.e. usb portable). Everything works but on each new machine I need to re-register the environment (Options->Python Tools->Environment Options).

So is there anyway I can avoid the environment registation?

Or is there a way that I could register and unregistered automatically or maybe from the commandline?

Thank you.
Coordinator
Jan 26 at 3:34 AM
You could export the registry keys we set when you register the environment, or maybe create a batch file with the equivalent "reg.exe add" commands. Searching the HKEY_CURRENT_USER hive for your interpreter path should find it.

Of course, this is completely undocumented and we don't guarantee that it won't change between releases of PTVS. There are also other possible issues because the keys are technically controlled by VS, but if you always use the same VS version and same PTVS version on every machine, you should be fine.
Jan 26 at 1:45 PM
Thanks zooba!

It looks like the information is stored at two places:
1) HKEY_CURRENT_USER\Software\Microsoft\VisualStudio*\PythonTools\Options\Interpreters.
2) HKEY_CURRENT_USER\Software\Microsoft\VisualStudio*_Config\PythonTools\InterpreterFactories

The options I get, but I'm not familiar with Interpreter Factories. The contents of that entry is just two keys but is there anything that i need to watch out for?

And about the uuids being used, can I generate those from the script? I'm thinking of maybe generating the uuids as a pre-install step and write the registry entries after.
Coordinator
Jan 26 at 2:31 PM
You don't need to worry about interpreter factories (unless you want to write an extension to auto-detect your environments - let me know if you do, I'm happy to help with this), so just get your entry from the other key.

You're probably best to keep the uuid the same because we may write it into project files. Right now we have an issue where projects that refer to a custom environment are not portable because we regenerate the uuid on each machine. We haven't come up with a robust solution yet, but we also haven't had many people run into trouble. If you have a consistent id on all your machines then the reference will work, even if the paths happen to be different.