Skip to content

Commit bcf756e

Browse files
committed
Update setup.py for easier and safer deploys to PyPI
1 parent 0de8df0 commit bcf756e

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

setup.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,45 @@
44
"""
55

66
from setuptools import setup, find_packages # noqa
7-
from os import path
7+
import os
8+
import sys
89

910

10-
this_directory = path.abspath(path.dirname(__file__))
11+
this_directory = os.path.abspath(os.path.dirname(__file__))
1112
long_description = None
1213
try:
13-
with open(path.join(this_directory, 'README.md'), 'rb') as f:
14+
with open(os.path.join(this_directory, 'README.md'), 'rb') as f:
1415
long_description = f.read().decode('utf-8')
1516
except IOError:
1617
long_description = 'Reliable Browser Automation & Testing Framework'
1718

19+
if sys.argv[-1] == 'publish':
20+
reply = None
21+
input_method = input
22+
if not sys.version_info[0] >= 3:
23+
input_method = raw_input # noqa
24+
reply = str(input_method(
25+
'>>> Confirm release PUBLISH to PyPI? (yes/no): ')).lower().strip()
26+
if reply == 'yes':
27+
print("\n*** Checking code health with flake8:\n")
28+
flake8_status = os.system("flake8 --exclude=temp")
29+
if flake8_status != 0:
30+
print("\nWARNING! Fix flake8 issues before publishing to PyPI!\n")
31+
sys.exit()
32+
else:
33+
print("*** No flake8 issues detected. Continuing...")
34+
print("\n*** Rebuilding distribution packages: ***\n")
35+
os.system('rm -f dist/*.egg; rm -f dist/*.tar.gz; rm -f dist/*.whl')
36+
os.system('python setup.py sdist bdist_wheel') # Create new tar/wheel
37+
print("\n*** Installing twine: *** (Required for PyPI uploads)\n")
38+
os.system("python -m pip install 'twine>=1.14.0'")
39+
print("\n*** Publishing The Release to PyPI: ***\n")
40+
os.system('python -m twine upload dist/*') # Requires ~/.pypirc Keys
41+
print("\n*** The Release was PUBLISHED SUCCESSFULLY to PyPI! :) ***\n")
42+
else:
43+
print("\n>>> The Release was NOT PUBLISHED to PyPI! <<<\n")
44+
sys.exit()
45+
1846
setup(
1947
name='seleniumbase',
2048
version='1.31.5',

0 commit comments

Comments
 (0)