astropy / astropy-helpers

Helpers for Astropy and Affiliated packages
BSD 3-Clause "New" or "Revised" License
28 stars 42 forks source link

``setup.py`` fails if in a git repo with no commits (low priority) #114

Closed astrofrog closed 9 years ago

astrofrog commented 9 years ago

The following demonstrates the issue:

$ git clone git@github.com:astropy/package-template.git
Cloning into 'package-template'...
cd packaremote: Counting objects: 545, done.
remote: Total 545 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (545/545), 160.67 KiB | 0 bytes/s, done.
Resolving deltas: 100% (273/273), done.
Checking connectivity... done.
mac-robitaille2:tmp tom$ cd package-template
mac-robitaille2:package-template tom$ rm -rf .git
mac-robitaille2:package-template tom$ git init

mac-robitaille2:package-template tom$ python setup.py
git submodule command failed unexpectedly:
error: pathspec 'astropy_helpers' did not match any file(s) known to git.
Did you forget to 'git add'?

The requested path 'astropy_helpers' for importing astropy_helpers does not exist, or does not contain a copy of the astropy_helpers package.  Attempting download instead.
Downloading astropy_helpers; run setup.py with the --offline option to force offline installation.
Traceback (most recent call last):
  File "setup.py", line 18, in <module>
    from astropy_helpers.setup_helpers import (
  File "/Users/tom/tmp/package-template/astropy_helpers-0.4.3-py3.4.egg/astropy_helpers/__init__.py", line 2, in <module>
    from .version import version as __version__
  File "/Users/tom/tmp/package-template/astropy_helpers-0.4.3-py3.4.egg/astropy_helpers/version.py", line 151, in <module>
    version = update_git_devstr(_last_generated_version)
  File "/Users/tom/tmp/package-template/astropy_helpers-0.4.3-py3.4.egg/astropy_helpers/version.py", line 34, in update_git_devstr
    devstr = get_git_devstr(sha=True, show_warning=False, path=path)
  File "/Users/tom/tmp/package-template/astropy_helpers-0.4.3-py3.4.egg/astropy_helpers/version.py", line 144, in get_git_devstr
    return _decode_stdio(stdout)[:40]
  File "/Users/tom/tmp/package-template/astropy_helpers-0.4.3-py3.4.egg/astropy_helpers/version.py", line 17, in _decode_stdio
    text = stream.decode(stdio_encoding)
AttributeError: 'str' object has no attribute 'decode'

While this may seem like a quite obscure case, it can happen when people are setting up affiliated packages from scratch (I ran into it).

embray commented 9 years ago

Ah, this line should be changed to return (None, b'', b''), and a regression test added.

embray commented 9 years ago

Should be fixed by #137.