79686546

Date: 2025-07-01 20:02:52
Score: 0.5
Natty:
Report link

I removed all git dependencies from my toml/setup.py since pypi is very strict about that and added a try except to my entry point before the import in question. So I have an intentionally failed import when you run the code the first time. This triggers the subprocess to install the package then reruns the code. So the user can still pip install your package and then your package installs the git dependency when they run it.

This is dependent on the user having git on their system. Not a perfect solution but a decent workaround.

import subprocess
import sys
import os

try:
    from svcca import something
except ImportError:
    print("svcca not found. Installing from GitHub...")
    subprocess.check_call([
        sys.executable,
        "-m", "pip", "install",
        "svcca @ git://github.com/themightyoarfish/svcca-gpu.git"
    ])
    print("Installation complete. Relaunching please wait..")
    os.execv(sys.executable, [sys.executable] + sys.argv)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user30942190