maphew

Installing Leo

Installing Leo

October 15, 2023

8:44 PM

Installing Leo from scratch on a new machine, following my preferences, some adjustment may be needed to match yours.

 

Overview

All but step 1 can be done from the command line, below.

 

  1. Install the winget command line package manager by installing App Installer from Microsoft Store.
  2. Download refreshenv.cmd and place in PATH (helper).
  3. Install gsudo, for running elevated commands.
  4. Install python launcher, a shortcut to all the python installs on a system.
  5. Install python from Python Software Foundation.
  6. Install pipx, for managing python programs as applications.
  7. Fetch Leo (choose from pypi.org or source code)
  8. Install Leo
  9. Register Leo with Windows

 

 

From a CMD shell (gist here):

 

:: Install Leo on windows recipe by matt wilkie

:: Requires App Installer from Microsoft Store be installed first

:: opinionated personal preferences, adjust to suit

::

winget install wget

winget install gsudo

md c:\bin

wget https://raw.githubusercontent.com/chocolatey/choco/blob/master/src/chocolatey.resources/redirects/RefreshEnv.cmd -O c:\bin\RefreshEnv.cmd

sudo setx /M path %path%;c:\bin

 

winget install --id Python.Launcher --exact --force

winget install python.python.3.12 --location c:\apps\python

 

refreshenv

py -0

where python

 

sudo setx /M PIPX_BIN_DIR C:\bin

sudo setx /M PIPX_HOME C:\apps\pipx

c:\apps\python\python.exe -m pip install pipx

c:\apps\python\python.exe -m pipx ensurepath

refreshenv

 

Choose:

 

:: Install latest stable release from pypi.org

pipx install leo

 

    Or:

:: Or install latest development from GitHub with git

pushd %userprofile%\code

git clone --depth=50 --no-single-branch https://github.com/leo-editor/leo-editor

pipx install --editable ./leo-editor

 

    Or:

:: Or install latest development from source code download

winget install 7zip

pushd %userprofile%\Downloads

wget https://github.com/leo-editor/leo-editor/archive/devel.zip

7z x devel.zip -o C:\apps
pipx install --editable C:\apps\leo-editor-devel

 

Resume

 

pipx inject leo websockets

 

leo-messages --version

 

:: run Leo to create profile and related, and then exit

Leo

 

:: Register Leo with Windows

leo-m --script=C:\apps\pipx\venvs\leo\Lib\site-packages\leo\scripts\add-desktop-links.leox

leo-m --script=C:\apps\pipx\venvs\leo\Lib\site-packages\leo\scripts\win\register-leo.leox

 

Notes

Python, pipx, and Leo are installed globally outside of user profile directory tree.

 

Several listed commands are optional. For example `where python` is merely a sanity check to see it it's in PATH and what folder it's in.

 

Refreshenv allows carrying out all commands in a single session. Without this opening a new CMD shell several times to catch changes each of the installs makes is necessary.

 

Pipx is for installing python programs in their own virtual environment, so they behave like regular programs that can have independent python versions and depencies from other python programs. It's lighter weight than conda and simpler than managing venvs directly.

 

Registering Leo with Windows can be done interactively via "Leo menu >> Settings >> Open desktop integration".

 

Websockets is optional, it's for using the LeoInteg extension in Visual Studio Code.

 

 

────────────────────────────────────────────────────────────────────────────────

OLD

 

Install Miniconda, then:

 

conda create -n Leo

:: creates bare environment

conda activate Leo

conda install pip

:: installs python, pip, setuptools, wheel, vc, vs2015_runtime, wincertstore

:: +82 MB on Win7 x64

 

 

Note: if you pip install leo without first conda installing pip the install will work, however Leo and all it's dependencies are then installed in the Conda Base env instead of the Leo one, potentially interfering with other conda envs.

 

 

 

2018-02-24

pip install d:\temp\wheels\leo-editor*.whl

:: installs Leo and all dependencies, downloading as needed

:: +289 MB on Win7 x64

 

Total size in MB

371

Size on disk in MB

413

Number of files

16,237

Number of folders

1,287

 

 

Installing from GitHub

When installing Leo from GitHub with pip install https://github.com/leo-editor/leo-editor/archive/devel.zip numerous files are left out. See #847 (comment)

Solution

Installing from Github into a new environment must be done in discrete steps: download, unpack, and install in editable mode.

Example:

wget https://github.com/leo-editor/leo-editor/archive/devel.zip
7z x devel.zip -o C:\apps
pip install --editable C:\apps\leo-editor-devel

On Windows there are powershell versions of wget if needed.

 

For easier upgrading substitute git clone for wget & 7z steps:

git clone --single-branch -b devel --depth=100 https://github.com/leo-editor/leo-editor.git
pip install --editable leo-editor

time passes, upgrade desired:

pushd c:\apps\leo-editor
git pull

single-branch, b and depth are all optional, but will dramatically speed up download time as it only grabs the latest development branch and skips all but the last couple weeks or months of history.

--- https://github.com/leo-editor/leo-editor/issues/847

 

Created with OneNote.