Distributing Python to Losedows useds

8 risposte [Ultimo contenuto]
koszkonutek
Offline
Iscritto: 03/19/2020

I predict I will need to distribute Python programs in a way they can be easily executed on computers running M$ Losedows. The users should not be required to go through the procedure of installing Python.

Normally, this would be fairly easily achieved by bundling a Python interpreter with the program. Unfortunately, the existing tools for the job rely on Python built with nonfree M$ Visual Studio compiler. If a program relies on nonfree software to build, it cannot be considered entirely free. For that reason, I'd like to find a way to cross-compile Python interpreter for mingw-w64 using GCC (although LLVM would also be OK) under a GNU/Linux system. Such setup doesn't seem to be supported by upstream CPython sources but I hope to find some workarounds. For example, it seems MSYS2 patches CPython so that it builds with GCC. Another idea is to try distributing a Cygwin build of CPython instead. I could also try giving PyPy a go.

I wanted to see if you could give me some advice how to best approach this problem. Perhaps some of you have more experience with the tools I mentioned or maybe you'll even be able to tell me that some of the ideas are not going to work and are not worth wasting time on?

andyprough
Online
Iscritto: 02/12/2015

>"Unfortunately, the existing tools for the job rely on Python built with nonfree M$ Visual Studio compiler. If a program relies on nonfree software to build, it cannot be considered entirely free."

This DigitalOcean page seems to describe how to manually package a python app for windows: https://www.digitalocean.com/community/tutorials/how-to-package-and-distribute-python-applications

Not sure if this answers your question, I'm not someone who has tried this before.

koszkonutek
Offline
Iscritto: 03/19/2020

It actually just describes packaging for PyPI. Not what I was interested in but still thanks for trying :)

Any ideas what would be the right place to ask such things? Is there maybe some pub where GNU gurus meet?

andyprough
Online
Iscritto: 02/12/2015

There's a Trisquel IRC channel where I think that Ruben (quidam) and the devs hang out: https://trisquel.info/en/wiki/connect-trisquel-irc-channel

You might try that first.

andermetalsh
Offline
Iscritto: 01/04/2013

On PyPI, install pypi2deb from repos.

An example, with curseradio-improved:

$ mkdir ~/del.me
$ cd ~/del.me
$ py2dsp --build --application curseradio-improved #(this is software, not a module)
$ sudo dpkg-i result/*.deb

Done.

lanun
Offline
Iscritto: 04/01/2021

I do believe there is an evil twist in this seemingly innocent picture. One tentacle to rule them all...Digital Ocean...

Anyway, I also believe kokonutek should have no qualms delivering libre software to prison software users, it is completely ethical. A bit like smuggling breadcrumbs to starving death row prisoners.

hidden_evil.png
bungholio
Offline
Iscritto: 06/07/2022

bundling a python interpreter is really easy, what those tools koszkonutek referred to just bundle it all into a single PE executable iirc. If you don't really mind that, you can just send them a lightweight python interpreter, provided by the python devs themselves: https://www.python.org/ftp/python/3.10.5/python-3.10.5-embed-amd64.zip
thats what I did whenever I had to send someone a little python script. you can also make an executable that just points the python interpreter at your main python script, something like this:

#include

int WinMain()
{
Py_Initialize();
wchar_t*argvar[]={L"foo",L"some/dir/main.py"};
Py_Main(2,argvar);
Py_Finalize();
return 0;

}
which you can cross compile with mingw

koszkonutek
Offline
Iscritto: 03/19/2020

This is a very interesting alternative to the mainstream bundlers, even tho it does not fix the issue of the interpreter provided by python devs being itself compiled with MSVC.

If I decide to give up (which I am not doing before I at least try cross-compiling pypy instead of cpython), I might choose this way.

Thanks

bungholio
Offline
Iscritto: 06/07/2022

Well, python is free software, regardless of what compiler is used to build it, right? and theres probably proprietary software out there built with gcc too. at any rate we're working at a damage reduction level anyway, even if your python interpreter is built with a free compiler, the target platform is proprietary, and you will inevitably link to nonfree libraries, or interact with a nonfree kernel. my solution doesn't require you to *use* any nonfree software, but of course this is out of the question for the end user.
If one were extremely strict about trapped free software abd so on, then you wouldn't be distributing to proprietary platforms in the first place, right?

one last ditch idea is maybe you can just copy the layout of the embeddable .zip file but using cygwin/MSYS2 or whatever binaries? and add the cygwin or MSYS2 libraries if needed.