Skip to content

Commit

Permalink
Merge pull request #15 from bmatern/master
Browse files Browse the repository at this point in the history
Logging and Python 3 updates
  • Loading branch information
bmatern authored Dec 11, 2017
2 parents 4b896b5 + 5f58e39 commit 8623845
Show file tree
Hide file tree
Showing 22 changed files with 992 additions and 911 deletions.
43 changes: 21 additions & 22 deletions AlleleSubInstallerOptions_Windows.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,26 @@

block_cipher = None


a = Analysis(['saddlebags\AlleleSubMain.py'],
binaries=None,
datas=[('images\horse_image_icon.ico', 'images')] ,
hiddenimports=['six', 'packaging', 'packaging.requirements', 'packaging.version', 'packaging.specifiers', 'Tkinter', 'tkFileDialog', 'Tkconstants', 'saddlebags.AlleleSubMainGui'],
hookspath=[],
runtime_hooks=[],
excludes=['tkinter'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
a = Analysis(['AlleleSubMain.py'],
binaries=None,
datas=[('images\horse_image_icon.ico', 'images')] ,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='SaddlebagsWindows',
debug=False,
strip=False,
upx=True,
console=False,
icon='images\horse_image_icon.ico' )
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='SaddlebagsWindows',
debug=False,
strip=False,
upx=True,
console=False,
icon='images\horse_image_icon.ico' )
41 changes: 23 additions & 18 deletions saddlebags/AlleleSubMain.py → AlleleSubMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,48 @@
# You should have received a copy of the GNU Lesser General Public License
# along with saddle-bags. If not, see <http://www.gnu.org/licenses/>.

import Tkinter
import sys
#import Tkinter
#import sys
from sys import argv, exc_info
from tkinter import Tk

from saddlebags.AlleleSubCommon import loadConfigurationFile
from saddlebags.AlleleSubMainGui import AlleleSubMainGui
# This exception handling is necessary for packaging the modules in pyinstaller.
# The namespace(?) is required to find the modules in pyinstaller.
try:
from AlleleSubMainGui import AlleleSubMainGui
from AlleleSubCommon import loadConfigurationFile
except:
from saddlebags.AlleleSubMainGui import AlleleSubMainGui
from saddlebags.AlleleSubCommon import loadConfigurationFile

#try:
# from AlleleSubMainGui import AlleleSubMainGui
# from AlleleSubCommon import loadConfigurationFile
#except:
# from saddlebags.AlleleSubMainGui import AlleleSubMainGui
# from saddlebags.AlleleSubCommon import loadConfigurationFile

SoftwareVersion = 'saddlebags Version 1.1'
SoftwareVersion = 'saddlebags Version 1.2'

if __name__=='__main__':
try:
# This is a really simple way to read commandline args,
# because there really shouldn't be any.
# TODO: Be more graceful with this, there are better ways to read args.
# No parameters are expected at all. sys.argv[0] doesn't count.
if (len(sys.argv) == 1):
if (len(argv) == 1):

loadConfigurationFile()

print('\n\n\n\n\n***Starting the HLA Allele Submission Tool***\n')

root = Tkinter.Tk()
root = Tk()
AlleleSubMainGui(root).pack()
root.mainloop()

print('Done. Hooray.')

# Print the Software Version
elif (len(sys.argv) == 2 and (
sys.argv[1].lower() == '-v' or
sys.argv[1].lower() == '--version' or
sys.argv[1].lower() == '-version')
elif (len(argv) == 2 and (
argv[1].lower() == '-v' or
argv[1].lower() == '--version' or
argv[1].lower() == '-version')
):
print (SoftwareVersion)
pass
Expand All @@ -61,13 +66,13 @@
"\tRun this program using standard python call:\n" +
"\t$python AlleleSubmissionMain.py\n" +
"\tbiopython must be accessible in your python environment. To run using Anaconda,\n"
"\tCheck readme at https://github.com/transplantation-immunology/saddle-bags\n"
"\tCheck readme at https://github.com/transplantation-immunology-maastricht/saddle-bags\n"
)


except Exception:
# Top Level exception handling like a pro.
# This is not really doing anything.
print 'Unexpected problem during execution:'
print sys.exc_info()[1]
print ('Unexpected problem during execution:')
print (exc_info()[1])
raise
4 changes: 2 additions & 2 deletions MakeExecutables.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
SET CodePath=saddlebags
SET BinPath=bin
SET SpecFile=AlleleSubInstallerOptions_Windows.spec
SET CondaEnvironment=minionvironment
SET VirtualEnvironmentLocation=C:\Users\ben\Envs\minionvenv\Scripts

:: Run Pyinstaller to create executables
:: cd %CodePath%
activate %CondaEnvironment% && pyinstaller %SpecFile% --distpath %BinPath% --clean && deactivate
activate %VirtualEnvironmentLocation%\activate && pyinstaller %SpecFile% --distpath %BinPath% --clean && deactivate
52 changes: 35 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,49 @@ Download an executable for Windows from the Release page.
[Download Saddlebags for Windows Here](https://github.com/transplantation-immunology-maastricht/saddle-bags/releases)

## Run using Python
Alternatively, you can run this program using Python 2.7. This works for Mac and Linux users (or Windows). There are prerequesites, I recommend you install them inside an Anaconda environment. See Run_allele_submission.sh and Run_allele_submission.bat for an example of this in Linux and Windows environments, respectively.
Alternatively, you can run this program using Python 3.6. The required packages can be installed within a python virtual environment. This works for Mac and Linux users, or Windows. See Run_allele_submission.bat and Run_allele_submission.sh for an example of launching Saddlebags in Windows, or Linux/Mac, respectively..

## To configure Virtual Environment.
The general installation instructions are similar for Windows and Linux/Mac environments.

Install the Git commandline. In Windows, there is an option to include the git bash console, I recommend doing this, as it is very useful.

Install Python 3.6, 64 or 32 bit.
[Download Python](https://www.python.org/downloads/release/python-363/)

The python installer includes pip, which is necessary for the next steps.

Install Virtual Environment. This requires a couple steps, because there is a windows wrapper to get virtual environment working with powershell.

```
python AlleleSubmissionMain.py
pip install virtualenv
pip install virtualenvwrapper-win
```
[More info](http://timmyreilly.azurewebsites.net/python-pip-virtualenv-installation-on-windows/)

## To configure Anaconda
Anaconda uses separate environments to run your programs in.
Install Anaconda for python 2.7.
https://www.continuum.io/downloads
To set up the environment in anaconda:
Create the virtual environment. I typically use an environment called "minionvenv":
```
mkvirtualenv minionvenv
```
The mkvirtualenv command should automatically activate the new environment. If not, activate the environment.
```
C:\Users\ben\Envs\minionvenv\Scripts\activate
```

Linux/Mac:
Is your environment activated? Then use pip to install the packages that saddlebags needs:
```
conda create --name minionvironment biopython six pycurl
source activate minionvironment
pip install pyinstaller packaging
source deactivate
```
Windows:
```
conda create --name minionvironment biopython six pywin32 pycurl
call activate minionvironment && pip install pyinstaller packaging && call deactivate
pip install biopython six pycurl pyinstaller packaging
```

In Ubuntu, Installing pycurl was a bit difficult inside of virtualenv.

https://stackoverflow.com/questions/37669428/error-in-installation-pycurl-7-19-0
sudo apt-get install libgnutls-dev

In linux, i needed Needed the "dev" verson of python 3.6
sudo apt-get install python3.6-dev


## Run using a bash or .bat script using anaconda
You can execute the following scripts to run the tool inside of Anaconda:
Linux/Mac:
Expand Down
6 changes: 2 additions & 4 deletions Run_allele_submission.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
:: You should have received a copy of the GNU Lesser General Public License
:: along with saddle-bags. If not, see <http://www.gnu.org/licenses/>.

:: Version 1.0
:: See the file README.MD for how to set up your virtual environment.

:: See the file README.MD for how to set up your anaconda environment.

activate minionvironment && cd saddlebags && python AlleleSubMain.py && deactivate
C:\Users\ben\Envs\minionvenv\Scripts\activate && python AlleleSubMain.py

12 changes: 4 additions & 8 deletions Run_allele_submission.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with saddle-bags. If not, see <http://www.gnu.org/licenses/>.

# See the file README.MD for how to set up your anaconda environment.

cd saddlebags

source activate minionvironment
python AlleleSubMain.py
source deactivate

# Activate the virtual environment.
source /home/ben/minionvenv/bin/activate

# Launch the Python.
python AlleleSubMain.py
10 changes: 0 additions & 10 deletions requirements_dev.txt

This file was deleted.

Loading

0 comments on commit 8623845

Please sign in to comment.