Skip to content

Commit

Permalink
2.0.9 release
Browse files Browse the repository at this point in the history
2.0.9 release
  • Loading branch information
harelba authored Feb 8, 2020
2 parents a603ab6 + 9605f98 commit 6293fe2
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 206 deletions.
149 changes: 136 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,137 @@
language: python
python:
- "2.7"
- "3.6"
matrix:
sudo: false

stages:
- integration
- release

env:
global:
- CACHE_NAME=${TRAVIS_JOB_NAME}


_commands_provider:

_test: &_test make test

_lint: &_lint make lint

_release: &_release make local-release

_install_requirements: &_install_requirements make dep

# https://ttcshelbyville.wordpress.com/2012/12/19/disable-remote-differential-compression-form-the-command-line/
_disable_windows_compression: &_disable_windows_compression "powershell Disable-WindowsOptionalFeature -Online -FeatureName MSRDC-Infrastructure"

# https://travis-ci.community/t/yarn-network-troubles/333/7
_disable_windows_defender: &_disable_windows_defender "powershell Set-MpPreference -DisableRealtimeMonitoring \\$true"


_steps_provider:

_test: &_step_test

install:
- *_install_requirements
before_script: *_lint
script: *_test

_release: &_step_release

install: *_install_requirements
script: *_release



jobs:
include:
- python: "3.7"
dist: xenial # Need for python 3.7
allow_failures:
- python: "3.6"
- python: "3.7"
install: pip install -r requirements.txt
before_script: flake8 ./bin/q ./test/test-suite --count --select=E901,E999,F821,F822,F823 --show-source --statistics
script: test/test-all

- stage: integration
name: py27-macos
os: osx
language: generic
osx_image: xcode7.3
env:
- PYENV_VERSION=2.7.14
before_install: source setup-pyenv.sh
<<: *_step_test
cache:
directories:
- ${HOME}/.pyenv_cache

- stage: integration
name: py36-macos
os: osx
language: generic
osx_image: xcode7.3
env:
- PYENV_VERSION=3.6.4
before_install: source setup-pyenv.sh
<<: *_step_test
cache:
directories:
- ${HOME}/.pyenv_cache

- stage: integration
name: py37-macos
os: osx
language: generic
osx_image: xcode7.3
env:
- PYENV_VERSION=3.7.3
before_install: source setup-pyenv.sh
<<: *_step_test
cache:
directories:
- ${HOME}/.pyenv_cache

- stage: integration
name: py27-linux
language: python
python: "2.7"
<<: *_step_test

- stage: integration
name: py36-linux
language: python
python: "3.6"
<<: *_step_test

- stage: integration
name: py37-linux
language: python
dist: xenial
python: "3.7"
<<: *_step_test

- stage: release
name: macos
os: osx
language: generic
osx_image: xcode7.3
env:
- PYENV_VERSION=3.7.3
before_install: source setup-pyenv.sh
<<: *_step_release
cache:
directories:
- ${HOME}/.pyenv_cache

- stage: release
name: linux
language: python
dist: xenial
python: "3.7"
<<: *_step_release

- stage: release
name: windows
os: windows
language: shell
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
before_install:
- *_disable_windows_compression
- *_disable_windows_defender
- choco install make
- choco install python --version 3.7.3
<<: *_step_release
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SHELL := /bin/bash

PROJECT_NAME=$(shell dirname "$0")
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

.PHONY: test help
.DEFAULT_GOAL := ci

ci: lint test ## Equivelant to 'make lint test'

help: ## Show this help message.

@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

dep: ## Install the dependent libraries.

pip install -r test-requirements.txt
pip install -e .

lint: dep ## Run lint validations.

flake8 q/ --count --select=E901,E999,F821,F822,F823 --show-source --statistics

test: dep ## Run the unit tests.

test/test-all
## TODO Bring back pytest
## py.test -rs -c pytest.ini -s -v q/tests/suite.py --rootdir .

release: ## Run release
pip install py-ci
pyci release --no-wheel-publish --wheel-universal

local-release:
pip install py-ci
./do-manual-release.sh

5 changes: 3 additions & 2 deletions bin/q → bin/q.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from __future__ import division
from __future__ import print_function

q_version = "2.0.6"
q_version = "2.0.9"

__all__ = [ 'QTextAsData' ]

Expand Down Expand Up @@ -1143,7 +1143,8 @@ def determine_max_col_lengths(m,output_field_quoting_func,output_delimiter):

def print_credentials():
print("q version %s" % q_version, file=sys.stderr)
print("Copyright (C) 2012-2017 Harel Ben-Attia ([email protected], @harelba on twitter)", file=sys.stderr)
print("Python: %s" % " // ".join([str(x).strip() for x in sys.version.split("\n")]), file=sys.stderr)
print("Copyright (C) 2012-2019 Harel Ben-Attia ([email protected], @harelba on twitter)", file=sys.stderr)
print("http://harelba.github.io/q/", file=sys.stderr)
print(file=sys.stderr)

Expand Down
29 changes: 29 additions & 0 deletions do-manual-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash -x

set -e

VERSION=2.0.9

echo "Packing binary for $TRAVIS_OS_NAME"

