tosher / StGitlab

Sublime text Gitlab manager
Other
12 stars 0 forks source link

feature_request(conflict): global Python packages #4

Closed Kristinita closed 4 years ago

Kristinita commented 4 years ago

1. Summary

If I use in my plugins:

# [NOTE] Currently, “PYTHONPACKAGES” — “C:\Python37”
site_packages = (os.environ['PYTHONPACKAGES'])
if site_packages not in sys.path:
    sys.path.append(site_packages)

StGitlab doesn't work for me.

It would be nice, if StGitlab works in this case.

2. Argumentation

See section 2 why I use global Python packages, not own Sublime Text environment for my plugins.

I installed 500+ third-party packages → I run Sublime Text → solely for StGitlab I get traceback in Sublime Text console.

3. Data

Part of my plugin AchtungBitLy.py, that shortify selected links, use pyshorteners.

import os
import sublime_plugin
import sys

# PYTHONPACKAGES path:
# https://stackoverflow.com/a/4907053/5951529
# Disable duplicate paths:
# https://stackoverflow.com/a/42656754/5951529
site_packages = (os.environ['PYTHONPACKAGES'])
if site_packages not in sys.path:
    sys.path.append(site_packages)

from pyshorteners import Shortener  # noqa

class TinyUrlCommand(sublime_plugin.TextCommand):

    def run(self, edit):
        # Get selected link
        print('Tiny URL called')
        select = self.view.sel()
        selection_region = select[0]
        selection_text = self.view.substr(selection_region)
        print(selection_text)

        shortener = Shortener('Tinyurl')
        formatted_url = (format(shortener.short(selection_text)))
        print("Short url is {}".format(shortener.short(selection_text)))

        # Replace selected link to Tiny.Url link
        self.view.replace(
            edit, selection_region, formatted_url)

4. Steps to reproduce

I reproduced the problem in a version of Sublime Text without plugins and user settings.

pip install transliterate dimensions terminaltables python-gitlab → I enabled AchtungBitLy.py → I restarted Sublime Text.

5. Expected behavior

If plugin AchtungBitLy.py disabled:

    StGitlab successfully works.

6. Actual behavior

Else enabled:

reloading plugin StGitlab.stgitlab
Traceback (most recent call last):
  File "D:\Sublime Text Build 3176 x64 For Debug\sublime_plugin.py", line 125, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\stgitlab.py", line 7, in <module>
    from .base import *
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\base\__init__.py", line 4, in <module>
    from .stg_gitlab_reset import StGitlabResetCommand
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\base\stg_gitlab_reset.py", line 6, in <module>
    from . import utils
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\base\utils.py", line 9, in <module>
    from .stg_gitlab import StGitlab
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\base\stg_gitlab.py", line 8, in <module>
    from ..libs import gitlab
  File "D:\Sublime Text Build 3176 x64 For Debug\Data\Packages\StGitlab\libs\gitlab\__init__.py", line 34, in <module>
    from gitlab.v3.objects import *  # noqa
ImportError: No module named 'gitlab.v3'

7. Environment

Thanks.

tosher commented 4 years ago

Newer version of python-gitlab (installed by you with pip) doesn't has a v3 api objects: https://github.com/python-gitlab/python-gitlab/tree/master/gitlab ..only v4

Plugin's version has: https://github.com/tosher/StGitlab/tree/master/libs/gitlab