There used to be a portable app type package for Python so that it could be run from a USB stick and used on different computers. But no longer. I thought it would be interesting to see what would be involved in setting one up. This is for Windows. I'm sure it could be adapted for Linux without much trouble.
First of all, the standard Python installer will install to any drive, including a usb stick. That's easy. Your want to install for all users so that there won't be a problem using it on some computer where you are not the specific user you installed for. But that's not the end of it.
You have to take care of at least two things, if you really want to be portable:
1. Where python will look for configuration and settings files, the site-customize location, .pth files, etc. There is an environmental variable to use for this: PYTHONUSERBASE. You can find where it is on your current Python installation:
>>>import site
>>> site.getuserbase()
'C:\\Users\\tom\\AppData\\Roaming\\Python'
>>> print(site.getsitepackages())
['C:\\Users\\tom\\AppData\\Local\\Programs\\Python\\Python38', 'C:\\Users\\tom\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages']
>>>
You need to set the user base so that it is on your usb stick.
2. Leo will look for some of its files, like its .leo/db directory, its user name file, and the standard workbook.leo file, in os.path.expanduser('~'):
>>> import os
>>> os.path.expanduser('~')
'C:\\Users\\tom'
You need to change this to point to the USB stick. It is set by the HOME environmental variable.
You will need to decide on a directory structure. For my tests, with the USB stick mounted as drive f:, I installed Python into f:\python3, and created a directory f:\user\python to use for both the user base and home directories. I set the environmental variables and run Python using the following cmd file named pyth.cmd:
@echo off
setlocal
path f:\python3\Scripts;f:\python3;%PATH%
set PYTHONUSERBASE=f:\user\python
set HOME=f:\user\python
call python %*
endlocal
After I installed Python 3.7 for the f:\python3 directory, I updated pip:
pyth -m pip install --upgrade pip
I have found that some python installers do not install wheel, and therefore some packages don't install because they can't build their wheels. So I now always run:
pyth -m pip install --upgrade wheel
This time, there was no previous wheel installation. Then I installed Leo:
pyth -m pip install leo
Running Leo, everything worked the first time:
pyth -m leo.core.runLeo --use-docks
I copied my standard settings from the myLeoSettings.leo file in my usual on-computer Leo installation. Note that I always run Leo with the -m leo.core.runLeo invocation because I find that sometimes I don't have a leo, runLeo, or launchLeo installed - depending on what Leo package I'm using - but this way always works. (Or maybe I do have them but my system path doesn't find them. Anyway, this method is very dependable.).
I have run Leo on this usb stick on two different Windows 10 computers. I did have to edit the batch file paths from f:\ to e:\ because the mount name of the drive was different on the two computers. I haven't come up with a way to adapt to the change in drive letter except by editing the batch file, sorry to say.
The stick did fail to work on a third computer. However, that one was so old that Windows hadn't been able to update itself for two or maybe even three years. So I expect there is some kind of DLL incompatibility going on. I would get the Leo splash screen but then it would die with no error message to the console. One of the computers that did work was a laptop I got back around 2012 (which has been able to be updated, though I'm retiring it so it may not get many more updates). So an old computer doesn't necessarily mean that this USB stick technique won't work.
Of course, you could do all the usual maneuvers to use Leo from a git clone or a zip download if you want to.
I hope this will be useful to someone.