Skip to content

Commit 06f3664

Browse files
committed
Added .pypirc support for uploading to PyPI with twine
1 parent 11d98bf commit 06f3664

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

pypi.sh

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,36 +59,62 @@
5959
# GROUP BY DATE(timestamp)
6060
# )
6161
# ORDER BY date
62-
#
6362

63+
###############
64+
# Functions #
65+
###############
6466

65-
rm -rf dist
66-
python3 -m build --sdist --wheel
67+
upload_test_pypi()
68+
{
69+
# Upload to Test PyPi
70+
if ! [ -f $HOME/.pypirc ]; then
71+
# .pypirc file does not exist, prompt for API token
72+
twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/*
73+
else
74+
# Get API token from .pypirc file
75+
twine upload --verbose -r testpypi dist/*
76+
fi
77+
}
78+
79+
upload_pypi()
80+
{
81+
# Upload to PyPi
82+
if ! [ -f $HOME/.pypirc ]; then
83+
# .pypirc file does not exist, prompt for API token
84+
twine upload dist/*
85+
else
86+
# Get API token from .pypirc file
87+
twine upload -r pypi dist/*
88+
fi
89+
}
6790

6891
# Use API Token instead of username+password
6992
# https://pypi.org/help/#apitoken
7093
# Place the API Token(s) in your $HOME/.pypirc
94+
#
95+
# # Example .pypirc file
96+
#
7197
# [distutils]
7298
# index-servers =
7399
# pypi
74100
# testpypi
75-
#
101+
#
76102
# [pypi]
77103
# repository = https://upload.pypi.org/legacy/
78104
# username = __token__
79105
# password = <PyPI API Token>
80-
#
106+
#
81107
# [testpypi]
82108
# repository = https://test.pypi.org/legacy/
83109
# username = __token__
84110
# password = <Test PyPI API Token>
85111

86-
# Upload to Test PyPi
87-
# (OLD) twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/*
88-
twine upload --verbose -r testpypi dist/*
89-
90-
# Upload to PyPI
91-
# (OLD) twine upload dist/*
92-
# twine upload -r pypi dist/*
112+
###########
113+
# Main #
114+
###########
93115

116+
rm -rf dist
117+
python3 -m build --sdist --wheel
118+
upload_test_pypi
119+
# upload_pypi
94120
rm -rf build dist stumpy.egg-info

0 commit comments

Comments
 (0)