Skip to content

Commit 8d71a8c

Browse files
committed
add dulwich to required packages in setup
* change version file check to use CONSTANTS instead of function get_or_create_version() * add comments * use importlib to get version file, instead of hardcode name, so this can be reused in other packages * ignore version.py * cherry pick ignores from quickstart branch * Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
1 parent 1142bf1 commit 8d71a8c

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
dist/
1313
build/
1414
*.egg-info/
15+
version.py
1516

1617
# docs
1718
carousel/docs/_build/
@@ -20,3 +21,8 @@ carousel/docs/_build/
2021
.cache/
2122
__pycache__
2223
carousel/tests/xlrdreader_testdata.xlsx.json
24+
.coverage
25+
cover/
26+
classes_Carousel.png
27+
packages_Carousel.png
28+
make_uml_diagram

carousel/__init__.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@
77
from carousel.release_robot import get_current_version
88
from dulwich.repo import NotGitRepository
99
import os
10+
import importlib
1011

11-
BASEDIR = os.path.dirname(__file__)
12-
13-
14-
def get_or_create_version(verfile='version.py'):
15-
try:
16-
git_version = get_current_version()
17-
except (ImportError, NotGitRepository):
18-
git_version = None
19-
try:
20-
from carousel.version import VERSION
21-
except ImportError:
22-
VERSION = None
23-
if git_version is not None and VERSION != git_version:
24-
with open(os.path.join(BASEDIR, verfile), 'w') as vf:
25-
vf.write('VERSION = "%s"\n' % git_version)
26-
else:
27-
git_version = VERSION
28-
return git_version
29-
12+
BASEDIR = os.path.dirname(__file__) # this directory
13+
VER_FILE = 'version' # name of file to store version
14+
# use release robot to try to get current Git tag
15+
try:
16+
GIT_TAG = get_current_version()
17+
except NotGitRepository:
18+
GIT_TAG = None
19+
# check version file
20+
try:
21+
version = importlib.import_module('%s.%s' % (__name__, VER_FILE))
22+
except ImportError:
23+
VERSION = None
24+
else:
25+
VERSION = version.VERSION
26+
# update version file if it differs from Git tag
27+
if GIT_TAG is not None and VERSION != GIT_TAG:
28+
with open(os.path.join(BASEDIR, VER_FILE + '.py'), 'w') as vf:
29+
vf.write('VERSION = "%s"\n' % GIT_TAG)
30+
else:
31+
GIT_TAG = VERSION # if Git tag is none use version file
32+
VERSION = GIT_TAG # version
3033

3134
__author__ = u'Mark Mikofski'
3235
__email__ = u'mark.mikofski@sunpowercorp.com'
3336
__url__ = u'https://github.com/SunPower/Carousel'
34-
__version__ = get_or_create_version()
37+
__version__ = VERSION
3538
__release__ = u'Caramel Corn'

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
REQUIRES = [
2424
'numpy', 'xlrd', 'scipy', 'python_dateutil', 'numexpr', 'pint (>=0.7.2)',
25-
'UncertaintyWrapper (>=0.4.1)', 'sphinx', 'nose', 'pandas', 'pytz', 'pvlib'
25+
'UncertaintyWrapper (>=0.4.1)', 'sphinx', 'nose', 'pandas', 'pytz',
26+
'pvlib (>=0.4.2)', 'dulwich'
2627
]
2728
INST_REQ = ['%s%s' % (r[0], r[1][1:-1]) if len(r) == 2 else r[0]
2829
for r in (r.split() for r in REQUIRES)]

0 commit comments

Comments
 (0)