Skip to content
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

Feature/installer improvements #165

Merged
merged 7 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Installing on Linux

Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/feature/PSYNEU-140/package/linux_installer.sh).
Download the installer from <a href="https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/installers/linux" download>here</a> and double click to run the installation.

# Installing on MAC

Download the installer from <a href="https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/installers/macos.scpt" download>here</a> and double click to run the installation.

# Manual installation on Linux

Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/linux_installer.sh).
It's recommended to download it in your home directory.

On terminal, go to your home directory
Expand Down Expand Up @@ -39,9 +47,9 @@ psyneulinkviewer

The application should open up succesfully after this. An icon will be visible on the Desktop as well.

# Installing on MAC
# Manual installation on MAC

Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/feature/PSYNEU-140/package/mac_installer.sh).
Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/mac_installer.sh).
It's recommended to download it in your home directory.

On terminal, go to your home directory
Expand Down
Binary file removed package/.linux_installer.sh.swp
Binary file not shown.
50 changes: 38 additions & 12 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
# Installing on Linux

Download the installer from <a href="https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/installers/linux" download>here</a> and double click to run the installation.

# Installing on MAC

Download the installer from <a href="https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/installers/macos.scpt" download>here</a> and double click to run the installation.

# Manual installation on Linux

Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/feature/PSYNEU-140/package/linux_installer.sh).
It's recommended to download it in your home directory.
It's recommended to download it in your home directory.

On terminal, go to your home directory

```
cd ~
```

Change file permissions to allow user to run it

```
chmod + x linux_installer.sh
```

And run installer
And run installer

```
./linux_installer.sh
```

After installation is done:

If conda environment is already active, run
If conda environment is already active, run

```
psyneulinkviewer
```

If conda environment is not active, then run :

```
source ~/.profile
conda activate psyneulinkview
Expand All @@ -34,34 +47,39 @@ psyneulinkviewer

The application should open up succesfully after this. An icon will be visible on the Desktop as well.

# Installing on MAC
# Manual installation on MAC

Download bash script to install [here](https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/feature/PSYNEU-140/package/mac_installer.sh).
It's recommended to download it in your home directory.
It's recommended to download it in your home directory.

On terminal, go to your home directory

```
cd ~
```

Give user permissions to file

```
chmod +x mac_installer.sh
```

And run installer
And run installer

```
./mac_installer.sh
```

After installation is done:

If conda environment is already active, run
If conda environment is already active, run

```
open ~/psyneulinkviewer-darwin-x64/psyneulinkviewer.app/
```

If conda environment is not active, then run :

```
source ~/.bash_profile
conda activate psyneulinkview
Expand All @@ -75,25 +93,29 @@ The application should open up succesfully after this. A desktop icon should be
The scripts above run the following commands in order:

Firs installs the python module 'psyneulinkviewer' from PyPi

```
sudo pip install psyneulinkviewer
```

This commands installs required libraries and packages. Also creates a conda enviroment where the needed packages are installed.

After successfully installing the python package above, it reset the user's bash profile to apply the settings changes
After successfully installing the python package above, it reset the user's bash profile to apply the settings changes

- Linux

```
source ~/.profile
```

- Mac
- Mac

```
source ~/.bash_profile
```

Then, a desktop file is created on the Desktop which allows users to open the application this way


# Psyneulinkviewer Requirements

Psyneulinkviewer requires:
Expand All @@ -113,28 +135,32 @@ If all went well with installation, you should see the application running as in

