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

hg failing if external repo is broken #352

Closed
Massimo-B opened this issue Aug 1, 2019 · 4 comments
Closed

hg failing if external repo is broken #352

Massimo-B opened this issue Aug 1, 2019 · 4 comments

Comments

@Massimo-B
Copy link

I have /.hg in my root fs of Gentoo Linux, tracking almost /etc and other files. And if something is broken with that external repo, all Python installations by the package manager inside of it's building sandbox in /var/tmp/portage are failing like this:

writing dependency_links to python_mimeparse.egg-info/dependency_links.txt
abort: No such file or directory: '/boot/config'
Traceback (most recent call last):
  File "setup.py", line 50, in <module>
    long_description=read('README.rst')
  File "/usr/lib64/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/install.py", line 61, in run
    return orig.install.run(self)
  File "/usr/lib64/python2.7/distutils/command/install.py", line 575, in run
    self.run_command(cmd_name)
  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/install_egg_info.py", line 34, in run
    self.run_command('egg_info')
  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/egg_info.py", line 296, in run
    self.find_sources()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
    mm.run()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/egg_info.py", line 534, in run
    self.add_defaults()
  File "/usr/lib64/python2.7/site-packages/setuptools/command/egg_info.py", line 574, in add_defaults
    rcfiles = list(walk_revctrl())
  File "/usr/lib64/python2.7/site-packages/setuptools/command/sdist.py", line 20, in walk_revctrl
    for item in ep.load()(dirname):
  File "/usr/lib64/python2.7/site-packages/setuptools_scm/integration.py", line 27, in find_files
    res = command(path)
  File "/usr/lib64/python2.7/site-packages/setuptools_scm/file_finder_hg.py", line 46, in hg_find_files
    hg_files, hg_dirs = _hg_ls_files_and_dirs(toplevel)
  File "/usr/lib64/python2.7/site-packages/setuptools_scm/file_finder_hg.py", line 29, in _hg_ls_files_and_dirs
    ["hg", "files"], cwd=toplevel, universal_newlines=True
  File "/usr/lib64/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['hg', 'files']' returned non-zero exit status 255

setuptools should be completely independent from outside Mercurial repos or maybe have an option to ignore that like this:

--- a/src/setuptools_scm/file_finder_hg.py      2019-08-01 08:24:15.060553831 +0200
+++ b/src/setuptools_scm/file_finder_hg.py      2019-08-01 08:26:11.334617120 +0200
@@ -41,7 +41,11 @@
 
 def hg_find_files(path=""):
     toplevel = _hg_toplevel(path)
     if not toplevel:
         return []
+    # SETUPTOOLS_SCM_IGNORE_VCS_ROOTS is a ':'-separated list of VCS roots to ignore.
+    # Example: SETUPTOOLS_SCM_IGNORE_VCS_ROOTS=/var:/etc:/home/me
+    if toplevel in os.environ.get('SETUPTOOLS_SCM_IGNORE_VCS_ROOTS', '').split(':'):
+        return []
     hg_files, hg_dirs = _hg_ls_files_and_dirs(toplevel)
     return scm_find_files(path, hg_files, hg_dirs)
@RonnyPfannschmidt
Copy link
Contributor

thanks for the input

the posted patch looks good, if you make it a pr with a note in the readme and a small test we can do a release of that quickly

an optional followup would be to move it to a utility function so we can use it for git as well

@Massimo-B
Copy link
Author

I'm no python developer. As far as I tested that on Gentoo with
echo 'SETUPTOOLS_SCM_IGNORE_VCS_ROOTS="/"' >> /etc/portage/make.conf
it is working.
Please consider a release.

@RonnyPfannschmidt
Copy link
Contributor

Will take a while, I'm currently on vacation

RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Nov 29, 2020
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Nov 29, 2020
RonnyPfannschmidt added a commit that referenced this issue Nov 29, 2020
@Massimo-B
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment