Skip to content

Commit

Permalink
"--portable": more consistent behaviour
Browse files Browse the repository at this point in the history
The old and new behaviour is as follows:
1. "pyinstaller" case: portable `.exe`, other `.exe`s with `--portable`, and `.dmg` with `--portable`
    - uses `$PWD`
    - note that when you double-click the portable `.exe` on Windows, `$PWD` is set to the parent folder, i.e. the datadir gets put next to the `.exe`
2. appimage `--portable`
    - was broken (see #5551)
    - (CHANGED NOW to) uses `$PWD`
3. git clone
    - next to `run_electrum`
4. unpacking `tar.gz` and running locally from it
    - next to `run_electrum`
5. `pip install *.tar.gz`, and calling "electrum --portable" from terminal
    - used python's user script directory
        - `~/.local/bin/electrum_data`
        - `$VIRTUAL_ENV/bin/electrum_data`
    - (CHANGED NOW to) uses `$PWD`

That is, we now almost always put the datadir in `$PWD`,
except for the local source case, where we put it next to `run_electrum`.

The "appimage" case (2) is now fixed.

The only breaking change is re case 5 which previously behaved completely
unintuitively and most likely not in a useful way.

closes #7732
fixes #5551
  • Loading branch information
SomberNight committed Mar 23, 2022
1 parent 5b500f0 commit 6a34d93
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions run_electrum
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,17 @@ def main():
config_options['portable'] = True

if config_options.get('portable'):
if is_pyinstaller:
datadir = os.path.join(os.path.realpath(cwd), 'electrum_data')
else:
if is_local:
# running from git clone or local source: put datadir next to main script
datadir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'electrum_data')
else:
# Running a binary or installed source. The most generic but still reasonable thing
# is to use the current working directory. (see #7732)
# note: The main script is often unpacked to a temporary directory from a bundled executable,
# and we don't want to put the datadir inside a temp dir.
# note: Re the portable .exe on Windows, when the user double-clicks it, CWD gets set
# to the parent dir, i.e. we will put the datadir next to the exe.
datadir = os.path.join(os.path.realpath(cwd), 'electrum_data')
config_options['electrum_path'] = datadir

if not config_options.get('verbosity'):
Expand Down

0 comments on commit 6a34d93

Please sign in to comment.