python-ipmi icon indicating copy to clipboard operation
python-ipmi copied to clipboard

a gentoo ebuild issue

Open Toluk opened this issue 1 year ago • 3 comments

Hello.

I was trying to create a gentoo portage ebuild for this python package and encountered an issue. Which could be bypassed by such patch:

--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ except (OSError, subprocess.CalledProcessError, IOError):
             exec(f.read(), d)
             version = d['__version__']
     except IOError:
-        version = 'unknown'
+        version = '0.5.7'


 with open('README.rst') as f:

Im not sure if this is important to begin with, but decided i should report about it.

Toluk avatar Nov 06 '24 13:11 Toluk

do you know how to solve the problem in general?

hthiery avatar Nov 07 '24 09:11 hthiery

In setup.py

except (OSError, subprocess.CalledProcessError, IOError):
    try:
        with open(version_py, 'r') as f:
            d = dict()
            exec(f.read(), d)
            version = d['__version__']
    except IOError:
        version = 'unknown'

in my case this block of code falls into "version = 'unknown'" and breaks something in setuptools (my guess), may be for stable releases (or tags in general) just switch this try-except block for direct version value ? Imo it looks overcomplicated. May be the problem is that i dont install this package through pip. I have limited knowledge of pip installation.

Toluk avatar Nov 07 '24 10:11 Toluk

I'm learning how to write them, so nothing overcomplicated so far, looked at some examples and ended up with this, and it seems to work. python-ipmi-0.5.7.ebuild

# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{7..13} )
DISTUTILS_USE_PEP517=setuptools
inherit distutils-r1

DESCRIPTION="Pure Python IPMI Library"
HOMEPAGE="https://github.com/kontron/python-ipmi"
SRC_URI="https://github.com/kontron/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64"

DEPEND=""
RDEPEND="${DEPEND}"

src_prepare() {
    eapply "${FILESDIR}/version2.patch"
    eapply_user
}

and version2.patch

except (OSError, subprocess.CalledProcessError, IOError):
    try:
        with open(version_py, 'r') as f:
            d = dict()
            exec(f.read(), d)
            version = d['__version__']
    except IOError:
        version = 'unknown'

metadata.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
  <maintainer type="person">
    <email>[email protected]</email>
    <name>Heiko Thiery</name>
  </maintainer>
  <upstream>
    <remote-id type="github">kontron/python-ipmi</remote-id>
  </upstream>
</pkgmetadata>

Toluk avatar Nov 07 '24 10:11 Toluk