Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 551272 - python-exec breaks mypy
Summary: python-exec breaks mypy
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Alex Brandt (RETIRED)
URL: https://github.com/JukkaL/mypy/issues...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-05 09:00 UTC by Hristo Venev
Modified: 2015-06-07 19:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hristo Venev 2015-06-05 09:00:06 UTC
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.4/mypy", line 169, in <module>
    main()
  File "/usr/lib/python-exec/python3.4/mypy", line 34, in main
    type_check_only(path, module, bin_dir, options)
  File "/usr/lib/python-exec/python3.4/mypy", line 78, in type_check_only
    python_path=options.python_path)
  File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 122, in build
    data_dir = default_data_dir(bin_dir)
  File "/usr/lib64/python3.4/site-packages/mypy/build.py", line 191, in default_data_dir
    raise RuntimeError("Broken installation: can't determine base dir")
RuntimeError: Broken installation: can't determine base dir

The reason is that bin_dir is os.path.dirname(__file__)
__file__=/usr/lib/python-exec/python3.4/mypy
then bindir=/usr/lib/python-exec/python3.4 instead of /usr/bin/mypy.

This can be fixed:

--- a/scripts/mypy
+++ b/scripts/mypy
@@ -41,19 +41,7 @@
 
 
 def find_bin_directory() -> str:
-    """Find the directory that contains this script.
-
-    This is used by build to find stubs and other data files.
-    """
-	return '/usr/bin'
-    script = __file__
-    # Follow up to 5 symbolic links (cap to avoid cycles).
-    for i in range(5):
-        if os.path.islink(script):
-            script = readlinkabs(script)
-        else:
-            break
-    return os.path.dirname(script)
+    return os.path.dirname(shutil.which('mypy'))
 
 
 def readlinkabs(link: str) -> str:


Reproducible: Always
Comment 1 Alex Brandt (RETIRED) gentoo-dev 2015-06-05 16:05:21 UTC
I've got an upstream issue open for this and I recommend you submit this patch there so it can be incorporated into mypy.

https://github.com/JukkaL/mypy/issues/653

I'll get this incorporated into the ebuild this weekend and if I don't see a pull request for this I'll add one but highly encourage you to provide the pull request since you've already taken the time to determine the patch.
Comment 2 Alex Brandt (RETIRED) gentoo-dev 2015-06-07 19:27:32 UTC
Added this patch to the tree and mentioned it upstream. If there is anything else, let me know.