Browse Source

"--portable": more consistent behaviour

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 https://github.com/spesmilo/electrum/issues/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 https://github.com/spesmilo/electrum/issues/7732
fixes https://github.com/spesmilo/electrum/issues/5551
patch-4
SomberNight 3 years ago
parent
commit
6a34d93ce2
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 13
      run_electrum

13
run_electrum

@ -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'):

Loading…
Cancel
Save