diff --git a/.travis.yml b/.travis.yml index dfa53b8..fd8fed4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +# build: 2 # increase this to trigger a new build + language: python python: 3.5 sudo: required @@ -8,16 +10,17 @@ osx_image: xcode6.4 env: global: - REPO_DIR=psutil + # This is the psutil GIT cset. # Remember to edit appveyor.yml too # Also see DAILY_COMMIT below - - BUILD_COMMIT=c4c6e22ca4dad687d2a8505f9e0207d8ecd64358 + - BUILD_COMMIT=95c202caf90b294ac558844a6464ae6bb7f84117 - PLAT=x86_64 - WHEELHOUSE_UPLOADER_USERNAME=travis-worker - BUILD_DEPENDS= - TEST_DEPENDS= # Following generated with - # travis encrypt -r MacPython/psutil-wheels WHEELHOUSE_UPLOADER_SECRET= - - secure: "TShPxjfYrHIYrf8CcdCfxrUNNCNcajUIiwwN9vd0xa1pnriwBnEiOGsBibYXPHDTtPx936DUfJXpsHuDcWYu023HNv9N7djZpNO1fI++tTCKFQahwln+wnIa/EzEOPK3EqyjmBR5i4Q1EU0LsKP3mNDdfAg5trpY23GTGPYQQto=" + # travis encrypt -r MacPython/psutil WHEELHOUSE_UPLOADER_SECRET= + - secure: "NOv97zrh+QRrGa+iFPtIcqaBBppbVfOIKJsbPKYzv1zcr45oipaSXHuSQdXVFHyi33iR6ygejXQuFOf61MWXsE0lJQd/k1892+Kz/ojEfrJuEknBNiw9N6mBKHXtV6vAaX5/d6ku9fS/IEDNR2XLetGnVL3GP9Kgpul0eYbBKgd4XU91tP/K2NKfrAXKpWIl3EsoHPdjIjVcrSLg+JXzUyCAke+YG4g9igAzSPmE6DgKkQG4nVX/kvYCc3Yf5MQsZdPVH16gvhw5qRgkeW2m8poujKbXNik3qa8oNAfGzYZ98khjvYwKrhJVtMZ254Lw6C564EYwECAD/4J91oXJta9T+huXdgEf1tHo5P12h9NSSMneRrL3dr8i0py3wRX5G1iyvF5eX7NX03jRgFi81WSwLNiPnzKQvRfLAfB9Jwmg70FBz7X8Nc5HTzHMOWgobLsBySyodaEuHFzNlnUz5GA7kRXdCxRJ+RdQSsukQl6UBT2GcdyA3EWd1tgZ605Dxyxp2PKhnlw3AWRSdt3wKBk8GrOeBNm3sQgZ0PwrvNFoCMWjT+NneNyyDkZsI3pEOJWk87BRsYvdxwD1ged2Z2AYEMKICfGFvSoLsH2xY5CWl336a26eLnlyUPInImuk5Zn0eZFHDOXVQGVXRe6RVCebRMzm9ecqdOeiy/FiNJI=" # Commit when running from daily branch - DAILY_COMMIT=master @@ -27,77 +30,64 @@ matrix: - python: 3.5 include: - os: linux - env: - - MB_PYTHON_VERSION=2.6 - - os: linux - env: - - MB_PYTHON_VERSION=2.6 - - PLAT=i686 - - os: linux - env: - - MB_PYTHON_VERSION=2.7 - - os: linux - env: - - MB_PYTHON_VERSION=2.7 - - UNICODE_WIDTH=16 - - os: linux - env: - - MB_PYTHON_VERSION=2.7 - - PLAT=i686 - - os: linux - env: - - MB_PYTHON_VERSION=2.7 - - PLAT=i686 - - UNICODE_WIDTH=16 - - os: linux - env: - - MB_PYTHON_VERSION=3.3 - - os: linux - env: - - MB_PYTHON_VERSION=3.3 - - PLAT=i686 - - os: linux - env: - - MB_PYTHON_VERSION=3.4 - - os: linux - env: - - MB_PYTHON_VERSION=3.4 - - PLAT=i686 - - os: linux - env: - - MB_PYTHON_VERSION=3.5 - - os: linux - env: - - MB_PYTHON_VERSION=3.5 - - PLAT=i686 - - os: linux - env: - - MB_PYTHON_VERSION=3.6 - - os: linux - env: - - MB_PYTHON_VERSION=3.6 - - PLAT=i686 - - os: osx - language: generic env: - MB_PYTHON_VERSION=2.7 + # - os: linux + # env: + # - MB_PYTHON_VERSION=2.7 + # - PLAT=i686 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.4 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.4 + # - PLAT=i686 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.5 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.5 + # - PLAT=i686 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.6 + # - os: linux + # env: + # - MB_PYTHON_VERSION=3.6 + # - PLAT=i686 + # - os: osx + # language: generic + # env: + # - SYS=OSX + # - MB_PYTHON_VERSION=2.7 + # - os: osx + # language: generic + # env: + # - SYS=OSX + # - PLAT=i686 + # - MB_PYTHON_VERSION=2.7 + # - os: osx + # language: generic + # env: + # - SYS=OSX + # - MB_PYTHON_VERSION=3.3 + # - os: osx + # language: generic + # env: + # - SYS=OSX + # - MB_PYTHON_VERSION=3.4 + # - os: osx + # language: generic + # env: + # - SYS=OSX + # - MB_PYTHON_VERSION=3.5 - os: osx language: generic env: - - MB_PYTHON_VERSION=3.3 - - os: osx - language: generic - env: - - MB_PYTHON_VERSION=3.4 - - os: osx - language: generic - env: - - MB_PYTHON_VERSION=3.5 - - os: osx - language: generic - env: + - SYS=OSX - MB_PYTHON_VERSION=3.6 - before_install: - if [ "$TRAVIS_BRANCH" == "daily" ]; then CONTAINER="pre-release"; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..784a1a3 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +PYTHON = python + +download-unix-wheels: ## download unix wheels + $(PYTHON) scripts/download_unix_wheels.py + +help: ## display callable targets + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' diff --git a/README.rst b/README.rst index 5ff7848..a0dd87c 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,12 @@ +.. image:: https://img.shields.io/travis/MacPython/psutil/master.svg?maxAge=3600&label=Linux%20/%20OSX + :target: https://travis-ci.org/MacPython/psutil + :alt: Linux / OSX (Travis) + ################## psutil wheel builder ################## -Repository to build psutil wheels. +Repository to build `psutil `__ wheels. By default the repo builds the latest tag (the tag on the branch most recently branched from master - see http://stackoverflow.com/a/24557377/1939576). If you @@ -16,8 +20,8 @@ want to build a specific commit: * git commit -The wheels get uploaded to a `rackspace container -`_ +The wheels get uploaded to a +`rackspace container `__ to which I have the API key. The API key is encrypted to this specific repo in the ``.travis.yml`` file, so the upload won't work for you from another account. Either contact me to get set up, or use another upload service such as diff --git a/config.sh b/config.sh index 016d3e7..044ca4b 100644 --- a/config.sh +++ b/config.sh @@ -4,8 +4,6 @@ if [ "$MB_PYTHON_VERSION" == '2.6' ]; then DEPENDS="ipaddress unittest2 argparse mock==1.0.1" elif [ $(lex_ver $MB_PYTHON_VERSION) -le $(lex_ver 3.2) ]; then DEPENDS="ipaddress mock" -elif [ "$MB_PYTHON_VERSION" == '3.3' ]; then - DEPENDS=ipaddress fi function pre_build { @@ -20,6 +18,21 @@ function run_tests { pip install $DEPENDS fi python --version - PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/__main__.py - PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_memory_leaks.py + pwd + ls -la + # if [ "$PYVER" == "2.7" ] || [ "$PYVER" == "3.6" ]; then + if [ "$MB_PYTHON_VERSION" == "2.7" ]; then + PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/__main__.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_process.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_system.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_connections.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_unicode.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_contracts.py + else + python -c "import psutil" + fi + + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/__main__.py + # PSUTIL_TESTING=1 python -Wa ../psutil/psutil/tests/test_memory_leaks.py } + diff --git a/scripts/download_unix_wheels.py b/scripts/download_unix_wheels.py new file mode 100644 index 0000000..cf0b6cf --- /dev/null +++ b/scripts/download_unix_wheels.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python + +from pprint import pprint as pp +import os +import re +import requests +import errno +import concurrent.futures + + +URL = "http://a365fff413fe338398b6-1c8a9b3114517dc5fe17b7c3f8c63a43.r19.cf2.rackcdn.com/" +TIMEOUT = 30 + + +def bytes2human(n): + """ + >>> bytes2human(10000) + '9.8 K' + >>> bytes2human(100001221) + '95.4 M' + """ + symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y') + prefix = {} + for i, s in enumerate(symbols): + prefix[s] = 1 << (i + 1) * 10 + for s in reversed(symbols): + if n >= prefix[s]: + value = float(n) / prefix[s] + return '%.2f %s' % (value, s) + return '%.2f B' % (n) + + +def safe_makedirs(path): + try: + os.makedirs(path) + except OSError as err: + if err.errno == errno.EEXIST: + if not os.path.isdir(path): + raise + else: + raise + +def get_most_recent(ls): + assert ls + ret = [] + ls.sort(reverse=False) # so that higher versions are listed first + ver = ls[0].split('-')[1] + for item in ls: + if item.split('-')[1] != ver: + break + else: + ret.append(item) + return ret + + +def download_file(url): + local_fname = url.split('/')[-1] + local_fname = os.path.join('dist', local_fname) + safe_makedirs('dist') + r = requests.get(url, stream=True, timeout=TIMEOUT) + with open(local_fname, 'wb') as f: + for chunk in r.iter_content(chunk_size=16384): + if chunk: # filter out keep-alive new chunks + f.write(chunk) + return local_fname + + +def parallel_wget(urls): + completed = 0 + with concurrent.futures.ThreadPoolExecutor() as e: + fut_to_url = {e.submit(download_file, url): url for url in urls} + for fut in concurrent.futures.as_completed(fut_to_url): + url = fut_to_url[fut] + try: + local_fname = fut.result() + except Exception as _: + exc = _ + print("error while downloading %s: %s" % (url, exc)) + else: + completed += 1 + print("downloaded %-10s %s" % ( + bytes2human(os.path.getsize(local_fname)), local_fname)) + return completed + + +def main(): + print("HTTP GET " + URL) + req = requests.get(URL) + req.raise_for_status() + ls = re.findall(r"\"psutil-.*\.whl\"", req.text) + print("found %s psutil-related files" % len(ls)) + ls = [x.strip('"') for x in ls] + ls = get_most_recent(ls) + print("getting the %s most recent versions" % len(ls)) + urls = [os.path.join(URL, x) for x in ls] + parallel_wget(urls) + + +main()