Skip to content

Commit c7edf0e

Browse files
committed
added updated_conda_forge_package function
1 parent 530685f commit c7edf0e

File tree

1 file changed

+64
-11
lines changed

1 file changed

+64
-11
lines changed

make_release.py

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import subprocess
1515
import sys
1616
import zipfile
17+
import hashlib
18+
import urllib.request as request
1719

1820
from datetime import date
1921
from os import chdir, makedirs
@@ -24,7 +26,9 @@
2426

2527
PY2 = sys.version_info[0] < 3
2628
TMP_PATH = r"c:\tmp\larray_new_release"
27-
29+
TMP_PATH_CONDA = r"c:\tmp\larray_conda_new_release"
30+
LARRAY_REP = 'https://github.com/liam2/larray'
31+
CONDA_LARRAY_FEEDSTOCK_REP = 'https://github.com/larray-project/larray-feedstock.git'
2832

2933
try:
3034
input = raw_input
@@ -411,6 +415,47 @@ def update_changelog(context):
411415
call('git commit -m "update release date in changes.rst" {}'.format(fpath))
412416

413417

418+
def update_conda_forge_package(context):
419+
create_tmp_directory(context)
420+
421+
try:
422+
# compute sha256
423+
url = LARRAY_REP + '/archive/{version}.tar.gz'.format(version=short(context['release_name']))
424+
print('Computing SHA256 from archive {}'.format(url), end=' ')
425+
with request.urlopen(url) as response:
426+
sha256 = hashlib.sha256(response.read()).hexdigest()
427+
print('done.')
428+
print('SHA256: ', sha256)
429+
430+
# clone repository
431+
clone_repository(context)
432+
433+
chdir(context['build_dir'])
434+
435+
# set version and sha256 in meta.yml file
436+
meta_file = r'recipe\meta.yaml'
437+
with open(meta_file, 'r') as f:
438+
lines = open(meta_file, 'r').readlines()
439+
lines[1] = '{{% set version = "{release_name}" %}}\n'.format(**context)
440+
lines[2] = '{{% set sha256 = "{sha256}" %}}\n'.format(sha256=sha256)
441+
with open(meta_file, 'w') as f:
442+
f.writelines(lines)
443+
# add, commit and push
444+
print(call('git status -s'))
445+
print(call('git diff {meta_file}'.format(meta_file=meta_file)))
446+
if no('Does that last changes look right?'):
447+
exit(1)
448+
do('Adding', call, 'git add {}'.format(meta_file))
449+
do('Commiting', call, 'git commit -m "bump to version {release_name}"'.format(**context))
450+
print(call('git log -1'))
451+
do('Pushing to GitHub', call, 'git push origin {branch}'.format(**context))
452+
# delete temporary directory
453+
cleanup(context)
454+
except Exception as e:
455+
cleanup(context)
456+
raise e
457+
458+
414459
def build_doc(context):
415460
chdir(context['build_dir'])
416461
chdir('doc')
@@ -480,6 +525,7 @@ def cleanup(context):
480525
(create_archives, 'Creating archives'),
481526
(final_confirmation, ''),
482527
(tag_release, 'Tagging release'),
528+
(update_conda_forge_package, ''),
483529
# We used to push from /tmp to the local repository but you cannot push
484530
# to the currently checked out branch of a repository, so we need to
485531
# pull changes instead. However pull (or merge) add changes to the
@@ -530,20 +576,27 @@ def make_release(release_name='dev', steps=':', branch='master'):
530576
'tmp_dir': TMP_PATH,
531577
'build_dir': os.path.join(TMP_PATH, 'build'),
532578
'public_release': public_release}
579+
context_conda = {'branch': branch,
580+
'release_name': release_name,
581+
'rev': rev,
582+
'repository': CONDA_LARRAY_FEEDSTOCK_REP,
583+
'tmp_dir': TMP_PATH_CONDA,
584+
'build_dir': os.path.join(TMP_PATH, 'build'),
585+
'public_release': public_release}
586+
533587
for step_func, step_desc in steps_funcs[start:stop]:
588+
ctx = context_conda if step_func == update_conda_forge_package else context
534589
if step_desc:
535-
do(step_desc, step_func, context)
590+
do(step_desc, step_func, ctx)
536591
else:
537-
step_func(context)
592+
step_func(ctx)
538593

539594

540595
if __name__ == '__main__':
541596
argv = sys.argv
542-
# if len(argv) < 2:
543-
# print("Usage: {} release_name|dev [step|startstep:stopstep] [branch]".format(argv[0]))
544-
# print("steps:", ', '.join(f.__name__ for f, _ in steps_funcs))
545-
# sys.exit()
546-
#
547-
# make_release(*argv[1:])
548-
549-
run_tests()
597+
if len(argv) < 2:
598+
print("Usage: {} release_name|dev [step|startstep:stopstep] [branch]".format(argv[0]))
599+
print("steps:", ', '.join(f.__name__ for f, _ in steps_funcs))
600+
sys.exit()
601+
602+
make_release(*argv[1:])

0 commit comments

Comments
 (0)