Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git file finding will fail if there are no commits #587

Closed
RonnyPfannschmidt opened this issue Jul 2, 2021 · 1 comment
Closed

git file finding will fail if there are no commits #587

RonnyPfannschmidt opened this issue Jul 2, 2021 · 1 comment

Comments

@RonnyPfannschmidt
Copy link
Contributor

It appears that this issue is back, in a sense. I'm seeing the same error with version 6.0.1 in a git respository that does not have any commits yet. The installation appears to succeed, but the error isn't handled.

  1. Create empty directory (in the output below: /tmp/test) and git init
  2. Create minimal setup.py:
import setuptools
setuptools.setup(name = 'issue298test', setup_requires = ['setuptools_scm'], use_scm_version = True)
  1. SETUPTOOLS_SCM_DEBUG=1 python3 setup.py develop
WARNING: The wheel package is not available.
finalize hook {'name': 'issue298test', 'version': None, 'author': None, 'author_email': None, 'maintainer': None, 'maintainer_email': None, 'url': None, 'license': None, 'description': None, 'long_description': None, 'keywords': None, 'platforms': None, 'classifiers': None, 'download_url': None, 'provides': None, 'requires': None, 'obsoletes': None}
Traceback (most recent call last):
  File "/tmp/test/.eggs/setuptools_scm-6.0.1-py3.9.egg/setuptools_scm/integration.py", line 56, in infer_version
    config = Configuration.from_file(dist_name=dist_name)
  File "/tmp/test/.eggs/setuptools_scm-6.0.1-py3.9.egg/setuptools_scm/config.py", line 136, in from_file
    with open(name) as strm:
FileNotFoundError: [Errno 2] No such file or directory: 'pyproject.toml'
version keyword {'name': 'issue298test', 'version': None, 'author': None, 'author_email': None, 'maintainer': None, 'maintainer_email': None, 'url': None, 'license': None, 'description': None, 'long_description': None, 'keywords': None, 'platforms': None, 'classifiers': None, 'download_url': None, 'provides': None, 'requires': None, 'obsoletes': None}
l {'root': '.', 'relative_to': None}
root '/tmp/test'
relative_to None
dist name: issue298test
looking for ep setuptools_scm.parse_scm /tmp/test
found ep .git = setuptools_scm.git:parse
cmd 'git rev-parse --show-prefix'
out b'\n'
real root /tmp/test
cmd 'git describe --dirty --tags --long --match *[0-9]*'
err b'fatal: No names found, cannot describe anything.\n'
ret 128
cmd 'git log -n 1 HEAD --format=%cI'
err b"fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n"
ret 128
branch err  fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]' 128
cmd 'git symbolic-ref --short HEAD'
out b'master\n'
cmd 'git rev-parse --verify --quiet HEAD'
ret 1
cmd 'git status --porcelain --untracked-files=no'
tag 0.0
tag '0.0' parsed to {'version': '0.0', 'prefix': '', 'suffix': ''}
version pre parse 0.0
version <Version('0.0')>
version 0.0 -> 0.0
scm version <ScmVersion 0.0 d=0 n=None d=False b=master>
config {'version_scheme': 'guess-next-dev', 'local_scheme': 'node-and-date'}
ep found: guess-next-dev
version 0.1.dev0
ep found: node-and-date
local_version 
running develop
running egg_info
writing issue298test.egg-info/PKG-INFO
writing dependency_links to issue298test.egg-info/dependency_links.txt
writing top-level names to issue298test.egg-info/top_level.txt
find files toplevel /tmp/test
/tmp/test ['']
fatal: not a valid object name: HEAD
listing git files failed - pretending there aren't any
Traceback (most recent call last):
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 2321, in next
    tarinfo = self.tarinfo.fromtarfile(self)
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 1111, in fromtarfile
    obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 1047, in frombuf
    raise EmptyHeaderError("empty header")
tarfile.EmptyHeaderError: empty header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/test/.eggs/setuptools_scm-6.0.1-py3.9.egg/setuptools_scm/file_finder_git.py", line 65, in _git_ls_files_and_dirs
    return _git_interpret_archive(proc.stdout, toplevel)
  File "/tmp/test/.eggs/setuptools_scm-6.0.1-py3.9.egg/setuptools_scm/file_finder_git.py", line 46, in _git_interpret_archive
    with tarfile.open(fileobj=fd, mode="r|*") as tf:
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 1639, in open
    t = cls(name, filemode, stream, **kwargs)
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 1520, in __init__
    self.firstmember = self.next()
  File "/home/username/.pyenv/versions/3.9.0/lib/python3.9/tarfile.py", line 2336, in next
    raise ReadError("empty file")
tarfile.ReadError: empty file
reading manifest file 'issue298test.egg-info/SOURCES.txt'
writing manifest file 'issue298test.egg-info/SOURCES.txt'
running build_ext
Creating /home/username/.pyenv/versions/3.9.0/envs/issue298test/lib/python3.9/site-packages/issue298test.egg-link (link to .)
Adding issue298test 0.1.dev0 to easy-install.pth file

Installed /tmp/test
Processing dependencies for issue298test==0.1.dev0
Finished processing dependencies for issue298test==0.1.dev0

(Without debug mode, the output is the wheel warning, running develop and the following four lines, and then everything from fatal: not a valid object name: HEAD onwards.)

Versions of the possibly relevant software: Python 3.9.0, setuptools 57.0.0, pip 21.1.3, setuptools_scm 6.0.1, git 2.32.0

Originally posted by @JustAnotherArchivist in #298 (comment)

@RonnyPfannschmidt
Copy link
Contributor Author

New bug in the date handling

Will fix over the weekend

@RonnyPfannschmidt RonnyPfannschmidt changed the title It appears that this issue is back, in a sense. I'm seeing the same error with version 6.0.1 in a git respository that does not have any commits yet. The installation appears to succeed, but the error isn't handled. git date finding will fail if there are no commits yet Aug 25, 2021
@RonnyPfannschmidt RonnyPfannschmidt changed the title git date finding will fail if there are no commits yet git file finding will fail if there are no commits Aug 25, 2021
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 26, 2021
on a repository without a commit we cannot tell the valid files, so we don't

# Conflicts:
#	src/setuptools_scm/config.py
#	src/setuptools_scm/discover.py
#	src/setuptools_scm/git.py
#	src/setuptools_scm/utils.py
#	src/setuptools_scm/version.py
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 26, 2021
on a repository without a commit we cannot tell the valid files, so we don't
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 26, 2021
RonnyPfannschmidt added a commit that referenced this issue Aug 26, 2021
…o-commit

fix #587 - stop file finding on missing commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant