Skip to content

Commit

Permalink
Fix #36: make nb activate venv; update README (#42)
Browse files Browse the repository at this point in the history
Take opportunity to fix errors / omissions:
- remove copying allowed files and its reference in the README
- fix [t]csh and fish installation: add extension to `activate`, not dev/null
- reinstate advice on Notebook 7
- remove leading space in `...` due to wrong GH Pages formatting

---------

Co-authored-by: Michel Wermelinger <[email protected]>
  • Loading branch information
densnow and mwermelinger authored Aug 28, 2024
1 parent 75b384a commit a883283
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ a modern operating system: Linux, macOS 11 (Big Sur) or later, Windows 10 or 11.
You can have your M269 book and TMAs in a cloud folder, but you must
install Python 3.11 and the M269 software on each computer you use.

You must open and close PowerShells and terminals as instructed below
**Important**: You must open and close PowerShells and terminals as instructed below
for the software to be correctly installed and used.
Do _not_ use already opened PowerShells and terminals.

Expand Down Expand Up @@ -93,22 +93,22 @@ The `start.ps1` script and these instructions are originally by M269 tutor Bob M
2. Right click on the new desktop icon and select 'Properties' to update the shortcut:

1. Modify the start-up folder to be your M269 folder.
2. Append ` -file start.ps1` to the target field. It should now read:
2. Append `-file start.ps1` to the target field. It should now read:
`C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file start.ps1`.
3. Optionally you can update the icon for the shortcut. To get a Jupyter icon
instead of a PowerShell icon you can use
`%USERPROFILE%\venvs\m269-23j\Lib\site-packages\nbclassic\static\base\images\favicon.ico`.

You should now be able to double click on the desktop shortcut to start Jupyter
in your M269 folder. First, a PowerShell window opens where Jupyter writes its log messages,
then your browser should open the Jupyter dashboard.

then your browser should open the Jupyter dashboard, listing the contents of your M269 folder.
If there’s a message about migrating to Notebook 7, click "don’t show anymore".
You can now continue reading Section 1.3 of the book to learn how to use Jupyter.

**Note for tutors:** You can create multiple shortcuts, each opening Jupyter in
a different start folder, e.g. the eTMA marking folder. Follow the same steps
as above for each shortcut, but in step 2.2, append also the intended start folder:
` -file start.ps1 path/to/folder`. If the path includes spaces, you must enclose it in quotes.
`-file start.ps1 path/to/folder`. If the path includes spaces, you must enclose it in quotes.

### 3.2 Terminal (Windows and Unix)

Expand All @@ -128,13 +128,25 @@ just do the first 3 steps and return to the book to learn how to use Jupyter.
3. Enter `nb` to start working with notebooks.
After a little while, a web browser opens, with the Jupyter dashboard
listing the contents of your M269 folder.
If there’s a message about migrating to Notebook 7, click "don’t show anymore".
(You can now continue reading Section 1.3 of the book.)

**Note**: if you skipped step 2 by mistake,
then entering `nb` will still activate the M269 software but
Jupyter will start in your current folder rather than the M269 folder,
and you won't see the M269 materials in the Jupyter dashboard.
In that case, do step 4 to close the dashboard and then go back to step 2.

4. After finishing working on the notebooks, go back to the web browser tab with
the Jupyter dashboard, click on the 'Quit' button, then close the browser tab.

5. Close the PowerShell or terminal you opened in step 1.

**Note to tutors:** To mark TMA notebooks, follow the steps above,
but in step 2, instead of entering `m269-24j`,
change to the eTMA marking folder with the `cd` command, and then
proceed with step 3 to start working in that folder.

**Note for macOS users**:
If steps 2 and 3 (the `m269-24j` and `nb` commands) are not working,
and you are using `bash`, enter in the terminal
Expand Down Expand Up @@ -181,13 +193,10 @@ e.g. to work again on your M269 notebooks. Do as follows:

2. Go to your M269 folder by entering `cd <M269 folder path>`, e.g. `cd ~/OU/m269-24j`.

3. Run the installation script as follows, ignoring messages about the `cp` command or
about a file being copied onto itself:
3. Run the installation script with an extra space and period after the command, compared to step 5 in Section 2:
- **Windows**: `.\install.ps1 .`
- **Unix**: `./install.sh .`

**Note**: there's an extra space and period after the command, compared to step 5 in Section 2.
4. Close the PowerShell or terminal you opened in step 1.

## Licence
Expand Down
1 change: 1 addition & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function m269-24j {
& "$VENV\Scripts\Activate.ps1"
}
function nb {
& "$VENV\Scripts\Activate.ps1"
Start-process -NoNewWindow jupyter -ArgumentList "notebook"
}
function allowed {}
Expand Down
26 changes: 16 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ else
else
cp -a $CSS ~/.jupyter/custom
fi
cp -a $CHECK "$FOLDER"
fi

echo "Creating Python environment $VENV... (this will take a bit)"
Expand All @@ -133,9 +132,21 @@ echo "Software has been installed."

echo "Adding shortcut commands to $shell's startup file..."

if [ $shell = "csh" ] || [ $shell = "tcsh" ]
then
EXT=".csh"
else
if [ $shell = "fish" ]
then
EXT=".fish"
else
EXT=""
fi
fi
# if 23J's allowed alias exists, cancel it, otherwise don't show error message
M269="cd \"$FOLDER\";source $VENV/bin/activate;unalias allowed 2> /dev/null"
NB="jupyter notebook &"
ACTIVATE="source $VENV/bin/activate$EXT;unalias allowed 2> /dev/null"
M269="cd \"$FOLDER\";$ACTIVATE"
NB="$ACTIVATE;jupyter notebook &"

if [ $shell = "fish" ]
then
Expand All @@ -146,15 +157,10 @@ fi

if [ $shell = "csh" ] || [ $shell = "tcsh" ]
then
echo "alias $COURSE '$M269.csh'" >> $FILE
echo "alias $COURSE '$M269'" >> $FILE
echo "alias nb '$NB'" >> $FILE
else
if [ $shell = "fish" ]
then
echo "alias $COURSE='$M269.fish'" >> $FILE
else
echo "alias $COURSE='$M269'" >> $FILE
fi
echo "alias $COURSE='$M269'" >> $FILE
echo "alias nb='$NB'" >> $FILE
fi

Expand Down

0 comments on commit a883283

Please sign in to comment.