Skip to content

Commit 9a3fac9

Browse files
prepare readme and universal whee
1 parent e74fcd8 commit 9a3fac9

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

README.txt

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ With apipkg you can control the exported namespace of a
55
python package and greatly reduce the number of imports for your users.
66
It is a `small pure python module`_ that works on virtually all Python
77
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.
1010

1111
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+
1317

1418
Tutorial example
1519
-------------------
@@ -26,14 +30,14 @@ and exports two objects imported from different modules::
2630
}
2731
}
2832

29-
The package is initialized with a dictionary as namespace.
33+
The package is initialized with a dictionary as namespace.
3034

31-
You need to create a ``_mypkg`` package with a ``somemodule.py``
35+
You need to create a ``_mypkg`` package with a ``somemodule.py``
3236
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.
3539

36-
Namespace dictionaries contain ``name: value`` mappings
40+
Namespace dictionaries contain ``name: value`` mappings
3741
where the value may be another namespace dictionary or
3842
a string specifying an import location. On accessing
3943
an namespace attribute an import will be performed::
@@ -62,23 +66,23 @@ loaded when they are accessed. This means:
6266
Including apipkg in your package
6367
--------------------------------------
6468

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,
6771
for example ``_mypkg/apipkg.py`` in the above example. You
6872
then import the ``initpkg`` function from that new place and
69-
are good to go.
73+
are good to go.
7074

7175
.. _`small pure python module`:
7276
.. _`apipkg.py`: http://bitbucket.org/hpk42/apipkg/src/tip/apipkg.py
7377

74-
Feedback?
78+
Feedback?
7579
-----------------------
7680

77-
If you have questions you are welcome to
81+
If you have questions you are welcome to
7882

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.
8185
* create an issue on http://bitbucket.org/hpk42/apipkg/issues
8286

83-
have fun,
87+
have fun,
8488
holger krekel

apipkg.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import sys
1010
from types import ModuleType
1111

12-
__version__ = '1.3.dev'
13-
1412

1513
def _py_abspath(path):
1614
"""
@@ -36,6 +34,10 @@ def distribution_version(name):
3634
return dist.version
3735

3836

37+
# this will yield wrong data for vendore versions
38+
__version__ = distribution_version(__name__)
39+
40+
3941
def initpkg(pkgname, exportdefs, attr=dict()):
4042
""" initialize given package from the export definitions. """
4143
oldmod = sys.modules.get(pkgname)

0 commit comments

Comments
 (0)