Skip to content

Commit 7bb9034

Browse files
committed
Finally getting the first release running as version 0.1.2
1 parent 3024915 commit 7bb9034

File tree

7 files changed

+55
-11
lines changed

7 files changed

+55
-11
lines changed

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
include README.rst
22
include LICENSE
33
include version.txt
4+
include challenges/version.txt
5+
include HelloWorld/sample.txt
6+
include HelloWorld/result.txt
47
recursive-include docs *

bin/challenge

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env python3
22

3+
import sys
4+
import os
5+
6+
here = os.path.abspath(os.path.dirname(__file__))
7+
sys.path.append(os.path.abspath(os.path.join(here, '..')))
8+
39
import challenges.main
410

511
challenges.main.main()

release.py renamed to bin/release

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
#!/usr/bin/env python3
2+
13
import os
24
import shutil
35

46

57
def main():
68
# pathes
79
here = os.path.abspath(os.path.dirname(__file__))
8-
sphinx = os.path.join(here, 'sphinx/')
9-
docs = os.path.join(here, 'docs/')
10-
html_source = os.path.join(here, 'sphinx/_build/html/')
11-
html_target = os.path.join(here, 'docs/html/')
12-
epub_source = os.path.join(here, 'sphinx/_build/epub/')
13-
epub_target = os.path.join(here, 'docs/epub/')
10+
root = os.path.abspath(os.path.join(here, '..'))
11+
sphinx = os.path.join(root, 'sphinx/')
12+
docs = os.path.join(root, 'docs/')
13+
dist = os.path.join(root, 'dist/')
14+
html_source = os.path.join(root, 'sphinx/_build/html/')
15+
html_target = os.path.join(root, 'docs/html/')
16+
epub_source = os.path.join(root, 'sphinx/_build/epub/')
17+
epub_target = os.path.join(root, 'docs/epub/')
1418
rst_challenges = os.path.join(sphinx, 'challenges.rst')
1519
rst_modules = os.path.join(sphinx, 'modules.rst')
1620
rst_hello = os.path.join(sphinx, 'HelloWorld.rst')
@@ -20,6 +24,9 @@ def main():
2024
'release.py '
2125
genhtml = 'make html'
2226
genepub = 'make epub'
27+
gendist = './setup.py sdist'
28+
test = 'twine upload dist/* -r testpypi'
29+
upload = 'twine upload dist/* -r pypi'
2330

2431
# execute
2532
if os.path.exists(docs):
@@ -28,7 +35,13 @@ def main():
2835
if not os.path.exists(docs):
2936
os.makedirs(docs)
3037

31-
with cd(here):
38+
if os.path.exists(dist):
39+
shutil.rmtree(dist)
40+
41+
if not os.path.exists(dist):
42+
os.makedirs(dist)
43+
44+
with cd(root):
3245
os.system(genapi)
3346

3447
with cd(sphinx):
@@ -41,11 +54,28 @@ def main():
4154

4255
os.rename(epub_source, epub_target)
4356

57+
with cd(root):
58+
os.system(gendist)
59+
4460
# cleanup autogenerated rst files
4561
os.remove(rst_challenges)
4662
os.remove(rst_hello)
4763
os.remove(rst_modules)
4864

65+
# Upload test
66+
print('Trying upload on TESTPYPI')
67+
with cd(root):
68+
os.system(test)
69+
70+
var = input('Uploading to live server? (y/n)')
71+
if var.strip() == 'y':
72+
with cd(root):
73+
os.system(upload)
74+
else:
75+
print('NOT UPLOADING. Please run the command manually!')
76+
print(upload)
77+
78+
4979
class cd:
5080
"""Context manager for changing the current working directory"""
5181

@@ -59,5 +89,6 @@ def __enter__(self):
5989
def __exit__(self, etype, value, traceback):
6090
os.chdir(self.savedPath)
6191

92+
6293
if __name__ == '__main__':
6394
main()

challenges/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self):
1313
self.parser = None
1414
self.args = None
1515
path = '{0}/version.txt'.format(os.path.realpath(
16-
os.path.dirname(__file__) + '/..'))
16+
os.path.dirname(__file__)))
1717
with open(path) as f:
1818
self.version = f.read().strip()
1919

challenges/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../version.txt

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@
2828
author_email='t3elmar@gmail.com',
2929
license='MIT',
3030
packages=['challenges', 'HelloWorld'],
31-
package_data={ 'HelloWorld': ['sample.txt', 'result.txt'], },
31+
package_data={
32+
'HelloWorld': ['sample.txt', 'result.txt'],
33+
'challenges': ['version.txt'],
34+
},
3235
include_package_data=True,
3336
entry_points={
3437
'console_scripts': [
3538
'challenge=challenges.main:main',
3639
'stepik=challenges.main:main',
3740
],
3841
},
42+
scripts=['bin/challenge'],
3943
classifiers=[
4044
'Development Status :: 3 - Alpha',
4145
'Environment :: Console',

version.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
0.1.0
2-
1+
0.1.2

0 commit comments

Comments
 (0)