Skip to content

Add test, username and password options to upload command. #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ class UploadCommand(Command):
"""Support setup.py upload."""

description = 'Build and publish the package.'
user_options = []
user_options = [
('test', None, 'Upload the package to PyPI test mirror.'),
('username=', None, 'Specify the username used uploading to PyPI.'),
('password=', None, 'Specify the password used uploading to PyPI.'),
]

@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))

def initialize_options(self):
pass
self.username = None
self.password = None
self.test = None

def finalize_options(self):
pass
Expand All @@ -83,7 +89,13 @@ def run(self):
os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))

self.status('Uploading the package to PyPI via Twine…')
os.system('twine upload dist/*')
cmd = 'twine upload%s%s%s dist/*' % (
' --repository-url https://test.pypi.org/legacy/'
if self.test else ',
' --password %s' % self.password if self.password else ',
' --username %s' % self.username if self.username else ',
)
os.system(cmd)

self.status('Pushing git tags…')
os.system('git tag v{0}'.format(about['__version__']))
Expand All @@ -103,7 +115,7 @@ def run(self):
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
packages=find_packages(exclude=['tests', '*.tests', '*.tests.*', 'tests.*']),
# If your package is a single module, use this instead of 'packages':
# py_modules=['mypackage'],

Expand Down