From 3d0ad3acd47bbf5b1403deb0921a2f70ea229051 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Tue, 12 Mar 2024 14:53:08 +0100 Subject: [PATCH] Add script to build installer and uninstaller Signed-off-by: Vitalii Koshura --- .github/workflows/build.yml | 31 ++++++++++++++++ .gitignore | 34 +---------------- .gitmodules | 3 ++ CADD | 1 + README.md | 53 ++++++++++++++++++++++++++- build.py | 73 +++++++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .gitmodules create mode 160000 CADD create mode 100644 build.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..57c931f --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.gitignore b/.gitignore index 259148f..3d7d4bd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..305a504 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "CADD"] + path = CADD + url = https://github.com/BOINC/CADD.git diff --git a/CADD b/CADD new file mode 160000 index 0000000..ef47df0 --- /dev/null +++ b/CADD @@ -0,0 +1 @@ +Subproject commit ef47df09eefe0ec3baeb10a93dea05476ac8bd66 diff --git a/README.md b/README.md index a6230f1..4c8bfdf 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.py b/build.py new file mode 100644 index 0000000..ba94d28 --- /dev/null +++ b/build.py @@ -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()