Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Mintstick: Proper handling of Python Depends.
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
Weezer
n00b
n00b


Joined: 19 Apr 2024
Posts: 30

PostPosted: Thu Apr 10, 2025 11:12 am    Post subject: [Solved] Mintstick: Proper handling of Python Depends. Reply with quote

Greetings!

Somewhere along the line in my linux journey I came upon a cute little USB Image writer/stick formatting program called Mintstick (from Mint obviously). I've used it for years because it just works.

When I got to Gentoo, I couldn't find it anywhere so I initially installed it by manually copying everything, then for the last couple years I've had an ebuild I wrote by looking at the Debian and Arch builds. It also works fine. However, I am not a developer nor exactly an expert at writing ebuilds and I am pretty sure I am NOT handling the python dependencies correctly.

Here is the ebuiild for mintstick-1.6.3.ebuild:

Code:
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="A graphical tool that allows you to format and create bootable USB sticks"
HOMEPAGE="https://github.com/linuxmint/mintstick"
SRC_URI="http://packages.linuxmint.com/pool/main/m/mintstick/${PN}_${PV}.tar.xz"
S=${WORKDIR}/${PN}
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64"

RDEPEND="
   dev-lang/python
   dev-python/dbus-python
   dev-python/pygobject
   dev-python/pyparted
   dev-python/python-gnupg
   dev-python/python3-xapp
   dev-python/unidecode
   dev-libs/glib
   dev-util/desktop-file-utils
   sys-apps/coreutils
   sys-apps/util-linux
   sys-auth/polkit
   sys-block/parted
   sys-fs/dosfstools
   sys-fs/e2fsprogs
   sys-fs/exfat-utils
   sys-fs/ntfs3g
   sys-fs/udisks
   sys-process/procps
   x11-libs/gtk+
   x11-libs/xapp
"
DEPEND="${RDEPEND}"
BDEPEND="sys-devel/gettext"

src_prepare(){
   default
}

