Skip to content

Commit

Permalink
Enforce Python 3 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfuchs committed Oct 13, 2019
1 parent 7cf8a33 commit 6bc8c68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ buildH is written in Python 3 and need the following modules :
- pandas
- MDAnalysis.

Python version >= 3.7 is recommended for running buildH. The code will raise an Exception if a user attempts to use Python 2.

## Usage

Expand Down
16 changes: 14 additions & 2 deletions buildH_calcOP.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
!/usr/bin/env python3
# coding: utf-8

"""
Expand Down Expand Up @@ -37,8 +37,10 @@
# Modules.
import argparse
import copy
import pickle
import collections
import pickle
import sys
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -1081,6 +1083,16 @@ def make_dic_Cname2Hnames(dic_OP):


if __name__ == "__main__":
# 0) Fist ensure Python 3 is used!!!
major, minor, _, _, _ = sys.version_info
if major != 3:
raise UserWarning("buildH only works with Python 3.")
else:
if minor < 7:
warnings.warn("Python version >= 3.7 is recommended with buildH.", UserWarning)
else:
print("Python version OK!")

# 1) Parse arguments.
# TODO --> Make a function for that.
message="""This program builds hydrogens and calculate the order
Expand Down

0 comments on commit 6bc8c68

Please sign in to comment.