return PyUnicode_FromString(arch);
}
+static PyObject* _pakfire_supported_arches(void) {
+ int r;
+
+ // Fetch all architectures
+ const char** arches = pakfire_supported_arches();
+ if (!arches) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ // Create a new list
+ PyObject* list = PyList_New(0);
+ if (!list)
+ return NULL;
+
+ // Append all architectures
+ for (const char** arch = arches; *arch; arch++) {
+ PyObject* object = PyUnicode_FromString(*arch);
+ if (!object)
+ goto ERROR;
+
+ // Append to list
+ r = PyList_Append(list, object);
+ if (r) {
+ Py_DECREF(object);
+ goto ERROR;
+ }
+
+ Py_DECREF(object);
+ }
+
+ return list;
+
+ERROR:
+ Py_DECREF(list);
+ return NULL;
+}
+
static PyMethodDef pakfireModuleMethods[] = {
{"performance_index", (PyCFunction)performance_index, METH_VARARGS, NULL},
{"native_arch", (PyCFunction)_pakfire_native_arch, METH_NOARGS, NULL },
+ {"supported_arches", (PyCFunction)_pakfire_supported_arches, METH_NOARGS, NULL },
{ NULL, NULL, 0, NULL }
};
return 0;
}
+const char** __pakfire_supported_arches = NULL;
+
+PAKFIRE_EXPORT const char** pakfire_supported_arches() {
+ unsigned int counter = 0;
+
+ if (!__pakfire_supported_arches) {
+ for (const struct pakfire_arch* arch = PAKFIRE_ARCHES; arch->name; arch++) {
+ __pakfire_supported_arches = reallocarray(__pakfire_supported_arches,
+ counter + 1, sizeof(*__pakfire_supported_arches));
+
+ // Exit if the allocation failed
+ if (!__pakfire_supported_arches)
+ return NULL;
+
+ __pakfire_supported_arches[counter++] = arch->name;
+ }
+
+ // Sentinel
+ if (__pakfire_supported_arches)
+ __pakfire_supported_arches[counter] = NULL;
+ }
+
+ return __pakfire_supported_arches;
+}
+
const char* pakfire_arch_platform(const char* name) {
const struct pakfire_arch* arch = pakfire_arch_find(name);
#define PAKFIRE_ARCH_H
int pakfire_arch_supported(const char* name);
+const char** pakfire_supported_arches(void);
const char* pakfire_arch_native(void);
#ifdef PAKFIRE_PRIVATE
# arch
pakfire_arch_native;
pakfire_arch_supported;
+ pakfire_supported_arches;
# archive
pakfire_archive_extract;
# #
###############################################################################
-from ._pakfire import Pakfire
+from ._pakfire import Pakfire, native_arch, supported_arches
from .__version__ import PAKFIRE_VERSION as __version__