[Python-modules-commits] [python-public] 01/03: Import python-public_0.5.orig.tar.gz
Barry Warsaw
barry at moszumanska.debian.org
Thu Dec 22 21:32:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
barry pushed a commit to branch master
in repository python-public.
commit 4aad6313916855124f499011066ce748ebf08088
Author: Barry Warsaw <barry at python.org>
Date: Thu Dec 22 16:26:59 2016 -0500
Import python-public_0.5.orig.tar.gz
---
MANIFEST.in | 3 +-
NEWS.rst | 4 ++
PKG-INFO | 2 +-
atpublic.egg-info/PKG-INFO | 2 +-
atpublic.egg-info/SOURCES.txt | 3 +-
public/__init__.py | 2 +-
setup.cfg | 2 +-
src/public.c | 153 ++++++++++++++++++++++++++++++++++++++++++
8 files changed, 165 insertions(+), 6 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index f3b2742..5b5e274 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,6 @@
include *.py MANIFEST.in
-global-include *.txt *.rst *.ini
+global-include *.txt *.rst *.ini *.c *.h
+recursive-include src
prune build
prune dist
prune .tox
diff --git a/NEWS.rst b/NEWS.rst
index f5f66c7..d8f7939 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,10 @@
@public NEWS
==============
+0.5 (2016-12-14)
+================
+* Fix MANIFEST.in inclusion of the src directory for the C extension.
+
0.4 (2016-11-28)
================
* Add Python 3.6 support.
diff --git a/PKG-INFO b/PKG-INFO
index 44e6efc..e73c985 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: atpublic
-Version: 0.4
+Version: 0.5
Summary: public -- @public for populating __all__
Home-page: http://public.readthedocs.io/
Author: Barry Warsaw
diff --git a/atpublic.egg-info/PKG-INFO b/atpublic.egg-info/PKG-INFO
index 44e6efc..e73c985 100644
--- a/atpublic.egg-info/PKG-INFO
+++ b/atpublic.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: atpublic
-Version: 0.4
+Version: 0.5
Summary: public -- @public for populating __all__
Home-page: http://public.readthedocs.io/
Author: Barry Warsaw
diff --git a/atpublic.egg-info/SOURCES.txt b/atpublic.egg-info/SOURCES.txt
index e3ffc12..f28c06d 100644
--- a/atpublic.egg-info/SOURCES.txt
+++ b/atpublic.egg-info/SOURCES.txt
@@ -14,4 +14,5 @@ atpublic.egg-info/top_level.txt
public/__init__.py
public/public.py
public/tests/__init__.py
-public/tests/test_public.py
\ No newline at end of file
+public/tests/test_public.py
+src/public.c
\ No newline at end of file
diff --git a/public/__init__.py b/public/__init__.py
index e9c3128..c80210a 100644
--- a/public/__init__.py
+++ b/public/__init__.py
@@ -13,7 +13,7 @@ except ImportError: # pragma: nocover
c_public = None
-__version__ = '0.4'
+__version__ = '0.5'
if c_public is None: # pragma: nocover
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..6bc2ff3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[egg_info]
-tag_build =
tag_date = 0
+tag_build =
tag_svn_revision = 0
diff --git a/src/public.c b/src/public.c
new file mode 100644
index 0000000..ec2f4e3
--- /dev/null
+++ b/src/public.c
@@ -0,0 +1,153 @@
+/*
+Copyright (C) 2016 Barry Warsaw
+
+This project is licensed under the terms of the Apache 2.0 License. See
+LICENSE.txt for details.
+*/
+
+#include <Python.h>
+
+
+static PyObject *
+public(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ PyObject *arg = NULL;
+ PyObject *globals = NULL;
+ PyObject *all = NULL;
+ PyObject *rtn = NULL;
+
+ if (!PyArg_UnpackTuple(args, "public", 0, 1, &arg))
+ return NULL;
+
+ /* kwds can be empty, but the keys must be strings. */
+ if (kwds != NULL && !PyArg_ValidateKeywordArguments(kwds))
+ return NULL;
+
+ if (!(globals = PyEval_GetGlobals())) {
+ PyErr_Format(PyExc_TypeError,
+ "@public called with no active globals");
+ return NULL;
+ }
+ if (!(all = PyDict_GetItemString(globals, "__all__"))) {
+ if (!(all = PyList_New(0)))
+ return NULL;
+ if (PyDict_SetItemString(globals, "__all__", all) < 0)
+ goto byebye;
+ }
+ else {
+ /* Make sure __all__ is a list, raising an exception if not. Bump
+ all's reference count since it's currently borrowed, and this way
+ we guarantee we own a reference for common exit cleanup.
+ */
+ if (!PyList_Check(all)) {
+ PyErr_Format(PyExc_ValueError,
+ "__all__ must be a list not: %S",
+ all->ob_type);
+ goto byebye;
+ }
+ Py_INCREF(all);
+ }
+
+ if (arg != NULL) {
+ PyObject *name = NULL;
+
+ /* There is a single positional argument. This must have a "__name__"
+ attribute, which we will put in __all__. The keywords dictionary
+ must be empty.
+ */
+ if (kwds != NULL && PyDict_Size(kwds) != 0) {
+ PyErr_Format(PyExc_TypeError,
+ "Positional and keywords are mutually exclusive");
+ goto byebye;
+ }
+ if (!PyObject_HasAttrString(arg, "__name__")) {
+ PyErr_Format(PyExc_TypeError,
+ "Positional argument has no __name__");
+ goto byebye;
+ }
+ if (!(name = PyObject_GetAttrString(arg, "__name__")) ||
+ !PyUnicode_Check(name))
+ {
+ PyErr_Format(PyExc_TypeError, "Bad __name__ value");
+ Py_XDECREF(name);
+ goto byebye;
+ }
+ if (PyList_Append(all, name) < 0) {
+ Py_DECREF(name);
+ goto byebye;
+ }
+ Py_DECREF(name);
+ rtn = arg;
+ }
+ else if (kwds == NULL || PyDict_Size(kwds) == 0) {
+ PyErr_Format(
+ PyExc_TypeError,
+ "Either a single positional or keyword arguments required");
+ goto byebye;
+ }
+ else {
+ /* There are only keyword arguments, so for each of these, insert the
+ key in __all__ *and* bind the name/key to the value in globals. We
+ force the use of globals here because we're modifying the global
+ __all__ so it doesn't make sense to touch locals.
+ */
+ PyObject *key, *value;
+ Py_ssize_t pos = 0;
+
+ while (PyDict_Next(kwds, &pos, &key, &value)) {
+ if (PyList_Append(all, key) < 0)
+ goto byebye;
+ if (PyDict_SetItem(globals, key, value) < 0)
+ goto byebye;
+ }
+ rtn = Py_None;
+ }
+
+ byebye:
+ Py_DECREF(all);
+ Py_XINCREF(rtn);
+ return rtn;
+}
+
+PyDoc_STRVAR(public_doc,
+"public(named)\n\
+public(**kws)\n\
+\n\
+May be used as a decorator or called directly. When used as a decorator\n\
+the thing being decorated must have an __name__ attribute. The value of\n\
+__name__ will be inserted in the global __all__ list. In this use case\n\
+it is an error to also include keyword arguments.\n\
+\n\
+When called directly, it is an error to pass a positional argument. The\n\
+keys must be strings, and are inserted into the global __all__ list. The\n\
+mapping of keys to values is also inserted into the globals, thus creating\n\
+name bindings for each key/value pair.");
+
+
+static PyMethodDef public_methods[] = {
+ {"public", (PyCFunction)public, METH_VARARGS | METH_KEYWORDS, public_doc},
+ {NULL, NULL}
+};
+
+
+static struct PyModuleDef public_def = {
+ PyModuleDef_HEAD_INIT,
+ "public",
+ NULL,
+ 0, /* size of module state */
+ public_methods,
+ NULL
+};
+
+
+PyObject *
+PyInit__public(void)
+{
+ return PyModule_Create(&public_def);
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "python3"
+ * End:
+ */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-public.git
More information about the Python-modules-commits
mailing list