Skip to content

Commit 6fcec8a

Browse files
committed
update tasks, setup, version
1 parent 811d1c2 commit 6fcec8a

File tree

6 files changed

+51
-33
lines changed

6 files changed

+51
-33
lines changed

LICENSE LICENSE.txt

File renamed without changes.

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include LICENSE
1+
include LICENSE.txt
22
include CHANGELOG.md
33
include rocketsled/defaults.yaml

VERSION

-1
This file was deleted.

rocketsled/__init__.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
from rocketsled.control import MissionControl
88
from rocketsled.task import OptTask
99

10-
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),
11-
"../VERSION"), "r") as f:
12-
version = f.read()
13-
__version__ = version
14-
1510
__author__ = "Alexander Dunn"
1611
__email__ = "[email protected]"
12+
__version__ = "2019.9.11"
13+
1714

setup.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import os
22
from setuptools import setup, find_packages
33

4+
version = "2019.9.11"
45
module_dir = os.path.dirname(os.path.abspath(__file__))
5-
with open(os.path.join(module_dir, "VERSION"), "r") as f:
6-
version = f.read()
7-
86
with open(os.path.join(module_dir, "requirements.txt"), "r") as f:
97
requirements = f.read().replace(" ", "").split("\n")
108

@@ -61,6 +59,8 @@
6159
test_suite='rocketsled',
6260
tests_require='tests',
6361
packages=find_packages(),
64-
package_data={'rocketsled': ['defaults.yaml']},
62+
# package_data={'rocketsled': ['defaults.yaml']},
6563
install_requires=requirements,
66-
data_files=['LICENSE'])
64+
# data_files=['LICENSE', 'README.md', 'VERSION'],
65+
include_package_data=True
66+
)

tasks.py

+43-21
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@
66
import json
77
import webbrowser
88
import requests
9+
import datetime
910
from invoke import task
11+
1012
from rocketsled import __version__
1113
from monty.os import cd
1214

13-
1415
"""
1516
Deployment file to facilitate releases.
1617
"""
1718

18-
__author__ = "Shyue Ping Ong, Anubhav Jain"
19-
__email__ = "[email protected]"
20-
__date__ = "Sep 1, 2014"
21-
2219

2320
@task
2421
def make_doc(ctx):
@@ -37,26 +34,55 @@ def make_doc(ctx):
3734

3835

3936
@task
40-
def update_doc(ctx):
41-
make_doc(ctx)
42-
with cd("docs"):
43-
ctx.run("git add .")
44-
ctx.run("git commit -a -m \"Update to v{}\"".format(__version__))
45-
ctx.run("git push")
37+
def open_doc(ctx):
38+
pth = os.path.abspath("docs/index.html")
39+
webbrowser.open("file://" + pth)
4640

4741

4842
@task
49-
def publish(ctx):
50-
ctx.run("rm dist/*.*", warn=True)
51-
ctx.run("python3 setup.py sdist bdist_wheel")
52-
ctx.run("twine upload dist/*")
43+
def version_check(ctx):
44+
with open("setup.py", "r") as f:
45+
setup_version = None
46+
for l in f.readlines():
47+
if "version = " in l:
48+
setup_version = l.split(" ")[-1]
49+
setup_version = setup_version.replace('"', "").replace("\n", "")
50+
51+
if setup_version is None:
52+
raise IOError("Could not parse setup.py for version.")
53+
54+
if __version__ == setup_version:
55+
print("Setup and init versions match eachother.")
56+
today = datetime.date.today().strftime("%Y.%-m.%-d")
57+
if today != __version__:
58+
raise ValueError(f"The version {__version__} does not match "
59+
f"the date!")
60+
else:
61+
print("Version matches the date.")
62+
else:
63+
raise ValueError(f"There is a mismatch in the date between the "
64+
f"rocketsled __init__ and the setup. Please "
65+
f"make sure they are the same."
66+
f"\n DIFF: {__version__}, {setup_version}")
67+
5368

5469
@task
5570
def update_changelog(ctx):
71+
version_check(ctx)
5672
ctx.run('github_changelog_generator hackingmaterials/rocketsled')
5773

74+
75+
@task
76+
def publish(ctx):
77+
version_check(ctx)
78+
ctx.run("rm dist/*.* build/*", warn=True)
79+
ctx.run("python3 setup.py sdist bdist_wheel")
80+
ctx.run("twine upload dist/*")
81+
82+
5883
@task
5984
def release(ctx):
85+
version_check(ctx)
6086
payload = {
6187
"tag_name": "v" + __version__,
6288
"target_commitish": "master",
@@ -68,10 +94,6 @@ def release(ctx):
6894
response = requests.post(
6995
"https://api.github.com/repos/hackingmaterials/rocketsled/releases",
7096
data=json.dumps(payload),
71-
headers={"Authorization": "token " + os.environ["GITHUB_RELEASES_TOKEN"]})
97+
headers={
98+
"Authorization": "token " + os.environ["GITHUB_RELEASES_TOKEN"]})
7299
print(response.text)
73-
74-
@task
75-
def open_doc(ctx):
76-
pth = os.path.abspath("docs/index.html")
77-
webbrowser.open("file://" + pth)

0 commit comments

Comments
 (0)