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

Fix: Smart-plugin not supporting an off-drive path #1399

Open
3 tasks done
radinparhami opened this issue Mar 3, 2024 · 0 comments
Open
3 tasks done

Fix: Smart-plugin not supporting an off-drive path #1399

radinparhami opened this issue Mar 3, 2024 · 0 comments

Comments

@radinparhami
Copy link

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

I am developing a Telegram bot as a Python library that uses Pyrogram.
And I use Smart Plugin, when I want to set the root path, because the user file does not match the library path, I have to give the library path like this:

dict(root=os.path.dirname(plugins.__file__))

When I change the following code in the pyrogram client file, it works:

for path in sorted(Path(root.replace(".", "/")).rglob("*.py")):
    parts = path.parent.parts
    if "site-packages" in parts:
        module_path = '.'.join(parts[parts.index("site-packages") + 1:])
    else:
        module_path = '.'.join(parts + (path.stem,))[4:]
    module = import_module(module_path)

Steps to reproduce

  1. I want to set the plugin root path of a python library
  2. but i can't ! 😓

Code example

from pyrogram import Client
from os import path

from proself import plugins

Client(..., plugins=dict(root=path.dirname(plugins.__file__))

Logs

File "P:\Python\venv\Lib\site-packages\pyrogram\client.py", line 690, in load_plugins
    module = import_module(module_path)

ModuleNotFoundError: No module named 'Python'

# PluginRootPath = "[my_drive_name]:\Python\venv\Lib\site-packages\proself\plugins"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant