Thank you very much for the thorough review, I learned a lot of new things
through it.
I am planning to follow this PR up with changes to the RPM Language Bindings
on https://rpm.org/documentation.html
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-manage
Merged #3177 into master.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#event-14008051812
You are receiving this because you are subscribed to this thread.
Message ID:
___
Rpm-maint mail
Okay fair enough, I think we've reviewed and bikeshedded this enough by now
:smile:
Thanks for the examples!
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#issuecomment-2309378449
You are receiving this because you are subscribed t
@FrostyX commented on this pull request.
> @@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+# Uninstall a package from the system.
+# A Python equivalent for `rpm -e hello`
+
+import sys
+import rpm
+
+ts = rpm.TransactionSet()
+for name in sys.argv[1:]:
+ts.addErase(name)
+ts.run(lambda *args: ...,
@FrostyX commented on this pull request.
> +if what == rpm.RPMCALLBACK_INST_OPEN_FILE:
+nvr, path = mydata
+fd = os.open(path, os.O_RDONLY)
+self.fdnos[nvr] = fd
+return fd
+
+elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
+
@FrostyX pushed 1 commit.
019fad71b799cf445aa8713723f7901475012d1a Add real-life examples of Python RPM
--
View it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177/files/04f5156ba4a8883e9d3a716dfb177ce56543c64a..019fad71b799cf445aa8713723f7901475012d1a
You are receiving this
@pmatilai commented on this pull request.
> @@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+# Uninstall a package from the system.
+# A Python equivalent for `rpm -e hello`
+
+import sys
+import rpm
+
+ts = rpm.TransactionSet()
+for name in sys.argv[1:]:
+ts.addErase(name)
+ts.run(lambda *args: ...,
@pmatilai commented on this pull request.
> +if what == rpm.RPMCALLBACK_INST_OPEN_FILE:
+nvr, path = mydata
+fd = os.open(path, os.O_RDONLY)
+self.fdnos[nvr] = fd
+return fd
+
+elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
+
@FrostyX commented on this pull request.
> @@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+# Uninstall a package from the system.
+# A Python equivalent for `rpm -e hello`
+
+import sys
+import rpm
+
+ts = rpm.TransactionSet()
+for name in sys.argv[1:]:
+ts.addErase(name)
+ts.run(lambda *args: ...,
@FrostyX pushed 1 commit.
04f5156ba4a8883e9d3a716dfb177ce56543c64a Add real-life examples of Python RPM
--
View it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177/files/852582e01fcb1604c3ec3b46e79a10ddc8885825..04f5156ba4a8883e9d3a716dfb177ce56543c64a
You are receiving this
@pmatilai commented on this pull request.
> @@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+# Uninstall a package from the system.
+# A Python equivalent for `rpm -e hello`
+
+import sys
+import rpm
+
+ts = rpm.TransactionSet()
+for name in sys.argv[1:]:
+ts.addErase(name)
+ts.run(lambda *args: ...,
Once again, sorry for the delay.
@pmatilai I think I addressed all your comments. Can you please take a look
again?
> If "real-world" examples are the goal, mightn't it be better to mine actual
> real-world code that uses the Python API for examples?
I am not aware of any reasonably well-known
@FrostyX pushed 1 commit.
852582e01fcb1604c3ec3b46e79a10ddc8885825 Add real-life examples of Python RPM
--
View it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177/files/c073851b5569f4d8fdd002566d68f6d514ceef03..852582e01fcb1604c3ec3b46e79a10ddc8885825
You are receiving this
Thank you all for so many comments. I am sorry for being inactive on this PR
for a while. I was partially on vacation and now trying to catch up. I will
update the PR soon.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#issuecommen
Dnf is not the best of sources for rpm API usage. It does most of its work on
the libsolv level rather than rpm, and the little rpm API usage there is
suffers from the yum heritage.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#is
@ferdnyc commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Query a single installed package by its name.
+# A Python equivalent for `rpm -q hello`
+
+import rpm
+
+name = "hello"
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", name)
+hdr = next(mi, None)
+if hdr:
Ac
@ferdnyc commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Query a single installed package by its name.
+# A Python equivalent for `rpm -q hello`
+
+import rpm
+
+name = "hello"
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", name)
+hdr = next(mi, None)
+if hdr:
(Y
@ferdnyc commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Query a single installed package by its name.
+# A Python equivalent for `rpm -q hello`
+
+import rpm
+
+name = "hello"
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", name)
+hdr = next(mi, None)
+if hdr:
Lo
If "real-world" examples are the goal, mightn't it be better to mine _actual
real-world code_ that uses the Python API for examples? DNF comes to mind, as a
blindingly-obvious source of existing, working code based on the RPM Python
bindings. :grin:
(The examples can be simplified/sanitized fo
> All of the proposed examples show how to implement various `rpm` commands. I
> don't know whether it would be worth it having them in a separate
> (sub)directory or not.
Anything you do with the bindings is going to resemble something rpm does, I
don't see these being any different from the p
@pmatilai commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+# Install a package from a file stored on your system.
+# A Python equivalent for `rpm -i hello-2.12.1-4.fc40.x86_64.rpm`
+
+import os
+import rpm
+
+ts = rpm.TransactionSet()
+path = "/tmp/hello-2.12.1-4.fc40.x8
@pmatilai commented on this pull request.
> @@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+# Query all installed packages.
+# A Python equivalent for `rpm -qa`
+
+import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch()
+for hdr in mi:
Similar issues exist with the 'ts' handle of course - doesn't ma
@pmatilai commented on this pull request.
> @@ -0,0 +1,11 @@
+#!/usr/bin/python3
+
+# Query all installed packages.
+# A Python equivalent for `rpm -qa`
+
+import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch()
+for hdr in mi:
This isn't wrong in such a small example of course, but assignin
@pmatilai commented on this pull request.
> @@ -0,0 +1,12 @@
+#!/usr/bin/python3
+
+# Query all packages that match part of their name with the searched string.
+# A Python equivalent for `rpm -qa kernel*`
+
+import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch()
+mi.pattern("name", rpm.RPMM
@pmatilai commented on this pull request.
> @@ -0,0 +1,34 @@
+#!/usr/bin/python3
+
+# Query a single package but this time print more information.
+# A Python equivalent for `rpm -qi hello`
+
+import rpm
+
+name = "hello"
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", name)
+hdr = next(mi,
@pmatilai commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Query a single installed package by its name.
+# A Python equivalent for `rpm -q hello`
+
+import rpm
+
+name = "hello"
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", name)
+hdr = next(mi, None)
+if hdr:
T
@pmatilai commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+# Install a package from a file stored on your system.
+# A Python equivalent for `rpm -i hello-2.12.1-4.fc40.x86_64.rpm`
+
+import os
+import rpm
+
+ts = rpm.TransactionSet()
+path = "/tmp/hello-2.12.1-4.fc40.x8
@pmatilai commented on this pull request.
> +import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", "hello")
+hdr = next(mi, None)
+if hdr:
+print(
+f"Name: {hdr[rpm.RPMTAG_NAME]}\n"
+f"Version : {hdr[rpm.RPMTAG_VERSION]}\n"
+f"Release : {hdr
All of the proposed examples show how to implement various `rpm` commands. I
don't know whether it would be worth it having them in a separate
(sub)directory or not.
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177#issuecomment-21824
@FrostyX pushed 1 commit.
c073851b5569f4d8fdd002566d68f6d514ceef03 Add real-life examples of Python RPM
--
View it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3177/files/b4e0bde2705a081b86556e8489d89965de5cfc7c..c073851b5569f4d8fdd002566d68f6d514ceef03
You are receiving this
@FrostyX commented on this pull request.
> +import rpm
+
+ts = rpm.TransactionSet()
+mi = ts.dbMatch("name", "hello")
+hdr = next(mi, None)
+if hdr:
+print(
+f"Name: {hdr[rpm.RPMTAG_NAME]}\n"
+f"Version : {hdr[rpm.RPMTAG_VERSION]}\n"
+f"Release : {hdr[
@FrostyX commented on this pull request.
> @@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+# Install a package from a file stored on your system.
+# A Python equivalent for `rpm -i hello-2.12.1-4.fc40.x86_64.rpm`
+
+import os
+import rpm
+
+ts = rpm.TransactionSet()
+path = "/tmp/hello-2.12.1-4.fc40.x86
See https://github.com/rpm-software-management/rpm-web/pull/54
You can view, comment on, or merge this pull request online at:
https://github.com/rpm-software-management/rpm/pull/3177
-- Commit Summary --
* Add real-life examples of Python RPM
-- File Changes --
A python/examples/erasi
33 matches
Mail list logo