Skip to content

Commit 04c9d99

Browse files
authored
Merge pull request #126 from jnothman/version-lite
Make version available to Python without dependencies; and to Sphinx metadata
2 parents c5178bd + ccfc138 commit 04c9d99

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

numpydoc/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
__version__ = '0.8.0.dev0'
44

5-
from .numpydoc import setup
5+
6+
def setup(app, *args, **kwargs):
7+
from .numpydoc import setup
8+
return setup(app, *args, **kwargs)

numpydoc/numpydoc.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
raise RuntimeError("Sphinx 1.0.1 or newer is required")
3030

3131
from .docscrape_sphinx import get_doc_object, SphinxDocString
32+
from . import __version__
3233

3334
if sys.version_info[0] >= 3:
3435
sixu = lambda s: s
@@ -150,7 +151,8 @@ def setup(app, get_doc_object_=get_doc_object):
150151
app.add_domain(NumpyPythonDomain)
151152
app.add_domain(NumpyCDomain)
152153

153-
metadata = {'parallel_read_safe': True}
154+
metadata = {'version': __version__,
155+
'parallel_read_safe': True}
154156
return metadata
155157

156158
# ------------------------------------------------------------------------------

setup.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
import sys
44
import os
55

6+
import setuptools # may monkeypatch distutils in some versions. # noqa
67
from distutils.command.sdist import sdist
7-
import setuptools
88
from distutils.core import setup
99

10+
from numpydoc import __version__ as version
11+
1012
if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[0:2] < (3, 4):
1113
raise RuntimeError("Python version 2.7 or >= 3.4 required.")
1214

13-
with open('numpydoc/__init__.py') as fid:
14-
for line in fid:
15-
if line.startswith('__version__'):
16-
version = line.strip().split()[-1][1:-1]
17-
break
1815

1916
def read(fname):
2017
"""Utility function to get README.rst into long_description.

0 commit comments

Comments
 (0)