Skip to content

Include static list of git tags in release tarballs available in PyPI #645

@Arfrever

Description

@Arfrever

After fixing of #640 and #644, generation of documentation in release tarballs would still fail due to missing .git directory:

$ make html
sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.1.3

Fatal error: local() encountered an error (return code 1) while executing 'git tag | sort -r | egrep "(1\.[^0]+)\.."'

====================================================================== Standard error ======================================================================

fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

=============================================================================================================================================================

Aborting.
make: *** [html] Error 1
$ git tag
fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I suggest to include static list of git tags in docs/git_tags file in generated tarballs:

--- docs/conf.py
+++ docs/conf.py
@@ -172,7 +172,10 @@

 from fabric.api import local, hide
 with hide('everything'):
-    get_tags = 'git tag | sort -r | egrep "(1\.[^0]+)\.."'
+    if os.path.exists('git_tags'):
+        get_tags = 'sort -r git_tags | egrep "(1\.[^0]+)\.."'
+    else:
+        get_tags = 'git tag | sort -r | egrep "(1\.[^0]+)\.."'
     fabric_tags = local(get_tags, True).split()
 html_context = {'fabric_tags': fabric_tags}

--- setup.py
+++ setup.py
@@ -1,8 +1,10 @@
 #!/usr/bin/env python

+import os
 import sys

 from setuptools import setup, find_packages
+from setuptools.command.sdist import sdist as _sdist

 from fabric.version import get_version

@@ -27,6 +29,12 @@
 For more information, please see the Fabric website or execute ``fab --help``.
 """ % (v, readme)

+class sdist(_sdist):
+    def run(self):
+        os.system('git tag > docs/git_tags')
+        _sdist.run(self)
+        os.unlink('docs/git_tags')
+
 setup(
     name='Fabric',
     version=get_version('short'),
@@ -64,4 +72,5 @@
           'Topic :: System :: Software Distribution',
           'Topic :: System :: Systems Administration',
     ],
+    cmdclass={'sdist': sdist},
 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions