dsa-ou / m269-installer

Software installation script and instructions for M269
https://dsa-ou.github.io/m269-installer/
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

[Idea] Check if m269-23j venv is active before allowing `nb` to do anything #36

Closed densnow closed 1 month ago

densnow commented 11 months ago

Often students can and will use nb before using m269-23j even though the correct order is documented. If they have no alternative jupyter environment installed, then a "command not found" type error is raised. If they do have an alternative Jupyter environment, then it most likely will not have the correct dependencies for error free operation with the M269 book.

When a Python venv is activated, a VIRTUAL_ENV environment variable is set with the location of the environment e.g ~/venvs/m269-23j. This allows a relatively straightforward way to check if a specific environment is currently activated and could be incorporated into the nb aliases on each of the scripts. If the environment is activated, carry on as normal. If not, then print specific error message and instruction to activate the environment.

mwermelinger commented 11 months ago

Good idea. Does it also work on Windows? If so, we could make the nb alias / cmdlet call the m269-23j if the environment isn't activated, instead of giving an error.

densnow commented 11 months ago

Yes it does work on windows you just need to get the var with env: VIRTUAL_ENV syntax.

Having said all that, I think we could just activate the env without any checks in nb regardless of current state. I.e if the env is not active, then it would be activated. If it was already activated then it can't be activated twice and no harm would come AFAIK from running the activation script when already activated. Of course needs to be tested properly as there might be something not thought of 🙂.

mwermelinger commented 11 months ago

Great, that's even simpler :-)

mwermelinger commented 1 month ago

@densnow We should have addressed this earlier. If you have the time this week to do a branch and PR to address this and test on Win10 + Linux, great, I can then test on Mac and merge.

mwermelinger commented 1 month ago

@densnow I added Bob's script, which changes folder between activating and calling nb (see new README section 3.1). For this to continue working, nb can activate but must not change the folder.