From 24020f9172af32d49671a3bcbc9a068ecb1a6765 Mon Sep 17 00:00:00 2001 From: Manu Phatak Date: Fri, 1 Jan 2016 16:12:19 -0600 Subject: [PATCH] update requirements --- .requirements.diff | 57 +++++++++++++++------ requirements_dev.in | 7 --- requirements_dev.txt | 13 +---- travis_pypi_setup.py | 119 ------------------------------------------- 4 files changed, 43 insertions(+), 153 deletions(-) delete mode 100755 travis_pypi_setup.py diff --git a/.requirements.diff b/.requirements.diff index c785ade..7943a27 100644 --- a/.requirements.diff +++ b/.requirements.diff @@ -1,24 +1,49 @@ diff --git i/requirements_dev.txt w/requirements_dev.txt -index 13adb71..e2087c6 100644 +index e2087c6..f4a1c4e 100644 --- i/requirements_dev.txt +++ w/requirements_dev.txt -@@ -24,8 +24,10 @@ ipython==4.0.1 # via ipdb - jinja2==2.8 # via sphinx - markupsafe==0.23 # via jinja2 - mccabe==0.3.1 # via flake8 -+mock==1.3.0 - path.py==8.1.2 # via pickleshare - pathtools==0.1.2 # via watchdog -+pbr==1.8.1 # via mock - pep8==1.5.7 # via flake8 - pexpect==4.0.1 # via ipython - pickleshare==0.5 # via ipython -@@ -43,7 +45,7 @@ pytz==2015.7 # via babel - pyyaml==3.11 +@@ -8,16 +8,13 @@ alabaster==0.7.7 # via sphinx + argh==0.26.1 # via watchdog + babel==2.1.1 # via sphinx + bumpversion==0.5.3 +-cffi==1.4.2 # via cryptography + click==6.2 # via pip-tools + coverage==4.0.3 +-cryptography==1.1.2 + decorator==4.0.6 # via ipython, traitlets + docutils==0.12 # via restructuredtext-lint, sphinx + first==2.0.1 # via pip-tools + flake8==2.5.1 + future==0.15.2 +-idna==2.0 # via cryptography + ipdb==0.8.1 + ipython-genutils==0.1.0 # via traitlets + ipython==4.0.1 # via ipdb +@@ -35,17 +32,15 @@ pip-tools==1.4.2 + pluggy==0.3.1 # via tox + ptyprocess==0.5 # via pexpect + py==1.4.31 # via pytest, tox +-pyasn1==0.1.9 # via cryptography +-pycparser==2.14 # via cffi + pyflakes==1.0.0 # via flake8 + pygments==2.0.2 # via sphinx + pytest-mock==0.9.0 + pytest==2.8.5 + pytz==2015.7 # via babel +-pyyaml==3.11 ++pyyaml==3.11 # via watchdog restructuredtext-lint==0.14.0 simplegeneric==0.8.1 # via ipython --six==1.10.0 # via cryptography, pip-tools, sphinx -+six==1.10.0 # via cryptography, mock, pip-tools, sphinx +-six==1.10.0 # via cryptography, mock, pip-tools, sphinx ++six==1.10.0 # via mock, pip-tools, sphinx snowballstemmer==1.2.1 # via sphinx sphinx-rtd-theme==0.1.9 # via sphinx sphinx==1.3.3 +@@ -54,7 +49,3 @@ traitlets==4.0.0 # via ipython + virtualenv==13.1.2 # via tox + watchdog==0.8.3 + wheel==0.26.0 +- +-# The following packages are commented out because they are +-# considered to be unsafe in a requirements file: +-# setuptools==19.2 # via cryptography diff --git a/requirements_dev.in b/requirements_dev.in index 7f47331..0db7a0d 100644 --- a/requirements_dev.in +++ b/requirements_dev.in @@ -27,13 +27,6 @@ sphinx watchdog restructuredtext_lint -# DIST UTILITIES -# ------------------------------------- -# required by `travis_pypi_setup.py` -cryptography -PyYAML - - # DEV UTILITIES (Your stuff here) # ------------------------------------- ipdb diff --git a/requirements_dev.txt b/requirements_dev.txt index e2087c6..f4a1c4e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,16 +8,13 @@ alabaster==0.7.7 # via sphinx argh==0.26.1 # via watchdog babel==2.1.1 # via sphinx bumpversion==0.5.3 -cffi==1.4.2 # via cryptography click==6.2 # via pip-tools coverage==4.0.3 -cryptography==1.1.2 decorator==4.0.6 # via ipython, traitlets docutils==0.12 # via restructuredtext-lint, sphinx first==2.0.1 # via pip-tools flake8==2.5.1 future==0.15.2 -idna==2.0 # via cryptography ipdb==0.8.1 ipython-genutils==0.1.0 # via traitlets ipython==4.0.1 # via ipdb @@ -35,17 +32,15 @@ pip-tools==1.4.2 pluggy==0.3.1 # via tox ptyprocess==0.5 # via pexpect py==1.4.31 # via pytest, tox -pyasn1==0.1.9 # via cryptography -pycparser==2.14 # via cffi pyflakes==1.0.0 # via flake8 pygments==2.0.2 # via sphinx pytest-mock==0.9.0 pytest==2.8.5 pytz==2015.7 # via babel -pyyaml==3.11 +pyyaml==3.11 # via watchdog restructuredtext-lint==0.14.0 simplegeneric==0.8.1 # via ipython -six==1.10.0 # via cryptography, mock, pip-tools, sphinx +six==1.10.0 # via mock, pip-tools, sphinx snowballstemmer==1.2.1 # via sphinx sphinx-rtd-theme==0.1.9 # via sphinx sphinx==1.3.3 @@ -54,7 +49,3 @@ traitlets==4.0.0 # via ipython virtualenv==13.1.2 # via tox watchdog==0.8.3 wheel==0.26.0 - -# The following packages are commented out because they are -# considered to be unsafe in a requirements file: -# setuptools==19.2 # via cryptography diff --git a/travis_pypi_setup.py b/travis_pypi_setup.py deleted file mode 100755 index 1ae8be5..0000000 --- a/travis_pypi_setup.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -""" -Update encrypted deploy password in Travis config file -""" - -from __future__ import print_function -import base64 -import json -import os -from getpass import getpass -import yaml -from cryptography.hazmat.primitives.serialization import load_pem_public_key -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 - -try: - from urllib import urlopen -except ImportError: - # noinspection PyCompatibility - from urllib.request import urlopen - -GITHUB_REPO = 'bionikspoon/json_config' -TRAVIS_CONFIG_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '.travis.yml') - - -def load_key(pubkey): - """Load public RSA key, with work-around for keys using - incorrect header/footer format. - - Read more about RSA encryption with cryptography: - https://cryptography.io/latest/hazmat/primitives/asymmetric/rsa/ - """ - try: - return load_pem_public_key(pubkey.encode(), default_backend()) - except ValueError: - # workaround for https://github.com/travis-ci/travis-api/issues/196 - pubkey = pubkey.replace('BEGIN RSA', 'BEGIN').replace('END RSA', 'END') - return load_pem_public_key(pubkey.encode(), default_backend()) - - -def encrypt(pubkey, password): - """Encrypt password using given RSA public key and encode it with base64. - - The encrypted password can only be decrypted by someone with the - private key (in this case, only Travis). - """ - key = load_key(pubkey) - encrypted_password = key.encrypt(password, PKCS1v15()) - return base64.b64encode(encrypted_password) - - -def fetch_public_key(repo): - """Download RSA public key Travis will use for this repo. - - Travis API docs: http://docs.travis-ci.com/api/#repository-keys - """ - keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo) - data = json.loads(urlopen(keyurl).read().decode()) - if 'key' not in data: - errmsg = "Could not find public key for repo: {}.\n".format(repo) - errmsg += "Have you already added your GitHub repo to Travis?" - raise ValueError(errmsg) - return data['key'] - - -def prepend_line(filepath, line): - """Rewrite a file adding a line to its beginning. - """ - with open(filepath) as f: - lines = f.readlines() - - lines.insert(0, line) - - with open(filepath, 'w') as f: - f.writelines(lines) - - -def load_yaml_config(filepath): - with open(filepath) as f: - return yaml.load(f) - - -def save_yaml_config(filepath, config): - with open(filepath, 'w') as f: - yaml.dump(config, f, default_flow_style=False) - - -def update_travis_deploy_password(encrypted_password): - """Update the deploy section of the .travis.yml file - to use the given encrypted password. - """ - config = load_yaml_config(TRAVIS_CONFIG_FILE) - - config['deploy']['password'] = dict(secure=encrypted_password) - - save_yaml_config(TRAVIS_CONFIG_FILE, config) - - line = ('# This file was autogenerated and will overwrite' - ' each time you run travis_pypi_setup.py\n') - prepend_line(TRAVIS_CONFIG_FILE, line) - - -def main(args): - public_key = fetch_public_key(args.repo) - password = args.password or getpass('PyPI password: ') - update_travis_deploy_password(encrypt(public_key, password.encode())) - print("Wrote encrypted password to .travis.yml -- you're ready to deploy") - - -if '__main__' == __name__: - import argparse - - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--repo', default=GITHUB_REPO, help='GitHub repo (default: %s)' % GITHUB_REPO) - parser.add_argument('--password', help='PyPI password (will prompt if not provided)') - - args = parser.parse_args() - main(args)