src_install(){

   insinto /usr/share/applications
      doins share/applications/*

   insinto /usr/share/polkit-1/actions
      doins share/polkit/*

   insinto /usr/share/nemo/actions
      doins -r share/nemo/actions/*

   insinto /usr/share/icons
      doins -r share/icons/*

   insinto /usr/share/kde4/apps/solid/actions
      doins share/kde4/*

   insinto /usr/bin
      dobin mintstick
      dobin mint-iso-verify
      dobin bin/mint-stick-format
      dobin bin/mint-stick-write

   insinto /usr/lib/mintstick
      doins lib/mountutils.py
      doins lib/raw_format.py
      doins lib/raw_write.py

   exeinto /usr/lib/mintstick
      doexe lib/mintstick.py
      doexe lib/verify.py

   insinto /usr/share/mintstick
      doins share/mintstick/*

   insinto /usr/share/man/man1
      doins debian/mintstick.1
}


As you can see it is not very complicated. It is a simple ebuild to make sure dependencies are installed and that things are copied to the right locations (no building of anything).

I would like to specify that the python version being used is the current Gentoo standard (python3.13 currently) and generally sticks with the Gentoo standard. I've looked for good examples and tried everyting I can think of but I'm quite confused by the python dependencies and how to handle them.

I've looked at the Gentoo ebuild wikis and they just confuse me more. I do know that the dependency 'dev-lang/python' actually causes freethreading python (3.13.3-r100) to be pulled in which It doesn't need.

I know using 'dev-lang/python:3.13' will work but after looking at all the python documentation I think I should use something like PYTHON_DEPS or PYTHON_USEDEP and specify PYTHON_COMPAT=( python3_{11..13} ) for that and the other python dependencies. However, I've not been successful in getting this right

If anyone can enlighten me on the best way to handle this, it would be GREATLY APPRECIATED as I've been kinda fighting with this for a while now.

Thanks for your assistance/time in advance! :D


Last edited by Weezer on Fri Apr 11, 2025 2:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
bstaletic
Guru
Guru


Joined: 05 Apr 2014
Posts: 506

PostPosted: Thu Apr 10, 2025 6:38 pm    Post subject: Reply with quote

The dev-lang/python dependency is to be handled by one of the three eclasses:

The python-single-r1 eclass is intended for things that can only support a single interpreter per installation. An example is app-editor/vim, which embeds an interpreter and can't possibly support multiple python versions at the same time.
The python-r1 eclass is intended for things that can support multiple interpreters at once. An example is portage, which can be installed for multiple interpreters.
The python-any-r1 eclass is intended for things that only depend on python during build time. For example, llvm-runtimes/libcxx is "just" a C++ standard library and does not depend on python at runtime, but it needs python during build time.
Finally, distutils-r1 eclass is for ebuilds of "normal" python software. "Normal" doing all the heavy lifting, because python packaging is a mess and this eclass is supposed to make your life easier in this regard.

After choosing the right eclass for your software, the ebuild should start something like this:
Code:
EAPI=8
# <insert eclass configuration here>
PYTHON_COMPAT( python3_12 python3_13 ) # Replace with the interpreters you wish to support. Free-threading one is python3_13t.
inherit python-any-r1


After choosing the right eclass, you should read its documentation, as they often come with some convenient stage functions that could make your life easier.
A short and "everything happens automatically" example is dev-python/parso.

Unfortunately, I don't think mintstick is a hole that distutils-r1 peg can fit into, so... python-r1 I guess? There's nothing about which python versions mintstick supports.

EDIT: Reading on distutils-r1,I realize one could do DISTUTILS_USE_PEP517=no, which fits your use case.
Back to top
View user's profile Send private message
Weezer
n00b
n00b


Joined: 19 Apr 2024
Posts: 30

PostPosted: Thu Apr 10, 2025 8:56 pm    Post subject: Reply with quote

Thank you bstaletic for the help!

The current python being used by the Debian package is 'python3' (no versioning whatsoever). I tend to follow that one for upgrades/updates as it is an official package. I've simply let the package use "whatever' is current for Gentoo. I run it on both stable and unstable machines. My inclination is to peg all python related dependencies to Gentoo stable.

I think from reading your post, which helps explain some things, python-r1 or distutils-r1 is what I should be using. I've tried both but I always get errors. I would like to get python-r1 to work, I think, so I can set the interprer there and have the python dependencies follow that. It seems easy enough to say, but I've tried many times to no avail. The use tags after the dependencies are fun and where I am having the difficulties I believe...

I will take at look at the examples you gave to see how they handle things. I know I've looked at Vim but not the other.

Thanks again..
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1875
Location: South America

PostPosted: Thu Apr 10, 2025 9:33 pm    Post subject: Reply with quote

Gentoo also has a Python Guide.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Weezer
n00b
n00b


Joined: 19 Apr 2024
Posts: 30

PostPosted: Fri Apr 11, 2025 2:57 pm    Post subject: Reply with quote

I believe having dev-lang/python as a direct runtime dependency was the issue (not necessary).

Removed that, used distutils-r1, set the python targets, set up the python-depends. It now sets the proper python target upon installation and is no longer pulling in python3.13t.

It is also listed as a dependent of python3:13 only.

Closing.
Back to top
View user's profile Send private message
bstaletic
Guru
Guru


Joined: 05 Apr 2014
Posts: 506

PostPosted: Fri Apr 11, 2025 5:04 pm    Post subject: Reply with quote

Weezer wrote:
I believe having dev-lang/python as a direct runtime dependency was the issue (not necessary).


Right, that was definitely wrong - you leave that to the eclasses.
I should have been more explicit with that.
Back to top
View user's profile Send private message
Weezer
n00b
n00b


Joined: 19 Apr 2024
Posts: 30

PostPosted: Sat Apr 12, 2025 11:28 am    Post subject: Reply with quote

bstaletic wrote:
Right, that was definitely wrong - you leave that to the eclasses.
I should have been more explicit with that..


No worries at all.. You pointed me to the best eclass to use and this: DISTUTILS_USE_PEP517=no, which would have taken a while to find.

I had tried so many iterations yet all had errors related to dev-lang/python dependency. I realized that it probably wasn't needed as an explicit dependency since it was changing to a python eclass. Everything behaved after that and it now appears to work like a proper python ebuild.

Thanks for confirming and again for your help. Much appreciated.
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