Skip to content

Commit 3a1f72f

Browse files
fix issue #84 - document sphinx using pkg_resources
1 parent 5c9d94e commit 3a1f72f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ v1.15.0
77
* fix issue #114: stop trying to be smart for the sdist
88
and ensure its always correctly usign itself
99
* update trove classifiers
10+
* fix issue #84: document using the installed package metadata for sphinx
1011

1112
v1.14.1
1213
=======

README.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,32 @@ To use setuptools_scm just modify your project's setup.py file like this:
3535
Programmatic usage
3636
------------------
3737

38-
In order to use setuptools_scm for sphinx config, assuming the sphinx conf
39-
is one directory deeper than the project's root, use:
38+
In order to use setuptools_scm from code
39+
that one directory deeper than the project's root, you can use:
4040

4141
.. code:: python
4242
4343
from setuptools_scm import get_version
4444
version = get_version(root='..', relative_to=__file__)
4545
4646
47+
Usage from sphinx
48+
-----------------
49+
50+
It is discouraged to use setuptools_scm from sphinx itself,
51+
instead use ``pkg_resources`` after editable/real installation:
52+
53+
.. code:: python
54+
55+
from pkg_resources import get_distribution
56+
release = pkg_resources('myproject').version
57+
# for the example take major/minor
58+
version = '.'.join(release.split('.')[:2])
59+
60+
The underlying reason is, that services like readthedocs sometimes change
61+
the workingdirectory for good reasons and using the installed metadata prevents
62+
using needless volatile data there.
63+
4764
Notable Plugins
4865
----------------
4966

0 commit comments

Comments
 (0)