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

Add script to build installer and uninstaller #1

Merged
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/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, macos, windows]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build
run: |
python build.py ${{ matrix.os }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Raccoon2_BOINC_Installer_${{ matrix.os }}
path: |
raccoon2_boinc_installer.py
README.md
34 changes: 2 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
*.pyc
raccoon2_boinc_installer.py
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "CADD"]
path = CADD
url = https://github.com/BOINC/CADD.git
1 change: 1 addition & 0 deletions CADD
Submodule CADD added at ef47df
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# Raccoon2_BOINC_Plugin
Raccon2 BOINC Plugin
# Raccoon2 BOINC Plugin

This plugin extends the functionality of [Raccoon2](https://autodock.scripps.edu/resources/raccoon2/) application by adding support for [BOINC](https://boinc.berkeley.edu/).

It allows to run [Autodock Vina](https://vina.scripps.edu/) tasks on [BOINC Central](https://boinc.berkeley.edu/central/) infrastructure.

IMPORTANT: To submit tasks to [BOINC Central](https://boinc.berkeley.edu/central/), please [contact](https://boinc.berkeley.edu/anderson/) us.

## Installation

To install the plugin, you need to have Raccoon2 1.5.7 installed.

Then, navigate to the `MGLTOOLS_FOLDER` folder, and put `raccoon2_boinc_installer.py` there.

Finally, you can install the plugin using the following command:

### Linux/Mac:

```bash
./bin/pythonsh raccoon2_boinc_installer.py install
```

### Windows:
Before running the command, you need to start `cmd` as an administrator, then navigate to the `MGLTOOLS_FOLDER` folder.

```bash
python.exe raccoon2_boinc_installer.py install
```

where `MGLTOOLS_FOLDER` is the folder where MGLTools is installed and `PATH_TO_PLUGIN` is the path to the this folder.

## Uninstallation

To uninstall the plugin, navigate to the `MGLTOOLS_FOLDER` folder, and put `raccoon2_boinc_installer.py` there.

Then you can use the following command:

### Linux/Mac:

```bash
./bin/pythonsh raccoon2_boinc_installer.py uninstall
```

### Windows:
Before running the command, you need to start `cmd` as an administrator, then navigate to the `MGLTOOLS_FOLDER` folder.

```bash
python.exe raccoon2_boinc_installer.py uninstall
```

where `MGLTOOLS_FOLDER` is the folder where MGLTools is installed and `PATH_TO_PLUGIN` is the path to the this folder.
73 changes: 73 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import base64
import hashlib
import sys

os = sys.argv[1]

files = [
'CADD/Raccoon2/BoincClient.py',
'CADD/Raccoon2/gui/AA_setup.py',
'CADD/Raccoon2/gui/BB_ligand.py',
'CADD/Raccoon2/gui/CC_receptor.py',
'CADD/Raccoon2/gui/EE_jobmanager.py',
'CADD/Raccoon2/gui/FF_anaylsis.py',
'CADD/Raccoon2/gui/Raccoon2GUI.py',
'CADD/Raccoon2/gui/RaccoonEngine.py',
'CADD/Raccoon2/gui/icons/boinc.png'
]

def get_file_hash(file):
with open(file, 'rb') as f:
return hashlib.sha512(f.read()).hexdigest()

def get_file_content(file):
with open(file, 'rb') as f:
return base64.b64encode(f.read())

def build_installer_py():
with open('raccoon2_boinc_installer.py', 'w') as f:
f.write('# IMPORTANT: Do not run this file directly.\n')
f.write('# Please read README.md first for usage instructions.\n')
f.write('import base64\n')
f.write('import hashlib\n')
f.write('import os\n')
f.write('import shutil\n')
f.write('import sys\n')
f.write('curdir = os.getcwd()\n')
f.write('if len(sys.argv) > 1 and sys.argv[1] == \'install\':\n')
for file in files:
hash = get_file_hash(file)
content = get_file_content(file)
if os == 'linux' or os == 'macos':
f.write(' file = curdir+\'/MGLToolsPckgs/%s\'\n' % file)
elif os == 'windows':
f.write(' file = curdir+\'/Lib/site-packages/%s\'\n' % file)
f.write(' content = %s\n' % content)
f.write(' if os.path.exists(file):\n')
f.write(' with open(file, \'rb\') as f:\n')
f.write(' hash = hashlib.sha512(f.read()).hexdigest()\n')
f.write(' if hash != \'%s\':\n' % hash)
f.write(' shutil.copy(file, file+\'.orig\')\n')
f.write(' with open(file, \'wb\') as f:\n')
f.write(' f.write(base64.b64decode(content))\n')
f.write(' else:\n')
f.write(' print(\'already updated: \' + file)\n')
f.write(' else:\n')
f.write(' with open(file, \'wb\') as f:\n')
f.write(' f.write(base64.b64decode(content))\n')
f.write(' print (\'Done\')\n')
f.write('elif len(sys.argv) > 1 and sys.argv[1] == \'uninstall\':\n')
for file in files:
if os == 'linux' or os == 'macos':
f.write(' file = curdir+\'/MGLToolsPckgs/%s\'\n' % file)
elif os == 'windows':
f.write(' file = curdir+\'/Lib/site-packages/%s\'\n' % file)
f.write(' if os.path.exists(file+\'.orig\'):\n')
f.write(' shutil.copy(file+\'.orig\', file)\n')
f.write(' os.remove(file+\'.orig\')\n')
f.write(' print (\'Done\')\n')
f.write('else:\n')
f.write(' print (\'Please read README.md for usage instructions.\')\n')

if __name__ == "__main__":
build_installer_py()