CodeReview icon indicating copy to clipboard operation
CodeReview copied to clipboard

File code-review.svg not found in directories ('/usr/local/lib/python3.6/site-packages/share/icons/svg',)

Open coquizen opened this issue 7 years ago • 4 comments

OS: Mac OS High Sierra 10.13.3 (17D102) Python: Python 3.6.5 pip3 freeze:

  • cffi==1.11.5
  • configparser==3.5.0
  • greenlet==0.4.13
  • msgpack==0.5.6
  • neovim==0.2.4
  • pycparser==2.18
  • pygit2==0.27.0
  • Pygments==2.2.0
  • PyQt5==5.10.1
  • PyYAML==3.12
  • sip==4.19.8
  • six==1.11.0
  • virtualenv==15.2.0

Steps to Reproduce:

brew install libgit2 --HEAD
pip3 install CodeReview
pyqgit

Expected Result: To open without error Result:

2018-03-31 10:32:02,262 - pyqgit - Logging.setup_logging - INFO - Start pyqgit
2018-03-31 10:32:02,340 - CodeReview.GUI.LogBrowser.LogBrowserApplication - ApplicationBase.__init__ - DEBUG - Namespace(path='/Users/caninodev', user_script=None, user_script_args='') {}
2018-03-31 10:32:02,360 - CodeReview.GUI.LogBrowser.LogBrowserApplication - GuiApplicationBase.__init__ - DEBUG - QtWidgets.QApplication ['/usr/local/bin/pyqgit']
2018-03-31 10:32:02,541 - CodeReview.GUI.LogBrowser.LogBrowserApplication - GuiApplicationBase.__init__ - DEBUG - GuiApplicationBase Namespace(path='/Users/caninodev', user_script=None, user_script_args='') {}
2018-03-31 10:32:02,588 - CodeReview.GUI.LogBrowser.LogBrowserApplication - LogBrowserApplication.__init__ - DEBUG - Namespace(path='/Users/caninodev', user_script=None, user_script_args='')
Traceback (most recent call last):
  File "/usr/local/bin/pyqgit", line 67, in <module>
    application = LogBrowserApplication(args)
  File "/usr/local/lib/python3.6/site-packages/CodeReview/GUI/LogBrowser/LogBrowserApplication.py", line 51, in __init__
    self._main_window = LogBrowserMainWindow()
  File "/usr/local/lib/python3.6/site-packages/CodeReview/GUI/LogBrowser/LogBrowserMainWindow.py", line 52, in __init__
    self.setWindowIcon(icon_loader['code-review@svg'])
  File "/usr/local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 67, in __getitem__
    return self.get_icon(icon_name, icon_size)
  File "/usr/local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 75, in get_icon
    icon_path = self._find(icon_name, icon_size)
  File "/usr/local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 89, in _find
    return ConfigInstall.Icon.find(file_name + extension, icon_size)
  File "/usr/local/lib/python3.6/site-packages/CodeReview/Config/ConfigInstall.py", line 61, in find
    return PathTools.find(file_name, (icon_directory,))
  File "/usr/local/lib/python3.6/site-packages/CodeReview/Tools/Path.py", line 51, in find
    raise NameError("File %s not found in directories %s" % (file_name, str(directories)))
NameError: File code-review.svg not found in directories ('/usr/local/lib/python3.6/site-packages/share/icons/svg',)
screen shot 2018-03-31 at 10 35 24 am

coquizen avatar Mar 31 '18 14:03 coquizen

The magic is done in CodeReview/Config/ConfigInstall.py

class Path:

    CodeReview_module_directory = PathTools.parent_directory_of(_this_file, step=2)
    config_directory = os.path.dirname(_this_file)

    ##############################################

    @staticmethod
    def share_directory():

        path = os.path.dirname(Path.CodeReview_module_directory)
        if path.startswith(sys.exec_prefix):
            return os.path.join(sys.exec_prefix, 'share', 'CodeReview')
        else:
            return os.path.join(path, 'share')

Could you try to debug so as to understand why you get the else clause on your environment ?

I tested it on a virtual env, maybe your python exec path is not /usr/local.

FabriceSalvaire avatar Apr 02 '18 11:04 FabriceSalvaire

Hi,

I encounter the same error, when installing on Arch Linux using "pip --user", like this:

pip install --user CodeReview

Traceback (most recent call last):
File "/home/feng/.local/bin/pyqgit", line 67, in (module)
application = LogBrowserApplication(args)
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/GUI/LogBrowser/LogBrowserApplication.py", line 51, in __init__
self._main_window = LogBrowserMainWindow()
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/GUI/LogBrowser/LogBrowserMainWindow.py", line 52, in __init__
self.setWindowIcon(icon_loader['code-review@svg'])
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 67, in __getitem__
return self.get_icon(icon_name, icon_size)
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 75, in get_icon
icon_path = self._find(icon_name, icon_size)
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/GUI/Widgets/IconLoader.py", line 89, in _find
return ConfigInstall.Icon.find(file_name + extension, icon_size)
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/Config/ConfigInstall.py", line 61, in find
return PathTools.find(file_name, (icon_directory,))
File "/home/feng/.local/lib/python3.6/site-packages/CodeReview/Tools/Path.py", line 51, in find
raise NameError("File %s not found in directories %s" % (file_name, str(directories)))
NameError: File code-review.svg not found in directories ('/home/feng/.local/lib/python3.6/site-packages/share/icons/svg',)

using "find" command, the "code-review.svg" seems to be present in this directory.

$ find ~/.local/ -name "code-review.svg"
/home/feng/.local/share/CodeReview/icons/svg/code-review.svg
$ ls /home/feng/.local/share/CodeReview/icons/svg/
align-mode.svg  code-review.svg  complete-mode.svg  go-next.svg  go-previous.svg  highlight.svg  line-number-mode.svg  view-refresh.svg

artisdom avatar Jun 09 '18 16:06 artisdom

someone as to look how to get install path used by pip

FabriceSalvaire avatar Jun 09 '18 17:06 FabriceSalvaire

I also observed the same error using pip3 install --user, which led me to this issue report.

I found that adding the following elif statement to check if the package is installed in the userbase path when it was not found to be running from within the system exec_path worked to find the icons in the ~/.local/share/CodeReview folder that should be generic enough to use on any platform that uses the userbase support after PEP 370. (Note: I also had to add 'import sysconfig' to be able to access it).

I started to fork, make changes, and issue a pull-request, but then I realized you removed the if/else you referred to above and was present in the pip installed version of the package in commit 33b23c0d28d56c8a29db97ef6745ee60c2743344. I tried making that change (just in case), but only looking in the relative path up from the file path still isn't the correct location to find the files.

    elif path.startswith(sysconfig.get_config_var('userbase')):
        return os.path.join(sysconfig.get_config_var('userbase'), 'share', 'CodeReview')

drmrboy avatar Feb 25 '22 17:02 drmrboy