Skip to content

Instantly share code, notes, and snippets.

@joaomcarlos
Created June 29, 2023 10:34
Show Gist options
  • Save joaomcarlos/8bbdf42ad0eb1dcfd0cf7291393dfeb6 to your computer and use it in GitHub Desktop.
Save joaomcarlos/8bbdf42ad0eb1dcfd0cf7291393dfeb6 to your computer and use it in GitHub Desktop.
import logging
import subprocess
from pathlib import Path
# Get the python venv
out = subprocess.run(
["pip show pip | grep Location"],
shell=True,
capture_output=True,
text=True,
).stdout
base = Path(out.split(" ")[1].strip())
file_to_fix = base / "wrapt/decorators.py"
text = file_to_fix.read_text()
if "formatargspec" in text:
logging.warning(
"Temporarily fixing import error in wrapt.decorators used by nameko ..."
)
logging.warning(f"Fixing {file_to_fix} ...\n")
# Replace the old function name with the new one
fixed_text = text.replace("formatargspec", "getfullargspec")
file_to_fix.write_text(fixed_text)
logging.warning(f"Fixed {file_to_fix}!\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment