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 improv 2 #169

Merged
merged 4 commits into from
Nov 26, 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
31 changes: 31 additions & 0 deletions .github/workflows/installers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Installers
on:
release:
types:
- created
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Install dependencies
working-directory: ./package/installers
run: pip install -r requirements.txt pyinstaller
- name: Build
working-directory: ./package/installers
run: pyinstaller your-code.py
- name: Rename the installer with the OS name
working-directory: ./package/installers
run: mv dist/installer/installer dist/installer/installer-${{ matrix.os }}
- uses: actions/upload-artifact@v2
with:
path: dist/*
3 changes: 0 additions & 3 deletions package/installers/generate_linux_binary.sh

This file was deleted.

46 changes: 46 additions & 0 deletions package/installers/installer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from os import path
import sys
import subprocess

def does_it_exists(command):
rc = subprocess.call(['which', command])
if rc == 0:
return True
else:
return False


# create a function, download_installer, that takes in input the url and
# save the bash script in the home directory of the user
def download_installer(url):
# download the installer
import requests
response = requests.get(url)
# save the installer in the home directory
installer_path = path.join(path.expanduser('~'), 'installer.sh')
with open(installer_path, 'wb') as f:
f.write(response.content)
return installer_path


# check if the platofrm is windows, linux or macos
if sys.platform == 'linux':
# install the linux specific package
linux_url = 'https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/linux_installer.sh'
linux_installer = download_installer(linux_url)
command1 = ["xterm", "-fa", "'Monospace'", "-fs", "14", "-hold", "-e", "/bin/bash", "-ilc", "cd $HOME && chmod +x " + linux_installer + " && bash " + linux_installer + "; rm -f " + linux_installer]
command2 = ["konsole", "--noclose", "-e", "$SHELL", "-ilc", "cd $HOME && chmod +x " + linux_installer + " && bash " + linux_installer + "; rm -f " + linux_installer]
command3 = ["gnome-terminal", "--", "$SHELL", "-ilc", "cd $HOME && chmod +x " + linux_installer + " && bash " + linux_installer + "; rm -f " + linux_installer]
# check if the user has the item 0 of each command array installed, once you find one installed run the command
for command in [command1, command2, command3]:
if does_it_exists(command[0]):
subprocess.call(command)
break
elif sys.platform == 'darwin':
# install the macos specific package
mac_url = 'https://raw.githubusercontent.com/MetaCell/PsyNeuLinkView/develop/package/scripts/mac_installer.sh'
mac_installer = download_installer(mac_url)
command1 = ["osascript", "-e", "tell application \"Terminal\" to do script \"cd $HOME && chmod +x " + mac_installer + " && bash " + mac_installer + "; rm -f " + mac_installer + "\" end tell"]
subprocess.call(command1)
else:
raise Exception('Unsupported platform')
Binary file removed package/installers/linux
Binary file not shown.
37 changes: 0 additions & 37 deletions package/installers/linux.sh

This file was deleted.

Empty file.
4 changes: 4 additions & 0 deletions package/scripts/linux_installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

echo 'I AM SOURCING BASHRC'
source ~/.profile
echo $PATH

check_last_command () {
if [[ $? -ne 0 ]]; then
echo ">>> Please report the output below to [email protected] <<<"
Expand Down