From: Sean Whitton <spwhitton@spwhitton.name>
Date: Sat, 18 Aug 2018 09:37:58 -0700
Subject: docs build use DEB_VERSION_UPSTREAM

---
 docs/conf.py            | 4 +---
 src/pikepdf/_version.py | 4 +++-
 2 files changed, 4 insertions(+), 4 deletions(-)

--- a/docs/conf.py
+++ b/docs/conf.py
@@ -92,8 +92,6 @@ autodoc_typehints = 'description'
 sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext'))
 sys.path.insert(0, os.path.join(os.path.abspath('.'), '..'))
 
-import pikepdf  # isort:skip pylint: disable=unused-import
-
 # -- General configuration ------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -138,7 +136,7 @@ author = 'James R. Barlow'
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 
-release = pikepdf.__version__
+release = os.environ['DEB_VERSION_UPSTREAM']
 version = '.'.join(release.split('.')[:2])
 
 # The language for content autogenerated by Sphinx. Refer to documentation
--- a/src/pikepdf/_version.py
+++ b/src/pikepdf/_version.py
@@ -3,11 +3,16 @@
 
 from __future__ import annotations
 
+import os
+
 try:
     from importlib_metadata import version as _package_version  # type: ignore
 except ImportError:
     from importlib.metadata import version as _package_version
 
-__version__ = _package_version('pikepdf')
+if 'DEB_VERSION_UPSTREAM' in os.environ:
+    __version__ = os.environ['DEB_VERSION_UPSTREAM']
+else:
+    __version__ = _package_version('pikepdf')
 
 __all__ = ['__version__']
