-
Notifications
You must be signed in to change notification settings - Fork 50
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
Breaks if virtual environment is not activated #229
Comments
Welcome to this project and thank you!' first issue |
You're correct: Mkdocs and Mkdocs-Macros do work without virtual environment (that is the way I use them). That depends of course on the absence of incompatible requirements from othermodules. What you are experiencing appears to be an issue with your configuration. I see a number of alternative approaches:
Let me know how it goes. |
Ahh, I think I see what is breaking! We have a custom plugin: def define_env(env: Any) -> None:
@env.macro
def subprocess_run(*args: str) -> str:
return subprocess.run(args, check=True, capture_output=True, text=True).stdout' That is not picking up the venv's bin folder. |
Thanks for the update! Thanks for the update. My best suggestion for that, is that you create a more specialized macro. If you use the facilities of Shell, it might raise issues: one of these, is that shell it has own rules for local directories (plus it might open safety issues). If you write a macro that does exactly what you need, you will have the power of Python, and the rules for the local default directory are more logical (it should be the location of the MkDocs project directory). Good luck with your project. |
I went with: def define_env(env: Any) -> None:
@env.macro
def subprocess_run(*args: str) -> str:
env = os.environ.copy()
scripts = sysconfig.get_path("scripts")
env["PATH"] = f"{scripts}{os.pathsep}{env.get('PATH', '')}"
return subprocess.run(args, check=True, capture_output=True, text=True, env=env).stdout Thanks! |
That's also a possible approach! You might want to use |
You are thinking of |
Oh, I see... That's another kettle of fish. 🙂 |
I updated my docs build to the following:
And only found out after releasing that pages had been replaced with "rendering errors"! This ruined the permanent release tag docs (https://cibuildwheel.pypa.io/en/v2.18.0/options), and required annoying workarounds to get a
stable
that had the fix.This is the error, a file not found error:
The fix (besides adding
--strict
!!!) was to replace.venv/bin/python -m mkdocs
(or.venv/bin/mkdocs
) with. .venv/bin/activate && mkdocs
; for some reason mkdocs-macros breaks down if you don't activate the virtual environment before running it. Python modules are supposed to work without activating the virtual environment.See pypa/cibuildwheel#1821 & readthedocs/readthedocs.org#11322.
The text was updated successfully, but these errors were encountered: