]> git.ipfire.org Git - pakfire.git/blob - src/_pakfiremodule.c
Fix composing of source packages on the server.
[pakfire.git] / src / _pakfiremodule.c
1
2 #include <Python.h>
3
4 #include "pool.h"
5 #include "problem.h"
6 #include "relation.h"
7 #include "repo.h"
8 #include "request.h"
9 #include "solvable.h"
10 #include "solver.h"
11 #include "step.h"
12 #include "transaction.h"
13
14 static PyMethodDef pakfireModuleMethods[] = {
15 { NULL, NULL, 0, NULL }
16 };
17
18 static PyMethodDef Pool_methods[] = {
19 {"prepare", (PyCFunction)Pool_prepare, METH_NOARGS, NULL},
20 {"size", (PyCFunction)Pool_size, METH_NOARGS, NULL},
21 {"set_installed", (PyCFunction)Pool_set_installed, METH_VARARGS, NULL},
22 {"providers", (PyCFunction)Pool_providers, METH_VARARGS, NULL},
23 {"search", (PyCFunction)Pool_search, METH_VARARGS, NULL},
24 { NULL, NULL, 0, NULL }
25 };
26
27 static PyMethodDef Problem_methods[] = {
28 { NULL, NULL, 0, NULL }
29 };
30
31 static PyMethodDef Request_methods[] = {
32 {"install_solvable", (PyCFunction)Request_install_solvable, METH_VARARGS, NULL},
33 {"install_relation", (PyCFunction)Request_install_relation, METH_VARARGS, NULL},
34 {"install_name", (PyCFunction)Request_install_name, METH_VARARGS, NULL},
35 {"remove_solvable", (PyCFunction)Request_remove_solvable, METH_VARARGS, NULL},
36 {"remove_relation", (PyCFunction)Request_remove_relation, METH_VARARGS, NULL},
37 {"remove_name", (PyCFunction)Request_remove_name, METH_VARARGS, NULL},
38 {"update_solvable", (PyCFunction)Request_update_solvable, METH_VARARGS, NULL},
39 {"update_relation", (PyCFunction)Request_update_relation, METH_VARARGS, NULL},
40 {"update_name", (PyCFunction)Request_update_name, METH_VARARGS, NULL},
41 {"lock_solvable", (PyCFunction)Request_lock_solvable, METH_VARARGS, NULL},
42 {"lock_relation", (PyCFunction)Request_lock_relation, METH_VARARGS, NULL},
43 {"lock_name", (PyCFunction)Request_lock_name, METH_VARARGS, NULL},
44 { NULL, NULL, 0, NULL }
45 };
46
47 static PyMethodDef Relation_methods[] = {
48 { NULL, NULL, 0, NULL }
49 };
50
51 static PyMethodDef Repo_methods[] = {
52 {"name", (PyCFunction)Repo_name, METH_NOARGS, NULL},
53 {"size", (PyCFunction)Repo_size, METH_NOARGS, NULL},
54 {"get_enabled", (PyCFunction)Repo_get_enabled, METH_NOARGS, NULL},
55 {"set_enabled", (PyCFunction)Repo_set_enabled, METH_VARARGS, NULL},
56 {"get_priority", (PyCFunction)Repo_get_priority, METH_NOARGS, NULL},
57 {"set_priority", (PyCFunction)Repo_set_priority, METH_VARARGS, NULL},
58 {"write", (PyCFunction)Repo_write, METH_VARARGS, NULL},
59 {"read", (PyCFunction)Repo_read, METH_VARARGS, NULL},
60 {"clear", (PyCFunction)Repo_clear, METH_NOARGS, NULL},
61 {"get_all", (PyCFunction)Repo_get_all, METH_NOARGS, NULL},
62 { NULL, NULL, 0, NULL }
63 };
64
65 static PyMethodDef Solvable_methods[] = {
66 {"get_name", (PyCFunction)Solvable_get_name, METH_NOARGS, NULL},
67 {"get_evr", (PyCFunction)Solvable_get_evr, METH_NOARGS, NULL},
68 {"get_arch", (PyCFunction)Solvable_get_arch, METH_NOARGS, NULL},
69 {"get_vendor", (PyCFunction)Solvable_get_vendor, METH_NOARGS, NULL},
70 {"set_vendor", (PyCFunction)Solvable_set_vendor, METH_VARARGS, NULL},
71 {"get_repo_name", (PyCFunction)Solvable_get_repo_name, METH_NOARGS, NULL},
72 {"get_uuid", (PyCFunction)Solvable_get_uuid, METH_NOARGS, NULL},
73 {"set_uuid", (PyCFunction)Solvable_set_uuid, METH_VARARGS, NULL},
74 {"get_hash1", (PyCFunction)Solvable_get_hash1, METH_NOARGS, NULL},
75 {"set_hash1", (PyCFunction)Solvable_set_hash1, METH_VARARGS, NULL},
76 {"get_summary", (PyCFunction)Solvable_get_summary, METH_NOARGS, NULL},
77 {"set_summary", (PyCFunction)Solvable_set_summary, METH_VARARGS, NULL},
78 {"get_description", (PyCFunction)Solvable_get_description, METH_NOARGS, NULL},
79 {"set_description", (PyCFunction)Solvable_set_description, METH_VARARGS, NULL},
80 {"get_groups", (PyCFunction)Solvable_get_groups, METH_NOARGS, NULL},
81 {"set_groups", (PyCFunction)Solvable_set_groups, METH_VARARGS, NULL},
82 {"get_url", (PyCFunction)Solvable_get_url, METH_NOARGS, NULL},
83 {"set_url", (PyCFunction)Solvable_set_url, METH_VARARGS, NULL},
84 {"get_filename", (PyCFunction)Solvable_get_filename, METH_NOARGS, NULL},
85 {"set_filename", (PyCFunction)Solvable_set_filename, METH_VARARGS, NULL},
86 {"get_license", (PyCFunction)Solvable_get_license, METH_NOARGS, NULL},
87 {"set_license", (PyCFunction)Solvable_set_license, METH_VARARGS, NULL},
88 {"get_buildhost", (PyCFunction)Solvable_get_buildhost, METH_NOARGS, NULL},
89 {"set_buildhost", (PyCFunction)Solvable_set_buildhost, METH_VARARGS, NULL},
90 {"get_maintainer", (PyCFunction)Solvable_get_maintainer, METH_NOARGS, NULL},
91 {"set_maintainer", (PyCFunction)Solvable_set_maintainer, METH_VARARGS, NULL},
92 {"get_downloadsize", (PyCFunction)Solvable_get_downloadsize, METH_NOARGS, NULL},
93 {"set_downloadsize", (PyCFunction)Solvable_set_downloadsize, METH_VARARGS, NULL},
94 {"get_installsize", (PyCFunction)Solvable_get_installsize, METH_NOARGS, NULL},
95 {"set_installsize", (PyCFunction)Solvable_set_installsize, METH_VARARGS, NULL},
96 {"get_buildtime", (PyCFunction)Solvable_get_buildtime, METH_NOARGS, NULL},
97 {"set_buildtime", (PyCFunction)Solvable_set_buildtime, METH_VARARGS, NULL},
98 {"add_provides", (PyCFunction)Solvable_add_provides, METH_VARARGS, NULL},
99 {"get_provides", (PyCFunction)Solvable_get_provides, METH_NOARGS, NULL},
100 {"add_requires", (PyCFunction)Solvable_add_requires, METH_VARARGS, NULL},
101 {"get_requires", (PyCFunction)Solvable_get_requires, METH_NOARGS, NULL},
102 {"add_obsoletes", (PyCFunction)Solvable_add_obsoletes, METH_VARARGS, NULL},
103 {"get_obsoletes", (PyCFunction)Solvable_get_obsoletes, METH_NOARGS, NULL},
104 {"add_conflicts", (PyCFunction)Solvable_add_conflicts, METH_VARARGS, NULL},
105 {"get_conflicts", (PyCFunction)Solvable_get_conflicts, METH_NOARGS, NULL},
106 { NULL, NULL, 0, NULL }
107 };
108
109 static PyMethodDef Solver_methods[] = {
110 {"solve", (PyCFunction)Solver_solve, METH_VARARGS, NULL},
111 {"get_allow_downgrade", (PyCFunction)Solver_get_allow_downgrade, METH_NOARGS, NULL},
112 {"set_allow_downgrade", (PyCFunction)Solver_set_allow_downgrade, METH_VARARGS, NULL},
113 {"get_allow_archchange", (PyCFunction)Solver_get_allow_archchange, METH_NOARGS, NULL},
114 {"set_allow_archchange", (PyCFunction)Solver_set_allow_archchange, METH_VARARGS, NULL},
115 {"get_allow_vendorchange", (PyCFunction)Solver_get_allow_vendorchange, METH_NOARGS, NULL},
116 {"set_allow_vendorchange", (PyCFunction)Solver_set_allow_vendorchange, METH_VARARGS, NULL},
117 {"get_allow_uninstall", (PyCFunction)Solver_get_allow_uninstall, METH_NOARGS, NULL},
118 {"set_allow_uninstall", (PyCFunction)Solver_set_allow_uninstall, METH_VARARGS, NULL},
119 {"get_updatesystem", (PyCFunction)Solver_get_updatesystem, METH_NOARGS, NULL},
120 {"set_updatesystem", (PyCFunction)Solver_set_updatesystem, METH_VARARGS, NULL},
121 {"get_do_split_provides", (PyCFunction)Solver_get_do_split_provides, METH_NOARGS, NULL},
122 {"set_do_split_provides", (PyCFunction)Solver_set_do_split_provides, METH_VARARGS, NULL},
123 {"get_problems", (PyCFunction)Solver_get_problems, METH_VARARGS, NULL},
124 { NULL, NULL, 0, NULL }
125 };
126
127 static PyMethodDef Step_methods[] = {
128 {"get_solvable", (PyCFunction)Step_get_solvable, METH_NOARGS, NULL},
129 {"get_type", (PyCFunction)Step_get_type, METH_NOARGS, NULL},
130 { NULL, NULL, 0, NULL }
131 };
132
133 static PyMethodDef Transaction_methods[] = {
134 {"steps", (PyCFunction)Transaction_steps, METH_NOARGS, NULL},
135 { NULL, NULL, 0, NULL }
136 };
137
138 void init_pakfire(void) {
139 PyObject *m, *d;
140
141 m = Py_InitModule("_pakfire", pakfireModuleMethods);
142
143 // Pool
144 PoolType.tp_methods = Pool_methods;
145 if (PyType_Ready(&PoolType) < 0)
146 return;
147 Py_INCREF(&PoolType);
148 PyModule_AddObject(m, "Pool", (PyObject *)&PoolType);
149
150 // Problem
151 ProblemType.tp_methods = Problem_methods;
152 if (PyType_Ready(&ProblemType) < 0)
153 return;
154 Py_INCREF(&ProblemType);
155 PyModule_AddObject(m, "Problem", (PyObject *)&ProblemType);
156
157 // Repo
158 RepoType.tp_methods = Repo_methods;
159 if (PyType_Ready(&RepoType) < 0)
160 return;
161 Py_INCREF(&RepoType);
162 PyModule_AddObject(m, "Repo", (PyObject *)&RepoType);
163
164 // Solvable
165 SolvableType.tp_methods = Solvable_methods;
166 if (PyType_Ready(&SolvableType) < 0)
167 return;
168 Py_INCREF(&SolvableType);
169 PyModule_AddObject(m, "Solvable", (PyObject *)&SolvableType);
170
171 // Relation
172 RelationType.tp_methods = Relation_methods;
173 if (PyType_Ready(&RelationType) < 0)
174 return;
175 Py_INCREF(&RelationType);
176 PyModule_AddObject(m, "Relation", (PyObject *)&RelationType);
177
178 // Request
179 RequestType.tp_methods = Request_methods;
180 if (PyType_Ready(&RequestType) < 0)
181 return;
182 Py_INCREF(&RequestType);
183 PyModule_AddObject(m, "Request", (PyObject *)&RequestType);
184
185 // Solver
186 SolverType.tp_methods = Solver_methods;
187 if (PyType_Ready(&SolverType) < 0)
188 return;
189 Py_INCREF(&SolverType);
190 PyModule_AddObject(m, "Solver", (PyObject *)&SolverType);
191
192 // Step
193 StepType.tp_methods = Step_methods;
194 if (PyType_Ready(&StepType) < 0)
195 return;
196 Py_INCREF(&StepType);
197 PyModule_AddObject(m, "Step", (PyObject *)&StepType);
198
199 // Transaction
200 TransactionType.tp_methods = Transaction_methods;
201 if (PyType_Ready(&TransactionType) < 0)
202 return;
203 Py_INCREF(&TransactionType);
204 PyModule_AddObject(m, "Transaction", (PyObject *)&TransactionType);
205
206 // Add constants
207 d = PyModule_GetDict(m);
208
209 // Add constants for relations
210 PyDict_SetItemString(d, "REL_EQ", Py_BuildValue("i", REL_EQ));
211 PyDict_SetItemString(d, "REL_LT", Py_BuildValue("i", REL_LT));
212 PyDict_SetItemString(d, "REL_GT", Py_BuildValue("i", REL_GT));
213 PyDict_SetItemString(d, "REL_LE", Py_BuildValue("i", REL_LT|REL_EQ));
214 PyDict_SetItemString(d, "REL_GE", Py_BuildValue("i", REL_GT|REL_EQ));
215
216 // Add constants for search
217 PyDict_SetItemString(d, "SEARCH_STRING", Py_BuildValue("i", SEARCH_STRING));
218 PyDict_SetItemString(d, "SEARCH_STRINGSTART", Py_BuildValue("i", SEARCH_STRINGSTART));
219 PyDict_SetItemString(d, "SEARCH_STRINGEND", Py_BuildValue("i", SEARCH_STRINGEND));
220 PyDict_SetItemString(d, "SEARCH_SUBSTRING", Py_BuildValue("i", SEARCH_SUBSTRING));
221 PyDict_SetItemString(d, "SEARCH_GLOB", Py_BuildValue("i", SEARCH_GLOB));
222 PyDict_SetItemString(d, "SEARCH_REGEX", Py_BuildValue("i", SEARCH_REGEX));
223 PyDict_SetItemString(d, "SEARCH_FILES", Py_BuildValue("i", SEARCH_FILES));
224 PyDict_SetItemString(d, "SEARCH_CHECKSUMS", Py_BuildValue("i", SEARCH_CHECKSUMS));
225 }