Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit e7dfe6c

Browse files
Merge branch 'develop'
2 parents 494c9e4 + 6897e4a commit e7dfe6c

File tree

3 files changed

+89
-71
lines changed

3 files changed

+89
-71
lines changed

conda_requirements_py3.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# These should all be in the conda-forge channel:
44
# Best to have it at the top in your conda configuration
55

6-
python=3.8.*
6+
python>=3.6.*
77
gitpython
88
numpy>=1.16.*
99
scipy>=0.18.1

oil_library/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515

1616
from .models import DBSession
1717

18-
#import sample_oils
19-
20-
try:
21-
__version__ = get_distribution('oil_library').version
22-
except Exception:
23-
__version__ = 'not_found'
18+
__version__ = '1.1.3'
2419

2520

2621
#
@@ -78,10 +73,17 @@ def initialize_console_log(level='debug'):
7873

7974
level = log_levels[level.lower()]
8075

81-
logging.basicConfig(force=True, # make sure this gets set up
82-
stream=sys.stdout,
83-
level=level,
84-
format=logger_format)
76+
ver = sys.version_info
77+
# only call force for py 3.8 or greater
78+
if ver.major == 3 and ver.minor >= 8:
79+
logging.basicConfig(force=True, # make sure this gets set up
80+
stream=sys.stdout,
81+
level=level,
82+
format=logger_format)
83+
else:
84+
logging.basicConfig(stream=sys.stdout,
85+
level=level,
86+
format=logger_format)
8587

8688

8789
def add_file_log(filename, level='info'):

setup.py

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,41 @@
1717
from setuptools.command.build_py import build_py
1818
from setuptools.command.test import test as TestCommand
1919

20-
from git import Repo
21-
from git.exc import InvalidGitRepositoryError
2220

2321
here = os.path.abspath(os.path.dirname(__file__))
2422
README = open(os.path.join(here, 'README.rst')).read()
2523
pkg_name = 'oil_library'
26-
pkg_version = '1.1.2'
2724

25+
def get_version():
26+
"""
27+
return the version number from the __init__
28+
"""
29+
for line in open(os.path.join(pkg_name, "__init__.py")):
30+
if line.startswith("__version__"):
31+
version = line.strip().split('=')[1].strip().strip("'").strip('"')
32+
return version
33+
raise ValueError("can't find version string in __init__")
2834

29-
# try to get update date from repo
30-
try:
31-
repo = Repo('.')
35+
pkg_version = get_version()
36+
37+
38+
def get_repo_data():
3239
try:
33-
branch_name = repo.active_branch.name
34-
except TypeError:
35-
branch_name = 'no-branch'
36-
last_update = next(repo.iter_commits()).committed_datetime.isoformat()
37-
except InvalidGitRepositoryError:
38-
# not building in a valid git repo
39-
# use today's date.
40-
print("not in a valid git repo -- using today's date as build date")
41-
branch_name = 'no-branch'
42-
last_update = datetime.now().isoformat()
40+
from git import Repo
41+
from git.exc import InvalidGitRepositoryError
42+
43+
repo = Repo('.')
44+
try:
45+
branch_name = repo.active_branch.name
46+
except TypeError:
47+
branch_name = 'no-branch'
48+
last_update = next(repo.iter_commits()).committed_datetime.isoformat()
49+
except: # bare excepts are not good, but in this case,
50+
# anything that goes wrong results in the same thing.
51+
print("something wrong with accessing git repo -- using today's date as build date")
52+
branch_name = 'no branch'
53+
last_update = datetime.now().isoformat()
54+
return branch_name, last_update
4355

4456

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

153-
154-
s = setup(name=pkg_name,
155-
version=pkg_version,
156-
description=('{}: The NOAA library of oils and their properties.\n'
157-
'Branch: {}\n'
158-
'LastUpdate: {}'
159-
.format(pkg_name, branch_name, last_update)),
160-
long_description=README,
161-
author='ADIOS/GNOME team at NOAA ORR',
162-
author_email='orr.gnome@noaa.gov',
163-
url='',
164-
keywords='adios weathering oilspill modeling',
165-
packages=find_packages(),
166-
include_package_data=True,
167-
package_data={'oil_library': ['OilLib.db',
168-
'OilLib',
169-
'OilLibTest',
170-
'OilLibNorway',
171-
'blacklist_whitelist.txt',
172-
'tests/*.py',
173-
'tests/sample_data/*']},
174-
cmdclass={'remake_oil_db': remake_oil_db,
175-
'cleanall': cleanall,
176-
'test': PyTest,
177-
'build_py': BuildPyCommand,
165+
DESCRIPTION = ('{}: The NOAA library of oils and their properties.\n'
166+
'Branch: {}\n'
167+
'LastUpdate: {}'
168+
.format(pkg_name, *get_repo_data())
169+
)
170+
171+
172+
setup(name=pkg_name,
173+
version=pkg_version,
174+
description=DESCRIPTION,
175+
long_description=README,
176+
author='ADIOS/GNOME team at NOAA ORR',
177+
author_email='orr.gnome@noaa.gov',
178+
url='',
179+
keywords='adios weathering oilspill modeling',
180+
packages=find_packages(),
181+
include_package_data=True,
182+
package_data={'oil_library': ['OilLib.db',
183+
'OilLib',
184+
'OilLibTest',
185+
'OilLibNorway',
186+
'blacklist_whitelist.txt',
187+
'tests/*.py',
188+
'tests/sample_data/*']},
189+
cmdclass={'remake_oil_db': remake_oil_db,
190+
'cleanall': cleanall,
191+
'test': PyTest,
192+
'build_py': BuildPyCommand,
193+
},
194+
entry_points={'console_scripts': [('initialize_OilLibrary_db = '
195+
'oil_library.initializedb'
196+
':make_db'),
197+
('diff_import_files = '
198+
'oil_library.scripts.oil_import'
199+
':diff_import_files_cmd'),
200+
('add_header_to_import_file = '
201+
'oil_library.scripts.oil_import'
202+
':add_header_to_csv_cmd'),
203+
('get_import_record_dates = '
204+
'oil_library.scripts.oil_import'
205+
':get_import_record_dates_cmd'),
206+
],
178207
},
179-
entry_points={'console_scripts': [('initialize_OilLibrary_db = '
180-
'oil_library.initializedb'
181-
':make_db'),
182-
('diff_import_files = '
183-
'oil_library.scripts.oil_import'
184-
':diff_import_files_cmd'),
185-
('add_header_to_import_file = '
186-
'oil_library.scripts.oil_import'
187-
':add_header_to_csv_cmd'),
188-
('get_import_record_dates = '
189-
'oil_library.scripts.oil_import'
190-
':get_import_record_dates_cmd'),
191-
],
192-
},
193-
zip_safe=False,
194-
)
195-
196-
197-
if 'develop' in s.script_args and '--uninstall' not in s.script_args:
208+
zip_safe=False,
209+
)
210+
211+
212+
if 'develop' in sys.argv and '--uninstall' not in sys.argv:
198213
init_db()
214+

0 commit comments

Comments
 (0)