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

No network #117

Open
tfmoraes opened this issue Apr 25, 2024 · 10 comments
Open

No network #117

tfmoraes opened this issue Apr 25, 2024 · 10 comments

Comments

@tfmoraes
Copy link

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?

@ofek
Copy link
Owner

ofek commented Apr 25, 2024

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

@tfmoraes
Copy link
Author

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.

@Stubatiger
Copy link

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 :/

@ofek
Copy link
Owner

ofek commented May 12, 2024

@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
Copy link
Owner

ofek commented May 14, 2024

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?

@tfmoraes
Copy link
Author

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

@ofek
Copy link
Owner

ofek commented May 14, 2024

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.

@tfmoraes
Copy link
Author

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

@ofek
Copy link
Owner

ofek commented May 14, 2024

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.

@trappitsch
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants