Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] Best way to build a standalone Python executable?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
blochl
n00b
n00b


Joined: 28 Aug 2018
Posts: 18

PostPosted: Wed Aug 21, 2024 6:29 am    Post subject: [solved] Best way to build a standalone Python executable? Reply with quote

Hi,
I'm trying to build a standalone executable from a complex Python project (complex in the sense that it consists of multiple Python scripts, and .so files, compiled as a Python C extension). I want it to run independently of the Python version and of the local libraries on the system.
I see a lot of options: PyInstaller, PyOxidizer, Nukita, to name a few.
My question is: which tool or approach is considered to be the best practice for this nowadays?

Thanks!


Last edited by blochl on Mon Aug 26, 2024 2:32 pm; edited 1 time in total
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9605
Location: beyond the rim

PostPosted: Wed Aug 21, 2024 6:26 pm    Post subject: Reply with quote

Start with checking which of these is actually still maintained and officially supports current python version. For example PyOxidizer did not have a release for over 18 months now, which is an indicator that it is probably abandoned and a dead end. Then obviously you'll need to check which tool is actually compatible with your project and all its dependencies. These things usually have some restrictions and/or require modifications to your codebase to work as intended. Also check the design of the different tools, e.g. Nuitka works very different than PyInstaller and each approach has its own ups and downs.

You mention that your project consists of multiple python scripts. Are these actual scripts to be executed by the user via commandline/UI, or modules loaded by a single main application? The mentioned tools usually are designed for the second use case, the first case will likely require quite a bit more work.

TL;DR: There is no single "best" approach.
Back to top
View user's profile Send private message
blochl
n00b
n00b


Joined: 28 Aug 2018
Posts: 18

PostPosted: Mon Aug 26, 2024 2:38 pm    Post subject: Reply with quote

Thanks!

Eventually ended up using Nuitka:
Tried PyInstaller, because it seems to be the most used, but the resulting binary had some module import issues. Then tried Nuitka, and it just worked! PyOxidizer seems to be not actively maintained indeed.

P.S. The project is indeed one executable script. All the others are modules loaded by the main application.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum