Add a Python virtual environment setup#133
Add a Python virtual environment setup#133ChrisEPhifer wants to merge 2 commits intotesting-tutorialfrom
Conversation
This is an attempt to make the development of CN tutorials more straightforward, as far as setting up the Python build is concerned. scripts/setup_env.sh handles creating a Python virtual environment suitable for building the tutorial (that is, with the necessary dependencies). This script tries to be relatively smart about not doing extra work. The README has been updated to reflect these changes.
|
Some concerns: (1) Is there no way to do the python magic in the Makefile? I'm a bit nervous about how heavy this is getting, and whether it's going to work in all circumstances -- e.g., if I run (2) Is the reason we need all this because we have one line of Python that's not compatible with 3.9? |
We can include a rule to run this setup in the Makefile. That was an oversight on my part. And it's no problem to then add the incantations necessary to keep Putting that aside, I'm not sure what about this is 'heavy'; could you clarify what you mean by that? The script is (perhaps) overly defensive, but what it is doing does not require anything other than
No; it is considered a best practice in Python development to make use of the virtual environments made available in the standard library. Relying on your system Python installation, and especially messing around with the system-wide Python packages, can cause all sorts of problems (like those you were running into earlier). Virtual environments provide isolated, unique-to-your-needs Python environments that are easily reproducible. |
This rule simply runs scripts/setup_env.sh; more importantly, it is also a dependency of the tutorial build/serve commands -- and the virtual environment it creates is now used in those rules to run mkdocs in an isolated/sandboxed manner (as was the intent behind introducing a virtual environment in the first place).
This is an attempt to make the CN tutorial build a bit more portable, utilizing Python's virtual environments.
TL;DR:
scripts/setup_env.shthat will create a Pythonvenvwith the necessarymkdocspackages to build the tutorialREADMEto clarify necessary Python version & how to use the virtual environment