@@ -5,11 +5,15 @@ With apipkg you can control the exported namespace of a
5
5
python package and greatly reduce the number of imports for your users.
6
6
It is a `small pure python module`_ that works on virtually all Python
7
7
versions, including CPython2.3 to Python3.1, Jython and PyPy. It co-operates
8
- well with Python's ``help()`` system, custom importers (PEP302) and common
9
- command line completion tools.
8
+ well with Python's ``help()`` system, custom importers (PEP302) and common
9
+ command line completion tools.
10
10
11
11
Usage is very simple: you can require 'apipkg' as a dependency or you
12
- can copy paste the <100 Lines of code into your project.
12
+ can copy paste the <200 Lines of code into your project.
13
+
14
+ As extra it will automatically set package.__version__
15
+ to your distribution version.
16
+
13
17
14
18
Tutorial example
15
19
-------------------
@@ -26,14 +30,14 @@ and exports two objects imported from different modules::
26
30
}
27
31
}
28
32
29
- The package is initialized with a dictionary as namespace.
33
+ The package is initialized with a dictionary as namespace.
30
34
31
- You need to create a ``_mypkg`` package with a ``somemodule.py``
35
+ You need to create a ``_mypkg`` package with a ``somemodule.py``
32
36
and ``othermodule.py`` containing the respective classes.
33
- The ``_mypkg`` is not special - it's a completely
34
- regular python package.
37
+ The ``_mypkg`` is not special - it's a completely
38
+ regular python package.
35
39
36
- Namespace dictionaries contain ``name: value`` mappings
40
+ Namespace dictionaries contain ``name: value`` mappings
37
41
where the value may be another namespace dictionary or
38
42
a string specifying an import location. On accessing
39
43
an namespace attribute an import will be performed::
@@ -62,23 +66,23 @@ loaded when they are accessed. This means:
62
66
Including apipkg in your package
63
67
--------------------------------------
64
68
65
- If you don't want to add an ``apipkg`` dependency to your package you
66
- can copy the `apipkg.py`_ file somewhere to your own package,
69
+ If you don't want to add an ``apipkg`` dependency to your package you
70
+ can copy the `apipkg.py`_ file somewhere to your own package,
67
71
for example ``_mypkg/apipkg.py`` in the above example. You
68
72
then import the ``initpkg`` function from that new place and
69
- are good to go.
73
+ are good to go.
70
74
71
75
.. _`small pure python module`:
72
76
.. _`apipkg.py`: http://bitbucket.org/hpk42/apipkg/src/tip/apipkg.py
73
77
74
- Feedback?
78
+ Feedback?
75
79
-----------------------
76
80
77
- If you have questions you are welcome to
81
+ If you have questions you are welcome to
78
82
79
- * join the #pylib channel on irc.freenode.net
80
- * subscribe to the http://codespeak.net/mailman/listinfo/py-dev list.
83
+ * join the #pylib channel on irc.freenode.net
84
+ * subscribe to the http://codespeak.net/mailman/listinfo/py-dev list.
81
85
* create an issue on http://bitbucket.org/hpk42/apipkg/issues
82
86
83
- have fun,
87
+ have fun,
84
88
holger krekel
0 commit comments