LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-11-2019, 01:57 PM   #1
gacekky1
LQ Newbie
 
Registered: Oct 2019
Posts: 6

Rep: Reputation: Disabled
How do you create .deb and .rpm installers from python code?


I'm having trouble finding any method to convert a python project into an installable binary.

On windows its super easy using cxFreeze: create a setup.py file, run build which creates the .exe, then run innosetup to package it all into an MSI.

Is there a similar program on linux to do the same thing? I would like to have it as cross distro as possible.

So far I've used PyInstaller, which works fine, but it just creates a binary. This could then be fed into dpkg to create a .deb file, BUT the binary has to be in the same folder as all the includes or it wont work. This obviously wont works since the bin file should be in the /usr/bin folder and the rest should be in /usr/lib/ or whatever.

I've been looking into py2deb which, in my opinion, looks like someone completely messed up. The documentation is garbage and there are 0 examples online anywhere. The old py2deb looked like a piece of cake to use. It was almost the same as cxFreeze.

I saw PyPackager but, it says there is a syntax error in the package. This whole thing is becoming very frustrating. Is there anything wrong with just releasing the binary in a tar with all of the included files?
 
Old 10-12-2019, 08:34 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Welcome to LQ.

Create python-[module].[arch].rpm :
See the ~2000 examples in Fedora 30
https://dl.fedoraproject.org/pub/fed...ee/Packages/p/
→ The build file is "name.spec".

