pyapp icon indicating copy to clipboard operation
pyapp copied to clipboard

No network

Open tfmoraes opened this issue 9 months ago • 10 comments

I'm testing pyapp and I'm liking it a lot. But in my testings it's always needed to have network to run the application for the first time. I tested with PYAPP_FULL_ISOLATION=1 and PYAPP_DISTRIBUTION_EMBED=1 this way:

PYAPP_DISTRIBUTION_FORMAT="tar|zstd" PYAPP_PROJECT_PATH="$PWD/dist/bioscaffolds-0.1.0.post213.dev0+8e76bb1-py3-none-any.whl" PYAPP_EXEC_MODULE="BioScaffolds" PYAPP_PROJECT_NAME="BioScaffolds" PYAPP_PROJECT_VERSION="0.1.0.post216.dev0+3d0ad9c" PYAPP_DISTRIBUTION_EMBED=1 PYAPP_PROJECT_DEPENDENCY_FILE="$PWD/requirements.txt" PYAPP_FULL_ISOLATION=1 PYAPP_IS_GUI=1 cargo install pyapp --force --root dist

And when I try to run without network:

dist/bin/pyapp
Error: unable to unpack to /var/home/thiago/.local/share/pyapp/bioscaffolds/15033190860216094598/0.1.0.post213.dev0+8e76bb1
failed to iterate over archive

I tested with PYAPP_SKIP_INSTALL=1 and I had the same problem.

Is it possible to make the executable no need network on runtime?

tfmoraes avatar Apr 25 '24 20:04 tfmoraes

Can you give me commands that I could run to disable network?

ofek avatar Apr 25 '24 22:04 ofek

I deactivated network here (Fedora 40 in Gnome) using NetworkManager GUI but you can deactivate using Networkmanager cli:

nmcli connection down enp4s0

Replace enp4s0 with device.

tfmoraes avatar Apr 25 '24 22:04 tfmoraes

i too am currently trying to create a self contained executable with PyApp which does not need to download stuff at runtime. As i understand it with PYAPP_DISTRIBUTION_EMBED=1 the python interpreter will be embeded and wont be needed to download at runtime. But i cannot get PyApp to also download the dependencies at build-time. if i add PYAPP_PIP_EXTRA_ARGS=--no-deps it wont install any dependencies of my .whl at all. Im also not sure what the difference between PYAPP_FULL_ISOLATION and PYAPP_DISTRIBUTION_EMBED is :/

Stubatiger avatar Apr 26 '24 12:04 Stubatiger

@tfmoraes I'm sorry I haven't had adequate time to troubleshoot, if possible do you think you could show me something that I could easily reproduce like a bash script or Dockerfile?

@Stubatiger

  • There is no such option yet to resolve dependencies at build time, for now you must preinstall into a distribution and target that distribution and then skip installation.
  • Isolation means no virtual environment is created but rather the project is installed in the base distribution that is unpacked while embedding refers to bundling the desired Python distribution into the binary which will be unpacked directly rather than downloading from somewhere.

ofek avatar May 12 '24 04:05 ofek

That "failed to iterate over archive" message is now fixed as of https://github.com/ofek/pyapp/releases/tag/v0.20.1

The issue was that the status code was not being checked so it would download a few bytes and count as success which it would then try to unpack immediately. To remove your cached distribution you may need to run <APP> self cache dist --remove or get rid of it yourself.

Can you please try again?

ofek avatar May 14 '24 14:05 ofek

I run this command to create the executable:

PYAPP_PROJECT_PATH="$PWD/dist/bioscaffolds-0.1.0.post213.dev0+8e76bb1-py3-none-any.whl" PYAPP_EXEC_MODULE="BioScaffolds" PYAPP_PROJECT_NAME="BioScaffolds" PYAPP_PROJECT_VERSION="0.1.0.post216.dev0+3d0ad9c" PYAPP_DISTRIBUTION_EMBED=1 PYAPP_PROJECT_DEPENDENCY_FILE="$PWD/requirements.txt" PYAPP_FULL_ISOLATION=1 PYAPP_IS_GUI=1 cargo install pyapp --force --root dist

Then I disconnected my PC and tried to run:

> dist/bin/pyapp
Processing /tmp/.tmpoNk0kS/bioscaffolds-0.1.0.post213.dev0+8e76bb1-py3-none-any.whl
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0914878f80>: Failed to establish a new connection: [Errno -3] Falha temporário na resolução de nome')': /simple/jinja2/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0914370110>: Failed to establish a new connection: [Errno -3] Falha temporário na resolução de nome')': /simple/jinja2/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0914370470>: Failed to establish a new connection: [Errno -3] Falha temporário na resolução de nome')': /simple/jinja2/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0914370680>: Failed to establish a new connection: [Errno -3] Falha temporário na resolução de nome')': /simple/jinja2/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f0914370410>: Failed to establish a new connection: [Errno -3] Falha temporário na resolução de nome')': /simple/jinja2/
INFO: pip is looking at multiple versions of bioscaffolds to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement jinja2<4.0.0,>=3.1.3 (from bioscaffolds) (from versions: none)
ERROR: No matching distribution found for jinja2<4.0.0,>=3.1.3

tfmoraes avatar May 14 '24 14:05 tfmoraes

Oh, I see, yeah like I mentioned above:

There is no such option yet to resolve dependencies at build time, for now you must preinstall into a distribution and target that distribution and then skip installation.

I plan to add such an option in the coming months.

ofek avatar May 14 '24 14:05 ofek

Thanks @ofek. How can I preinstall into a distribution and use that?

tfmoraes avatar May 14 '24 15:05 tfmoraes

Basically pull down one of the distributions that is used by default, install whatever you want, archive it again, then embed as you are currently doing.

ofek avatar May 14 '24 15:05 ofek

@tfmoraes Ran into the same issue a bit ago. Here is a gist that describes the steps in a bit more detail. Hope this helps, if anything is unclear, let me know and I'm happy to write it better.

trappitsch avatar Aug 31 '24 19:08 trappitsch