Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #243985 > unrolled thread
| Started by | Antonio Russo <aerusso@aerusso.net> |
|---|---|
| First post | 2022-01-14 16:40 +0100 |
| Last post | 2022-01-17 16:20 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.debian.user
python-apt create_pin question Antonio Russo <aerusso@aerusso.net> - 2022-01-14 16:40 +0100
Re: python-apt create_pin question Andrei POPESCU <andreimpopescu@gmail.com> - 2022-01-15 18:40 +0100
Re: python-apt create_pin question Michael Lange <klappnase@freenet.de> - 2022-01-17 11:10 +0100
Re: python-apt create_pin question Antonio Russo <aerusso@aerusso.net> - 2022-01-17 16:20 +0100
| From | Antonio Russo <aerusso@aerusso.net> |
|---|---|
| Date | 2022-01-14 16:40 +0100 |
| Subject | python-apt create_pin question |
| Message-ID | <DFwQi-8v6-15@gated-at.bofh.it> |
Hello!
I'm trying to use apt_pkg to get a "best candidate" for a package, but with
slightly different constraints than I have set up in /etc/apt/preferences.d.
I am trying to use Policy.create_pin to do so, but cannot seem to get it working:
import apt_pkg
apt_pkg.init()
cache = apt_pkg.Cache(progress=None)
policy = apt_pkg.Policy(cache)
#policy.create_pin('origin', '', 'Debian', -1)
policy.create_pin('origin', 'apt', 'Debian', -1)
policy.init_defaults()
print([ (v, policy.get_priority(v)) for v in cache['apt'].version_list ])
All calls to get_priority return 500---not -1, as I am trying to get here.
I must be doing something silly. I'd appreciate any help.
Best,
Antonio
[toc] | [next] | [standalone]
| From | Andrei POPESCU <andreimpopescu@gmail.com> |
|---|---|
| Date | 2022-01-15 18:40 +0100 |
| Message-ID | <DFVbY-7PK-33@gated-at.bofh.it> |
| In reply to | #243985 |
[Multipart message — attachments visible in raw view] — view raw
On Vi, 14 ian 22, 08:09:30, Antonio Russo wrote:
>
> Hello!
>
> I'm trying to use apt_pkg to get a "best candidate" for a package, but with
> slightly different constraints than I have set up in /etc/apt/preferences.d.
>
> I am trying to use Policy.create_pin to do so, but cannot seem to get it working:
>
> import apt_pkg
>
> apt_pkg.init()
> cache = apt_pkg.Cache(progress=None)
> policy = apt_pkg.Policy(cache)
> #policy.create_pin('origin', '', 'Debian', -1)
> policy.create_pin('origin', 'apt', 'Debian', -1)
> policy.init_defaults()
>
> print([ (v, policy.get_priority(v)) for v in cache['apt'].version_list ])
>
>
> All calls to get_priority return 500---not -1, as I am trying to get here.
>
> I must be doing something silly. I'd appreciate any help.
If you don't get an answer in a few more days you should probably try
asking on https://lists.debian.org/deity instead.
Kind regards,
Andrei
--
http://wiki.debian.org/FAQsFromDebianUser
[toc] | [prev] | [next] | [standalone]
| From | Michael Lange <klappnase@freenet.de> |
|---|---|
| Date | 2022-01-17 11:10 +0100 |
| Message-ID | <DGx7A-7lc-7@gated-at.bofh.it> |
| In reply to | #243985 |
Hi,
On Fri, 14 Jan 2022 08:09:30 -0700
Antonio Russo <aerusso@aerusso.net> wrote:
(...)
> I am trying to use Policy.create_pin to do so, but cannot seem to get
> it working:
>
> import apt_pkg
>
> apt_pkg.init()
> cache = apt_pkg.Cache(progress=None)
> policy = apt_pkg.Policy(cache)
> #policy.create_pin('origin', '', 'Debian', -1)
> policy.create_pin('origin', 'apt', 'Debian', -1)
> policy.init_defaults()
(...)
> All calls to get_priority return 500---not -1, as I am trying to get
> here.
>
> I must be doing something silly. I'd appreciate any help.
just a shot into the dark:
According to
https://apt-team.pages.debian.net/python-apt/library/apt_pkg.html :
"The parameter type refers to one of the strings ‘Version’, ‘Release’,
or ‘Origin’. "
So maybe this argument is case sensitive and changing "origin" into
"Origin" may fix the issue?
Best regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
Not one hundred percent efficient, of course ... but nothing ever is.
-- Kirk, "Metamorphosis", stardate 3219.8
[toc] | [prev] | [next] | [standalone]
| From | Antonio Russo <aerusso@aerusso.net> |
|---|---|
| Date | 2022-01-17 16:20 +0100 |
| Message-ID | <DGBXz-21H-1@gated-at.bofh.it> |
| In reply to | #244111 |
On 1/17/22 02:54, Michael Lange wrote:
(...)
>
> So maybe this argument is case sensitive and changing "origin" into
> "Origin" may fix the issue?
>
Hello Michael,
Thanks for the suggestion. Unfortunately it does not work. I had actually
dug into the source a tiny bit before posting:
Unlike the file parsing interface (ReadPinfile) in libapt, which performs a
case-insensitive compare, the Python interface to CreatePin checks for
either "Origin" or "origin":
static PyObject *policy_create_pin(PyObject *self, PyObject *args) {
pkgVersionMatch::MatchType match_type;
const char *type, *pkg, *data;
signed short priority;
if (PyArg_ParseTuple(args, "sssh", &type, &pkg, &data, &priority) == 0)
return 0;
pkgPolicy *policy = GetCpp<pkgPolicy *>(self);
if (strcmp(type,"Version") == 0 || strcmp(type, "version") == 0)
match_type = pkgVersionMatch::Version;
else if (strcmp(type,"Release") == 0 || strcmp(type, "release") == 0)
match_type = pkgVersionMatch::Release;
else if (strcmp(type,"Origin") == 0 || strcmp(type, "origin") == 0)
match_type = pkgVersionMatch::Origin;
else
match_type = pkgVersionMatch::None;
policy->CreatePin(match_type,pkg,data,priority);
HandleErrors();
Py_RETURN_NONE;
}
Direct re-testing also fails.
Best,
Antonio
> Best regards
>
> Michael
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web