Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBarker-NOAA committed Aug 25, 2020
2 parents 494c9e4 + 6897e4a commit e7dfe6c
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 71 deletions.
2 changes: 1 addition & 1 deletion conda_requirements_py3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# These should all be in the conda-forge channel:
# Best to have it at the top in your conda configuration

python=3.8.*
python>=3.6.*
gitpython
numpy>=1.16.*
scipy>=0.18.1
Expand Down
22 changes: 12 additions & 10 deletions oil_library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@

from .models import DBSession

#import sample_oils

try:
__version__ = get_distribution('oil_library').version
except Exception:
__version__ = 'not_found'
__version__ = '1.1.3'


#
Expand Down Expand Up @@ -78,10 +73,17 @@ def initialize_console_log(level='debug'):

level = log_levels[level.lower()]

logging.basicConfig(force=True, # make sure this gets set up
stream=sys.stdout,
level=level,
format=logger_format)
ver = sys.version_info
# only call force for py 3.8 or greater
if ver.major == 3 and ver.minor >= 8:
logging.basicConfig(force=True, # make sure this gets set up
stream=sys.stdout,
level=level,
format=logger_format)
else:
logging.basicConfig(stream=sys.stdout,
level=level,
format=logger_format)


def add_file_log(filename, level='info'):
Expand Down
136 changes: 76 additions & 60 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,41 @@
from setuptools.command.build_py import build_py
from setuptools.command.test import test as TestCommand

from git import Repo
from git.exc import InvalidGitRepositoryError

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
pkg_name = 'oil_library'
pkg_version = '1.1.2'

def get_version():
"""
return the version number from the __init__
"""
for line in open(os.path.join(pkg_name, "__init__.py")):
if line.startswith("__version__"):
version = line.strip().split('=')[1].strip().strip("'").strip('"')
return version
raise ValueError("can't find version string in __init__")

# try to get update date from repo
try:
repo = Repo('.')
pkg_version = get_version()


def get_repo_data():
try:
branch_name = repo.active_branch.name
except TypeError:
branch_name = 'no-branch'
last_update = next(repo.iter_commits()).committed_datetime.isoformat()
except InvalidGitRepositoryError:
# not building in a valid git repo
# use today's date.
print("not in a valid git repo -- using today's date as build date")
branch_name = 'no-branch'
last_update = datetime.now().isoformat()
from git import Repo
from git.exc import InvalidGitRepositoryError

repo = Repo('.')
try:
branch_name = repo.active_branch.name
except TypeError:
branch_name = 'no-branch'
last_update = next(repo.iter_commits()).committed_datetime.isoformat()
except: # bare excepts are not good, but in this case,
# anything that goes wrong results in the same thing.
print("something wrong with accessing git repo -- using today's date as build date")
branch_name = 'no branch'
last_update = datetime.now().isoformat()
return branch_name, last_update


def clean_files(del_db=False):
Expand Down Expand Up @@ -150,49 +162,53 @@ def run(self):
# build_py is an old-style class, so we can't use super()
build_py.run(self)


s = setup(name=pkg_name,
version=pkg_version,
description=('{}: The NOAA library of oils and their properties.\n'
'Branch: {}\n'
'LastUpdate: {}'
.format(pkg_name, branch_name, last_update)),
long_description=README,
author='ADIOS/GNOME team at NOAA ORR',
author_email='orr.gnome@noaa.gov',
url='',
keywords='adios weathering oilspill modeling',
packages=find_packages(),
include_package_data=True,
package_data={'oil_library': ['OilLib.db',
'OilLib',
'OilLibTest',
'OilLibNorway',
'blacklist_whitelist.txt',
'tests/*.py',
'tests/sample_data/*']},
cmdclass={'remake_oil_db': remake_oil_db,
'cleanall': cleanall,
'test': PyTest,
'build_py': BuildPyCommand,
DESCRIPTION = ('{}: The NOAA library of oils and their properties.\n'
'Branch: {}\n'
'LastUpdate: {}'
.format(pkg_name, *get_repo_data())
)


setup(name=pkg_name,
version=pkg_version,
description=DESCRIPTION,
long_description=README,
author='ADIOS/GNOME team at NOAA ORR',
author_email='orr.gnome@noaa.gov',
url='',
keywords='adios weathering oilspill modeling',
packages=find_packages(),
include_package_data=True,
package_data={'oil_library': ['OilLib.db',
'OilLib',
'OilLibTest',
'OilLibNorway',
'blacklist_whitelist.txt',
'tests/*.py',
'tests/sample_data/*']},
cmdclass={'remake_oil_db': remake_oil_db,
'cleanall': cleanall,
'test': PyTest,
'build_py': BuildPyCommand,
},
entry_points={'console_scripts': [('initialize_OilLibrary_db = '
'oil_library.initializedb'
':make_db'),
('diff_import_files = '
'oil_library.scripts.oil_import'
':diff_import_files_cmd'),
('add_header_to_import_file = '
'oil_library.scripts.oil_import'
':add_header_to_csv_cmd'),
('get_import_record_dates = '
'oil_library.scripts.oil_import'
':get_import_record_dates_cmd'),
],
},
entry_points={'console_scripts': [('initialize_OilLibrary_db = '
'oil_library.initializedb'
':make_db'),
('diff_import_files = '
'oil_library.scripts.oil_import'
':diff_import_files_cmd'),
('add_header_to_import_file = '
'oil_library.scripts.oil_import'
':add_header_to_csv_cmd'),
('get_import_record_dates = '
'oil_library.scripts.oil_import'
':get_import_record_dates_cmd'),
],
},
zip_safe=False,
)


if 'develop' in s.script_args and '--uninstall' not in s.script_args:
zip_safe=False,
)


if 'develop' in sys.argv and '--uninstall' not in sys.argv:
init_db()

0 comments on commit e7dfe6c

Please sign in to comment.