aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 00:06:57 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-11-14 00:06:57 +0000
commit57e078aec9546a4d3738eaaaf1f51bb061a8e2b8 (patch)
tree2705c91ed04d0410824b9d71234c4af3109f78f3
parent7d264966104e6c79ee6fc74a1b5545aca68dde10 (diff)
downloadpaludis-57e078aec9546a4d3738eaaaf1f51bb061a8e2b8.tar.gz
paludis-57e078aec9546a4d3738eaaaf1f51bb061a8e2b8.tar.xz
(python) Add Paludis version constants.
-rw-r--r--doc/api/python/Makefile.am1
-rwxr-xr-xdoc/api/python/example_about.py11
-rw-r--r--python/Makefile.am1
-rw-r--r--python/about.cc38
-rw-r--r--python/paludis_python.hh1
-rw-r--r--python/paludis_python_so.cc1
6 files changed, 53 insertions, 0 deletions
diff --git a/doc/api/python/Makefile.am b/doc/api/python/Makefile.am
index f6a679e..0429561 100644
--- a/doc/api/python/Makefile.am
+++ b/doc/api/python/Makefile.am
@@ -4,6 +4,7 @@ CLEANFILES = *~ python/*
MAINTAINERCLEANFILES = Makefile.in
examples = \
+ example_about.py \
example_command_line.py \
example_version_spec.py
diff --git a/doc/api/python/example_about.py b/doc/api/python/example_about.py
new file mode 100755
index 0000000..cd4738c
--- /dev/null
+++ b/doc/api/python/example_about.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 sw=4 sts=4 et :
+
+"""A simple example showing how to use Paludis version constants"""
+
+import paludis
+
+print "Built using Paludis " + paludis.VERSION + paludis.VERSION_SUFFIX,
+
+if paludis.SUBVERSION_REVISION:
+ print 'r' + paludis.SUBVERSION_REVISION
diff --git a/python/Makefile.am b/python/Makefile.am
index a9d72ec..afc2239 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -51,6 +51,7 @@ IF_PYTHON_SOURCES = \
options.hh \
iterable.hh \
validated.hh \
+ about.cc \
action.cc \
contents.cc \
dep_label.cc \
diff --git a/python/about.cc b/python/about.cc
new file mode 100644
index 0000000..b0aac89
--- /dev/null
+++ b/python/about.cc
@@ -0,0 +1,38 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <python/paludis_python.hh>
+
+#include <paludis/about.hh>
+
+using namespace paludis;
+using namespace paludis::python;
+namespace bp = boost::python;
+
+void expose_about()
+{
+ bp::scope s;
+ s.attr("VERSION_MAJOR") = stringify(PALUDIS_VERSION_MAJOR);
+ s.attr("VERSION_MINOR") = stringify(PALUDIS_VERSION_MINOR);
+ s.attr("VERSION_MICRO") = stringify(PALUDIS_VERSION_MICRO);
+ s.attr("VERSION") = stringify(PALUDIS_VERSION_MAJOR) + "."
+ + stringify(PALUDIS_VERSION_MINOR) + "." + stringify(PALUDIS_VERSION_MICRO);
+ s.attr("VERSION_SUFFIX") = stringify(PALUDIS_VERSION_SUFFIX);
+ s.attr("SUBVERSION_REVISION") = stringify(PALUDIS_SUBVERSION_REVISION);
+}
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 3d3b289..05d83a6 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -157,6 +157,7 @@ namespace paludis
} // namespace paludis::python
} // namespace paludis
+void expose_about() PALUDIS_VISIBLE;
void expose_action() PALUDIS_VISIBLE;
void expose_contents() PALUDIS_VISIBLE;
void expose_dep_label() PALUDIS_VISIBLE;
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index 405ea49..016f7df 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -29,6 +29,7 @@ BOOST_PYTHON_MODULE(paludis)
boost::python::docstring_options doc_options(true, false);
#endif
+ expose_about();
expose_exception();
expose_version_spec();
expose_version_operator();