Skip to content

Commit c22a742

Browse files
release task : pypi upload
1 parent 84c9454 commit c22a742

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

PySpice/__init__.py.in

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

2121
####################################################################################################
2222

23-
__version__ = '1.3.1'
23+
__version__ = '@VERSION@'
24+
__git_tag__ = '@GIT_TAG@'
2425
__git_sha__ = '@GIT_SHA@'
2526

2627
def show_version():

tasks/release.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
####################################################################################################
2222

2323
from pathlib import Path
24+
import re
25+
import shutil
2426

2527
from invoke import task
2628

@@ -80,18 +82,35 @@ def find_package(ctx, name):
8082
@task()
8183
def update_git_sha(ctx):
8284
result = ctx.run('git describe --tags --abbrev=0 --always', hide='out')
85+
tag = result.stdout.strip()
86+
if tag.startswith('v'):
87+
version = tag[1:]
88+
else:
89+
version = tag
90+
if not re.match('\d+(\.\d+(\.\d+)?)?', version):
91+
raise ValueError('Invalid version {}'.format(version))
92+
result = ctx.run('git rev-parse HEAD', hide='out')
8393
sha = result.stdout.strip()
94+
print(sha)
95+
print(tag)
96+
print(version)
8497
filename = Path(ctx.Package, '__init__.py')
8598
with open(str(filename) + '.in', 'r') as fh:
8699
lines = fh.readlines()
87100
with open(filename, 'w') as fh:
88101
for line in lines:
89102
if '@' in line:
103+
line = line.replace('@VERSION@', version)
104+
line = line.replace('@GIT_TAG@', tag)
90105
line = line.replace('@GIT_SHA@', sha)
91106
fh.write(line)
92107

93108
####################################################################################################
94109

110+
def clean(ctx):
111+
for directory in ('build', 'dist'):
112+
shutil.rmtree(directory)
113+
95114
def show_python_site(ctx):
96115
ctx.run('python3 -m site')
97116

@@ -102,3 +121,17 @@ def build(ctx):
102121
@task(build)
103122
def install(ctx):
104123
ctx.run('python3 setup.py install')
124+
125+
@task(build)
126+
def install(ctx):
127+
ctx.run('python3 setup.py install')
128+
129+
@task(clean, build)
130+
def wheel(ctx):
131+
ctx.run('python3 setup.py bdist_wheel')
132+
133+
@task(build)
134+
def upload(ctx):
135+
ctx.run('twine register dist/*whl')
136+
ctx.run('gpg --detach-sign -a dist/*whl')
137+
ctx.run('twine upload dist/*')

tasks/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# source /opt/python-virtual-env/py36/bin/activate
2+
# unset PYHONPATH
3+
# tox

tools/upload-to-pypi

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)