To test models, download [these models](https://github.com/MetaCell/PsyNeuLinkView/tree/feature/PSYNEU-140/test_models) and import one at a time to test. Each time a Model is open, the previous one will disappear. I recommend you start with the models inside 'working_tests', as those are the ones we know for sure should we working.

To import go to File -> Open Models
To import go to File -> Open Models

# PsyNeuLinkView Package Building

To build pip package

```
cd package
python3 -m pip install build
python3 -m build --sdist
```

To test local build

```
pip install dist/psyneulinkviewer-VERSIOn.tar.gz
```

To upload to distribution server. You will need token shared privately to be able to upload.
To upload to distribution server. You will need token shared privately to be able to upload.

```
python3 -m twine upload dist/*
```

To upload to test Pypi server

```
python3 -m twine upload --repository testpypi dist/*
```
3 changes: 3 additions & 0 deletions package/installers/generate_linux_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

shc -vrf linux.sh -o linux
Binary file added package/installers/linux
Binary file not shown.
37 changes: 37 additions & 0 deletions package/installers/linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

RUN_FLAG=0

if [ $RUN_FLAG -eq 0 ]; then
command -v xterm >/dev/null 2>&1
if [ $? -eq 0 ]; then
xterm -fa 'Monospace' -fs 14 -hold -e "cd ~ && . .bashrc && curl -H \"Cache-Control: no-cache\" https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/linux_installer.sh -o linux_installer.sh && chmod +x linux_installer.sh && ./linux_installer.sh && rm -f linux_installer.sh && bash"
RUN_FLAG=1
fi
fi

if [ $RUN_FLAG -eq 0 ]; then
command -v konsole >/dev/null 2>&1
if [ $? -eq 0 ]; then
konsole --noclose -e "cd ~ && . .bashrc && curl -H \"Cache-Control: no-cache\" https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/linux_installer.sh -o linux_installer.sh && chmod +x linux_installer.sh && ./linux_installer.sh && rm -f linux_installer.sh && bash"
RUN_FLAG=1
fi
fi


if [ $RUN_FLAG -eq 0 ]; then
command -v gnome-terminal >/dev/null
if [ $? -eq 0 ]; then
gnome-terminal -- bash -c "cd ~ && . .bashrc && curl -H \"Cache-Control: no-cache\" https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/linux_installer.sh -o linux_installer.sh && chmod +x linux_installer.sh && ./linux_installer.sh && rm -f linux_installer.sh && bash"
RUN_FLAG=1
fi
fi

if [ $RUN_FLAG -eq 0 ]; then
command -v notify-send >/dev/null 2>&1
if [ $? -eq 0 ]; then
notify-send "PsyNeuLinkViewer installation ERROR: No terminal found" "Try the manual installation documented in the github README."
else
xmessage -center -buttons 'Close':0 -default Ok -nearmouse "Error during the PsyNeuLinkViewer installation: No terminal found\nPlease try to download the linux installer bash script and run this manually from your terminal as documented in the repository README."
fi
fi
3 changes: 3 additions & 0 deletions package/installers/macos.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
osascript -e 'tell app "Terminal"
do script "cd ~ && curl -H \"Cache-Control: no-cache\" https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/mac_installer.sh -o mac_installer.sh && chmod +x mac_installer.sh && ./mac_installer.sh && rm -f mac_installer.sh"
end tell' > /dev/null
25 changes: 14 additions & 11 deletions package/linux_installer.sh → package/scripts/linux_installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash

check_last_command () {
if [[ $? -ne 0 ]]; then
echo ">>> Please report the output below to [email protected] <<<"
echo "Error: $1"
python --version
pip --version
conda --version
exit 1
fi
}

pip install -vv psyneulinkviewer --break-system-packages --use-pep517 && . ~/.profile && sudo chown root:root /usr/local/bin/psyneulinkviewer-linux-x64/chrome-sandbox && sudo chmod 4755 /usr/local/bin/psyneulinkviewer-linux-x64/chrome-sandbox
check_last_command

# Variables
APP_NAME="PsyneulinkViewer" # Name of the application
Expand All @@ -8,18 +21,8 @@ CONDA_ENV=$PSYNEULINK_ENV # Conda environment t
ICON_PATH="/usr/local/bin/psyneulinkviewer-linux-x64/resources/app/build/logo.png" # Path to the custom icon
DESKTOP_FILE="$HOME/Desktop/$APP_NAME.desktop" # Path where the desktop shortcut will be created

# Function to check if a conda environment is already active
is_conda_active() {
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
echo "Conda environment '$CONDA_DEFAULT_ENV' is already active."
return 0
else
echo "No active conda environment found. Activating '$CONDA_ENV'..."
return 1
fi
}

# Creating the .desktop file for the application
rm -f "$DESKTOP_FILE"
echo "[Desktop Entry]" > "$DESKTOP_FILE"
echo "Version=1.0" >> "$DESKTOP_FILE"
echo "Name=$APP_NAME" >> "$DESKTOP_FILE"
Expand Down
27 changes: 15 additions & 12 deletions package/mac_installer.sh → package/scripts/mac_installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash
check_last_command () {
if [[ $? -ne 0 ]]; then
echo ">>> Please report the output below to [email protected] <<<"
echo "Error: $1"
python --version
pip --version
conda --version
exit 1
fi
}


pip install -vv psyneulinkviewer --break-system-packages --use-pep517 && source ~/.bashrc_profile
check_last_command

# Variables - adjust these for your setup
APP_PATH="$HOME/psyneulinkviewer-darwin-x64/psyneulinkviewer.app/" # Replace with the full path to the application
Expand All @@ -14,21 +27,12 @@ COMMAND_FILE_PATH="$APP_SHORTCUT_PATH/Contents/MacOS/$SHORTCUT_NAME"
ICON_FILE_PATH="$APP_SHORTCUT_PATH/Contents/Resources/$SHORTCUT_NAME.icns"

# Create .app structure
rm -rf "$APP_SHORTCUT_PATH"
mkdir -p "$APP_SHORTCUT_PATH/Contents/MacOS"
mkdir -p "$APP_SHORTCUT_PATH/Contents/Resources"

# Function to check if a conda environment is active
is_conda_active() {
# Check if the CONDA_DEFAULT_ENV variable is set, meaning a conda environment is active
if [ -z "$CONDA_DEFAULT_ENV" ]; then
return 1 # No active conda environment
else
return 0 # A conda environment is already active
fi
}

# Write the .command file that launches the app with conda environment
cat <<EOL > "$COMMAND_FILE_PATH"
#!/bin/bash
source ~/.bashrc_profile
source ~/miniconda3/etc/profile.d/conda.sh
Expand Down Expand Up @@ -71,4 +75,3 @@ chmod -R 755 "$APP_SHORTCUT_PATH"
touch "$APP_SHORTCUT_PATH"

echo "Shortcut created at $DESKTOP_PATH/$SHORTCUT_NAME.app"

Loading