Question About Debian Package Control File

Contribute code to SolydXK and make it even better.
User avatar
wildman
Posts: 246
Joined: 12 Feb 2014 23:31
Location: Kentucky, USA

Question About Debian Package Control File

Postby wildman » 29 Mar 2016 04:09

I have a program that I wrote using Python and Tkinter. The program is written in such a way to allow it to run on Python 2 or 3. And I want to package the program in .deb format. This presents me with a dependency problem. Tkinter has separate packages for the two Python versions and they are not interchangeable. So my program's dependencies are different depending on which version of Python is installed. I was not able to find any info on this particular subject. Not even on Debian's website. Below is an idea I had and was hoping someone could tell me if this depends entry might work. Assuming the syntax of the entry is ok, I'm not sure what would happen if both versions of Python are installed. Schoelje?

Code: Select all

Depends: (python (<<3.0.0), python-tk, python-pil.imagetk) | (python (>=3.0.0), python3-tk, python3-pil.imagetk)
Wildman
May the Source be with you.

User avatar
Arjen Balfoort
Site Admin
Posts: 9311
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Question About Debian Package Control File

Postby Arjen Balfoort » 29 Mar 2016 13:25

Moved your topic to the Code forum.

It sounds logical but I have no experience with these kind of dependency formats. You really just have to try it out.

On the ISOs both python2.7 and python3 are installed.
Some packages still use 2.7 but all SolydXK packages use python3.

Out of curiosity: In your scripts, how do you set which version it should use if both versions are available?


SolydXK needs you!
Development | Testing | Translations

User avatar
wildman
Posts: 246
Joined: 12 Feb 2014 23:31
Location: Kentucky, USA

Re: Question About Debian Package Control File

Postby wildman » 29 Mar 2016 16:01

Schoelje wrote:Out of curiosity: In your scripts, how do you set which version it should use if both versions are available?
The script runs the same no matter which version so it doesn't really matter. I use the import function. It tries version 2.x first and if that fails it imports the version 3 modules. The version 3 modules are imported with aliases of the same name as the version 2 modules so nothing in the code is version dependent.

Code: Select all

try:
    import Tkinter as tk
    from Tkinter import Tk
    import tkFileDialog
    import tkMessageBox
    import Image
    import ImageTk
except ImportError:
    import tkinter as tk
    from tkinter import Tk
    import tkinter.filedialog as tkFileDialog
    import tkinter.messagebox as tkMessageBox
    import PIL.Image as Image
    import PIL.ImageTk as ImageTk
Thanks for the reply. I will have to just build the .deb and test it.
Wildman
May the Source be with you.

User avatar
Arjen Balfoort
Site Admin
Posts: 9311
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Question About Debian Package Control File

Postby Arjen Balfoort » 29 Mar 2016 19:22

Yes, I thought you would do that.
Why not use Python3 and use 2.7 as fallback?


SolydXK needs you!
Development | Testing | Translations

kurotsugi
Posts: 2234
Joined: 09 Jan 2014 00:17

Re: Question About Debian Package Control File

Postby kurotsugi » 30 Mar 2016 03:56

+1.

python 2 got dead sentence in debian. you need to port everything to python 3 on the next debian release.

User avatar
wildman
Posts: 246
Joined: 12 Feb 2014 23:31
Location: Kentucky, USA

Re: Question About Debian Package Control File

Postby wildman » 30 Mar 2016 18:15

Schoelje wrote:Yes, I thought you would do that.
Why not use Python3 and use 2.7 as fallback?
I didn't really give that much thought. I guess I thought it would be more likely that Python2 would be installed. However, as kurotsugi pointed out, Python2 is on the way out.

Anyway, I have the answer to my original question about using the pipe (OR operator) in the control file. Using the extra parentheses did not work. I got a build error saying package names must start with an alpha-numeric character. So I tried it without them. Python2 package on the left and Python3 packages on the right with the pipe in the center. I built a dummy deb to test it. Tried it with Ubuntu 14.04 in a VM that had all the Python2 packages installed. Some of the Python3 packages were missing. If the pipe worked the way I wanted, the package manager should report that dependencies were satisfied. That is not what happened. The package manager reported that the Python3 packages were missing. It appears that the pipe only works for the two packages that are on either side of it.

I guess the smart thing to do is to rewrite my program to support Python3 only. That is what I'm going to do. Thanks for your feedback.
Wildman
May the Source be with you.

User avatar
Arjen Balfoort
Site Admin
Posts: 9311
Joined: 26 Jan 2013 19:36
Location: Netherlands
Contact:

Re: Question About Debian Package Control File

Postby Arjen Balfoort » 30 Mar 2016 21:07

That's a tedious job but well worth it. I did that with the live installer. It took a long time and a lot of testing but now I'm happy I did. Let me know if I can do anything to test/debug and of course, if you have too much time on your hand, check out our Github projects ;)


SolydXK needs you!
Development | Testing | Translations


Return to “Code”

Who is online

Users browsing this forum: No registered users and 1 guest