summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/__init__.py2
-rw-r--r--setuptools/command/upload.py23
2 files changed, 24 insertions, 1 deletions
diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py
index f6dbc39c..3fb2f6df 100644
--- a/setuptools/command/__init__.py
+++ b/setuptools/command/__init__.py
@@ -2,7 +2,7 @@ __all__ = [
'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop',
'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts',
'sdist', 'setopt', 'test', 'install_egg_info', 'install_scripts',
- 'register', 'bdist_wininst', 'upload_docs',
+ 'register', 'bdist_wininst', 'upload_docs', 'upload',
]
from distutils.command.bdist import bdist
diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py
new file mode 100644
index 00000000..08c20ba8
--- /dev/null
+++ b/setuptools/command/upload.py
@@ -0,0 +1,23 @@
+from distutils.command import upload as orig
+
+
+class upload(orig.upload):
+ """
+ Override default upload behavior to look up password
+ in the keyring if available.
+ """
+
+ def finalize_options(self):
+ orig.upload.finalize_options(self)
+ self.password or self._load_password_from_keyring()
+
+ def _load_password_from_keyring(self):
+ """
+ Attempt to load password from keyring. Suppress Exceptions.
+ """
+ try:
+ keyring = __import__('keyring')
+ self.password = keyring.get_password(self.repository,
+ self.username)
+ except Exception:
+ pass