Create package.deb : Debian examples https://packages.debian.org/source/buster/python/
→ The build file is `rules´.

-
 
Old 10-12-2019, 11:35 AM   #3
gacekky1
LQ Newbie
 
Registered: Oct 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
That's just a list of python packages...

I don't want to create a python package. I have a python program that uses a tkinter GUI that I would like the user to be able to run from the command line or a desktop icon.

All it has is 5 .py files and a folder with button images that I would like to roll up into a binary (mostly to hide my embarrassing python code, I only really know C). But if I do that it will just be sitting in the users downloads folder.

This was super easy and I got everything from the documentation: https://cx-freeze.readthedocs.io/en/.../overview.html

But it doesn't support linux! It says 'bdist_rpm' but gives no options for its use, so...yeah.
 
Old 10-13-2019, 05:11 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Your head line : "... create .deb and .rpm installers from python code": Hence source code links, with build scripts.

The other question,
Quote:
5 .py files and a folder with button images that I would like to roll up into a binary
Probably have a look at PyInstaller https://pyinstaller.readthedocs.io/e...ting-mode.html

Section »Bundling to One Folder« → → »How the One-Folder Program Works« :
Code:
The PyInstaller bootloader is a binary executable program 
for the active platform (Windows, GNU/Linux, Mac OS X, etc.).
Besides that why not use Google ?
Google, make some python scripts into one elf executable
https://www.google.com/webhp?hl=all&...elf+executable
... You will find "PyInstaller" .... and may be other suggestions.

-
 
Old 10-13-2019, 09:26 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Quote:
Is there anything wrong with just releasing the binary in a tar with all of the included files?
Yes. Some of us believe in FOSS.
 
2 members found this post helpful.
Old 10-15-2019, 09:37 PM   #6
gacekky1
LQ Newbie
 
Registered: Oct 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Yeah looking at the title, it is quite vague as to what I was trying to do. But I did list Pyinstaller as one of the things I tried that didn't work (it worked but not able to create a usable installer). I have been googling this for about two weeks, and every option is either broken, incomplete, or simply incomprehensible. Everything seems to be half done, there's about 10 different projects that people have started that do the same thing and they're all in alpha release. I just dont understand why the Mac and Windows ones are so easy to use (both literally take about an hour), but there is absolutely nothing for linux that just converts a python gui application to some sort of installable program that users can run. I can't be the only person who's wanted to do this...

What is FOSS?

Edit: Also, don't use the one file option on pyinstaller with a GUI application. It's terrible. When you run it has to basically deconstruct everything into one folder which takes forever. It almost seems like it's not going to open, it takes about 20 seconds on my junk acer laptop.

Last edited by gacekky1; 10-15-2019 at 09:42 PM.
 
Old 10-15-2019, 10:19 PM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by gacekky1 View Post
What is FOSS?
https://www.google.com/search?q=What+is+FOSS%3F
 
Old 10-16-2019, 01:00 AM   #8
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
deb and rpm are just archives with metadata

for example, a debian.deb
https://salsa.debian.org/games-team/game-data-packager
picked at random as I know it is python

## is the output I get

Code:
mkdir Temp && cd Temp
ar xv ../game-data-packager_64_all.deb 
## x - debian-binary
## x - control.tar.xz
## x - data.tar.xz
Code:
file debian-binary 
## debian-binary: ASCII text
cat debian-binary
## 2.0
lets look at control.tar.xz
Code:
tar tfv control.tar.xz 
## drwxr-xr-x root/root         0 2019-02-10 16:11 ./
## -rw-r--r-- root/root       625 2019-02-10 16:11 ./conffiles
## -rw-r--r-- root/root      5215 2019-02-10 16:11 ./control
## -rw-r--r-- root/root      7476 2019-02-10 16:11 ./md5sums
## -rwxr-xr-x root/root       718 2019-02-10 16:11 ./postinst
## -rwxr-xr-x root/root       403 2019-02-10 16:11 ./postrm
## -rwxr-xr-x root/root       403 2019-02-10 16:11 ./preinst
## -rwxr-xr-x root/root       797 2019-02-10 16:11 ./prerm
you can probably figure out what they are from the names

a quick peek at the data tar
Code:
tar tfv data.tar.xz |grep py$
-rw-r--r-- root/root       886 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/__init__.py
-rw-r--r-- root/root     99586 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/build.py
-rw-r--r-- root/root     14420 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/command_line.py
-rw-r--r-- root/root      2346 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/config.py
-rw-r--r-- root/root     33129 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/data.py
-rw-r--r-- root/root      6674 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/download.py
-rw-r--r-- root/root     47527 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/game.py
-rw-r--r-- root/root        36 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/games/__init__.py
-rw-r--r-- root/root      8527 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/games/doom_common.py
-rw-r--r-- root/root      4008 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/games/dosbox.py
-rw-r--r-- root/root      4365 2018-01-16 02:59 ./usr/share/games/game-data-packager/game_data_packager/games/ecwolf_common.py
-rw-r--r-- root/root      3311 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/games/lgeneral.py
-rw-r--r-- root/root      4976 2019-02-10 16:11 ./usr/share/games/game-data-packager/game_data_packager/games/morrowind.py
many more files, but look... python
I wa slucky picking that package at random


so, if you want to learn how to package deb , pull one apart
then look at how they are created
https://salsa.debian.org/games-team/.../master/debian
then read the docs
https://wiki.debian.org/HowToPackageForDebian

game-data-packager might not be the best to learn from
hmm, youtube-dl, that is python

Code:
apt -s source youtube-dl 
## Reading package lists... Done
## NOTICE: 'youtube-dl' packaging is maintained in the 'Git' version
## control system at:
## https://github.com/rbrito/pkg-youtube-dl
## Please use:
## git clone https://github.com/rbrito/pkg-youtube-dl
## to retrieve the latest (possibly unreleased) updates to the package.
## Need to get 3,214 kB of source archives.
## Fetch source youtube-dl
-s is simulate. without it you d/l tarballs
Personally I prefer to get the git

That should be easier for you to work out how to pkg your python project for Debian
( the important stuff is in debian/ )


rpm is going to be similar
slackware is just tarballs, breaking FOSS ?
I really don't see how TApeaRchive impinges on FOSS

alien ( the debian package, not the broken scripts hoster ) can convert between redhat, slackware and debian

I've only used it for zfs, rpm to deb
but that will let you
Code:
alien -r YourPython.deb
to make an rpm from your deb
I'm not sure how well the deps are handled

have fun
 
Old 10-16-2019, 03:02 AM   #9
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Firerat View Post
breaking FOSS ?
I really don't see how TApeaRchive impinges on FOSS
I think the OP is asking how to obfuscate the *.py files, not openly package/distribute them in any of the normal ways.

Evo2.

Last edited by evo2; 10-16-2019 at 03:04 AM.
 
1 members found this post helpful.
Old 10-16-2019, 07:37 AM   #10
gacekky1
LQ Newbie
 
Registered: Oct 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by evo2 View Post
I think the OP is asking how to obfuscate the *.py files, not openly package/distribute them in any of the normal ways.
Yes, this is correct.

This is just a test utility for a piece of hardware that I'm selling. Why would it be open source...actually why would anyone want the code for it?

It just communicates to an RS485 serial device, not exactly ground breaking stuff. And yes, I would like it to be a binary package with an easy to use deb installer to look "professional" I suppose. It's not like I'm selling the program anyway, it will be free to download and use.

Last edited by gacekky1; 10-16-2019 at 08:01 AM. Reason: typo
 
Old 10-16-2019, 07:48 AM   #11
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by gacekky1 View Post
Yes, this is correct.

This is just a test utility for a piece of hardware that I'm selling. Why would it be open source...actually why would anyone want the code for it?

It's just communicates to an RS485 serial device, not exactly ground breaking stuff. And yes, I would like it to be a binary package with an easy to use deb installer to look "professional" I suppose. It's not like I'm selling the program anyway, it will be free to download and use.
hmm
well I miss understood your intent then

I miss read package binary tar


what you have is gratis to download and use, but you are not free to improve it

just package it as clear python , apologise for the poor quality code in comments and invite improvements.

I have already started you on the right path to packaging your code

but if it is trivial, you don't really need a full installable package, just a tutorial on running the script

Last edited by Firerat; 10-16-2019 at 07:49 AM.
 
Old 10-16-2019, 07:10 PM   #12
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by gacekky1 View Post
This is just a test utility for a piece of hardware that I'm selling. Why would it be open source...actually why would anyone want the code for it?
Many reasons. Did you read read about FOSS yet?

One example: So users can run it on systems other than the ones that you provided binaries for.



Evo2.
 
Old 10-16-2019, 11:36 PM   #13
gacekky1
LQ Newbie
 
Registered: Oct 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Well at this rate, it looks like it's going to be Windows and Mac only...
 
Old 10-17-2019, 03:23 AM   #14
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by gacekky1 View Post
Well at this rate, it looks like it's going to be Windows and Mac only...
Sigh.

Evo2.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract deb package,change and create deb again ccc Debian 2 12-19-2014 11:40 PM
How do you check for a list of .deb dependencies without installing the deb file arthur_makowah Linux - Newbie 3 07-23-2014 11:04 PM
Using i4l to create application installers for Linux gnumaru Linux - Desktop 4 10-30-2010 03:41 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
how do you install the loki installers timalan SUSE / openSUSE 4 08-25-2005 02:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration