kontron / python-ipmi

A pure python IPMI library
GNU Lesser General Public License v2.1
189 stars 75 forks source link

a gentoo ebuild issue #179

Open Toluk opened 1 week ago

Toluk commented 1 week ago

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.

hthiery commented 1 week ago

do you know how to solve the problem in general?

Toluk commented 1 week ago

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 commented 1 week ago

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>heiko.thiery@gmail.com</email>
    <name>Heiko Thiery</name>
  </maintainer>
  <upstream>
    <remote-id type="github">kontron/python-ipmi</remote-id>
  </upstream>
</pkgmetadata>