Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix portable behavior #288

Merged
merged 2 commits into from
May 2, 2023
Merged

fix portable behavior #288

merged 2 commits into from
May 2, 2023

Conversation

PiRK
Copy link
Collaborator

@PiRK PiRK commented Apr 28, 2023

The main change here is that we fix the broken portable.exe behavior caused by recent versions of PyInstaller now setting the __file__ attribute to the temp folder where the bundle is temporarily extracted. We don't want the data dir in a temp folder, we want it next to the exe, so use os.getcwd instead.

As a bonus, this probably fixes the --portable CLI option which I suspect was broken in Electron Cash when an attempt was made to support py2app. This will allow to run the AppImage or source dist with that option, from a hard drive or USB thumbdrive.

This also enables deprecation warnings for developers (anyone running this from a git clone)

Commits backported:

revert py2app support change for portable detection

The way config["portable"] is set overwrites the --portable command line flag.

Electron-Cash@c99d4e2


run_electrum: small clean-up, and hide DeprecationWarnings if not git

  • rename is_bundle to is_pyinstaller (no semantic changes, just to clearer name)
  • define is_appimage
  • add comment to explain is_local
    • its value is the same as before (but more explicit definition)
  • define is_git_clone, and restrict DeprecationWarnings to that case

spesmilo@5f1a13e


"--portable": make behaviour independent of pyinstaller version

pyinstaller 4.3 changed the value of __file__.
This change makes our behaviour independent of that pyinstaller change (we always behave like old versions of pyinstaller).

spesmilo@5b500f0


"--portable": more consistent behaviour

The old and new behaviour is as follows:

  1. "pyinstaller" case: portable .exe, other .exes 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 Appimage Linux Electrum doesn't work with portable wallet - "read only filesystem" spesmilo/electrum#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.

spesmilo@6a34d93

@PiRK PiRK force-pushed the fix_portable branch 2 times, most recently from d9129a4 to ddc2f81 Compare May 2, 2023 12:27
PiRK added 2 commits May 2, 2023 15:31
The main change here is that we fix the broken portable.exe behavior caused by PyInstaller now setting the `__file__` attribute to the temp folder where the bundle is temporarily extracted. We don't want the data dir in a temp folder, we want it next to the exe.

As a bonus, this probably fixes the `--portable` CLI option which I suspect was broken in Electron Cash when an attempt was made to support py2app. This will allow to run the AppImage or source dist with that option, from a hard drive or USB thumbdrive.

This also enables deprecation warnings for developers (anyone running this from a git clone)

----

revert py2app support chenge for portable detection

Electron-Cash@c99d4e2

----

 run_electrum: small clean-up, and hide DeprecationWarnings if not git

- rename `is_bundle` to `is_pyinstaller` (no semantic changes, just to clearer name)
- define `is_appimage`
- add comment to explain `is_local`
  - its value is the same as before (but more explicit definition)
- define `is_git_clone`, and restrict DeprecationWarnings to that case

spesmilo@5f1a13e

----

"--portable": make behaviour independent of pyinstaller version

pyinstaller 4.3 changed the value of `__file__`.
This change makes our behaviour independent of that pyinstaller change
(we always behave like old versions of pyinstaller).

spesmilo@5b500f0

----

"--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 spesmilo#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.

spesmilo@6a34d93
@PiRK PiRK merged commit 6ca9c3e into Bitcoin-ABC:master May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant