Skip to content

Commit 7a316bb

Browse files
committed
travis-ci: fix packaging-trusty.sh issues
1 parent 9d67569 commit 7a316bb

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ matrix:
1717
include:
1818
- python: 3.6
1919
env: TOXENV=lint,docs
20-
- python: 3.6
20+
- python: 2.7
2121
script: ./tests/integration/packaging-trusty.sh
2222
- python: 3.6
2323
install: python setup.py install

compdb/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def _format_action(self, action):
427427

428428

429429
def term_columns():
430-
columns = 80
430+
columns = 0
431431

432432
try:
433433
# can happens in tests, when we redirect sys.stdout to a StringIO
@@ -449,7 +449,9 @@ def term_columns():
449449
struct.pack('HHHH', 0, 0, 0, 0)))[1]
450450
except (ImportError, IOError):
451451
pass
452-
return columns
452+
if columns > 0:
453+
return columns
454+
return 80
453455

454456

455457
def _wrap_paragraphs(text, max_width=None):
@@ -518,7 +520,8 @@ def main(argv=None):
518520

519521
command_description = textwrap.dedent("""
520522
description:
521-
""") + _wrap_paragraphs(command_description, 120)
523+
""") + _wrap_paragraphs(
524+
command_description, max_width=120)
522525

523526
subparser = subparsers.add_parser(
524527
command_cls.name,

tests/integration/packaging-trusty.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/bash
22

33
# This script tests the packaging of compdb on Ubuntu Trusty.
4-
# It has been made to run on Travis CI and locally on Ubuntu 14.04,
5-
# or locally inside docker thanks to docker/ubuntu-trusty.sh.
4+
5+
# It has been made to run on Travis CI and inside docker image of Ubuntu 14.04.
6+
# For the docker image, one can use docker/ubuntu-trusty.sh.
7+
# At this time it is not recommended to run this locally
8+
# because files are created in the user home directory.
69
# The dependencies can be found in docker/ubuntu-trusty/Dockerfile.
710

811
if [[ ! -f compdb/__init__.py ]]; then
@@ -13,6 +16,26 @@ fi
1316
set -o errexit
1417
set -o xtrace
1518

19+
# Initial goal for this script was to run in a "pristine" Ubuntu Trusty,
20+
# with a stock installation of python,
21+
# unfortunately Travis CI uses isolated virtualenvs:
22+
# - https://docs.travis-ci.com/user/languages/python/#Travis-CI-Uses-Isolated-virtualenvs
23+
#
24+
# This means, one has to accomodate the 'pip install' commands
25+
# to not use the --user options when run under virtualenv.
26+
# Doing otherwise, triggers the following error:
27+
# $ pip install --user .
28+
# Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
29+
#
30+
# virtualenv detection logic copied from pip:
31+
# - https://github.com/pypa/pip/blob/ccd75d4daf7753b6587cffbb1ba52e7dfa5e9915/pip/locations.py#L41-L51
32+
USER_OPTS=""
33+
if python -c 'import sys; sys.exit(hasattr(sys, "real_prefix"))' ||
34+
python -c 'import sys; sys.exit(sys.prefix != getattr(sys, "base_prefix", sys.prefix))'
35+
then
36+
USER_OPTS="--user"
37+
fi
38+
1639
# First generate release files to ~/dist
1740
virtualenv .venv
1841
source .venv/bin/activate
@@ -25,13 +48,18 @@ rm -r .venv
2548

2649
# Install from source
2750
mkdir ~/userbase
28-
PYTHONUSERBASE=~/userbase python setup.py install --user
29-
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
51+
env PYTHONPATH=$(PYTHONUSERBASE=~/userbase python -m site --user-site) \
52+
PYTHONUSERBASE=~/userbase \
53+
python setup.py install --user
54+
env PYTHONPATH=$(PYTHONUSERBASE=~/userbase python -m site --user-site) \
55+
PYTHONUSERBASE=~/userbase \
56+
PATH="$HOME/userbase/bin:$PATH" \
57+
compdb version
3058
rm -r ~/userbase
3159

3260
# Install from source with pip
3361
mkdir ~/userbase
34-
PYTHONUSERBASE=~/userbase pip install --user .
62+
PYTHONUSERBASE=~/userbase pip install ${USER_OPTS} .
3563
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
3664
rm -r ~/userbase
3765

@@ -48,7 +76,7 @@ rm -r .venv
4876

4977
# Wheel
5078
mkdir ~/userbase
51-
PYTHONUSERBASE=~/userbase pip install --user ~/dist/compdb-*.whl
79+
PYTHONUSERBASE=~/userbase pip install ${USER_OPTS} ~/dist/compdb-*.whl
5280
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
5381
rm -r ~/userbase
5482

@@ -66,7 +94,7 @@ rm -r .venv
6694

6795
# pip install source distribution
6896
mkdir ~/userbase
69-
PYTHONUSERBASE=~/userbase pip install --user ~/dist/compdb-*.tar.gz
97+
PYTHONUSERBASE=~/userbase pip install ${USER_OPTS} ~/dist/compdb-*.tar.gz
7098
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
7199
rm -r ~/userbase
72100

0 commit comments

Comments
 (0)