ngrok / ngrok-api-python

ngrok API client library for Python
MIT License
25 stars 13 forks source link

Cannot install ngrok-api and ngrok packages at the same time #30

Open acodeninja opened 8 months ago

acodeninja commented 8 months ago

Replication:

Results in:

Traceback (most recent call last):
  File "test/test.py", line 3, in <module>
    ngrok.forward("http://localhost:8080")
    ^^^^^^^^^^^^^^
AttributeError: module 'ngrok' has no attribute 'forward'

Cause

The package ngrok and ngrok-api both contain the same published package folder ngrok. ngrok-api seems to take precedence:

ls python3.11/site-packages/ngrok
__init__.py     __main__.py     __pycache__     client.py       datatypes.py    error.py        http_client.py  iterator.py     mypy.ini        ngrok.abi3.so   ngrok.pyi       ngrok_parser.py py.typed        services.py     utils.py

Suggested fix

Update this package to expose the package directory ngrok_api which might be a better choice.

salilsub commented 7 months ago

@acodeninja can you provide more context on why you are using both packages? Specifically interested in what you are using the ngrok-api package for.

acodeninja commented 7 months ago

Hi, thanks for taking a look @salilsub. The specific use case was for a Python app, live-questions.

The app hosts a flask application over an ngrok tunnel and presents a TUI app with a QR Code pointing to the ngrok domain.

I wanted to use this library to retrieve a list of ngrok domains for users to choose from. As a workaround I've used various subprocess.call instances to get the information needed from the ngrok CLI.

These calls are usually very fragile when working cross-os so I'd like to use both libraries. I also feel both the ngrok and ngrok-api packages should be capable of being installed at the same time.

WesTyler commented 2 months ago

I just ran into the same. I'm trying to create a reserved address (api lib) and then use that address to connect a TCP tunnel (sdk lib).

thrau commented 1 month ago

I'm running into the same limitation, which is blocking me from using ngrok-api. I'm using the ngrok agent sdk to create and manage tunnels for the user programmatically, and I want to use the ngrok api in the same app to do things like list the available custom domains.

A solution could be to use namespace packages