if [[ "$TRAVIS_OS_NAME" == "osx" || "$TRAVIS_OS_NAME" == "linux" ]]
then
echo "Packing $TRAVIS_OS_NAME installer - packing binary"
pyci pack binary
echo "Packing $TRAVIS_OS_NAME installer - uploading"
pyci github upload-asset --asset q-$(uname -m)-$(uname -s) --release $VERSION
else
echo "Packing windows installer - packing binary"
pyci pack binary
echo "Packing windows installer - listing files"
find `pwd` -ls | grep -v \.git/
echo "Packing windows installer - packing nsis"
BINARY_LOCATION="c:\\Users\\travis\\build\\harelba\\q\\q-AMD64-Windows.exe"
pyci pack nsis --program-files-dir q-TextAsData --binary-path $BINARY_LOCATION --version ${VERSION}.0
echo "Packing windows installer - uploading"
pyci github upload-asset --asset $BINARY_LOCATION --release $VERSION
SETUP_LOCATION="c:\\Users\\travis\\build\\harelba\\q\\q-AMD64-Windows-installer.exe"
pyci github upload-asset --asset $SETUP_LOCATION --release $VERSION
fi

echo "done"
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
log_print = True
134 changes: 134 additions & 0 deletions setup-pyenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env bash
# NOTE: This script needs to be sourced so it can modify the environment.
#
# Environment variables that can be set:
# - PYENV_VERSION
# Python to install [required]
# - PYENV_VERSION_STRING
# String to `grep -F` against the output of `python --version` to validate
# that the correct Python was installed (recommended) [default: none]
# - PYENV_ROOT
# Directory in which to install pyenv [default: ~/.travis-pyenv]
# - PYENV_RELEASE
# Release tag of pyenv to download [default: clone from master]
# - PYENV_CACHE_PATH
# Directory where full Python builds are cached (i.e., for Travis)

# PYENV_ROOT is exported because pyenv uses it
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.travis-pyenv}"
export PYTHON_CONFIGURE_OPTS="--enable-shared"
PYENV_CACHE_PATH="${PYENV_CACHE_PATH:-$HOME/.pyenv_cache}"
version_cache_path="$PYENV_CACHE_PATH/$PYENV_VERSION"
version_pyenv_path="$PYENV_ROOT/versions/$PYENV_VERSION"

# Functions
#
# verify_python -- attempts to call the Python command or binary
# supplied in the first argument with the --version flag. If
# PYENV_VERSION_STRING is set, then it validates the returned version string
# as well (using grep -F). Returns whatever status code the command returns.
verify_python() {
local python_bin="$1"; shift

if [[ -n "$PYENV_VERSION_STRING" ]]; then
"$python_bin" --version 2>&1 | grep -F "$PYENV_VERSION_STRING" &>/dev/null
else
"$python_bin" --version &>/dev/null
fi
}

# use_cached_python -- Tries symlinking to the cached PYENV_VERSION and
# verifying that it's a working build. Returns 0 if it's found and it
# verifies, otherwise returns 1.
use_cached_python() {
if [[ -d "$version_cache_path" ]]; then
printf "Cached python found, %s. Verifying..." "$PYENV_VERSION"
ln -s "$version_cache_path" "$version_pyenv_path"
if verify_python "$version_pyenv_path/bin/python"; then
printf "success!\n"
return 0
else
printf "FAILED.\nClearing cached version..."
rm -f "$version_pyenv_path"
rm -rf "$version_cache_path"
printf "done.\n"
return 1
fi
else
echo "No cached python found."
return 1
fi
}

# output_debugging_info -- Outputs useful debugging information
output_debugging_info() {
echo "**** Debugging information"
printf "PYENV_VERSION\n%s\n" "$PYENV_VERSION"
printf "PYENV_VERSION_STRING\n%s\n" "$PYENV_VERSION_STRING"
printf "PYENV_CACHE_PATH\n%s\n" "$PYENV_CACHE_PATH"
set -x
python --version
"$version_cache_path/bin/python" --version
which python
pyenv which python
set +x
}

# Main script begins.

if [[ -z "$PYENV_VERSION" ]]; then
echo "PYENV_VERSION is not set. Not installing a pyenv."
return 0
fi

# Get out of the virtualenv we're in (if we're in one).
[[ -z "$VIRTUAL_ENV" ]] || deactivate

# Install pyenv
echo "**** Installing pyenv."
if [[ -n "$PYENV_RELEASE" ]]; then
# Fetch the release archive from Github (slightly faster than cloning)
mkdir "$PYENV_ROOT"
curl -fsSL "https://github.com/yyuu/pyenv/archive/$PYENV_RELEASE.tar.gz" \
| tar -xz -C "$PYENV_ROOT" --strip-components 1
else
# Don't have a release to fetch, so just clone directly
git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
fi

export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Make sure the cache directory exists
mkdir -p "$PYENV_CACHE_PATH"

# Try using an already cached PYENV_VERSION. If it fails or is not found,
# then install from scratch.
echo "**** Trying to find and use cached python $PYENV_VERSION."
if ! use_cached_python; then
echo "**** Installing python $PYENV_VERSION with pyenv now."
if pyenv install "$PYENV_VERSION"; then
if mv "$version_pyenv_path" "$PYENV_CACHE_PATH"; then
echo "Python was successfully built and moved to cache."
echo "**** Trying to find and use cached python $PYENV_VERSION."
if ! use_cached_python; then
echo "Python version $PYENV_VERSION was apparently successfully built"
echo "with pyenv, but, once cached, it could not be verified."
output_debugging_info
return 1
fi
else
echo "**** Warning: Python was succesfully built, but moving to cache"
echo "failed. Proceeding anyway without caching."
fi
else
echo "Python version $PYENV_VERSION build FAILED."
return 1
fi
fi

# Now we have to reinitialize pyenv, as we need the shims etc to be created so
# the pyenv activates correctly.
echo "**** Activating python $PYENV_VERSION and generating new virtualenv."
eval "$(pyenv init -)"
pyenv global "$PYENV_VERSION"
Loading

0 comments on commit 6293fe2

Please sign in to comment.