Skip to content

Commit e798a57

Browse files
authored
snap: 0.x: prevent user site package conflicts (#3879)
* snap: restrict site-package checks Fixes #3514 * debug commit * sync master, revert debug
1 parent c5bac1c commit e798a57

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ jobs:
106106
- sudo /snap/bin/lxd.migrate -yes
107107
- sudo /snap/bin/lxd waitready
108108
- sudo /snap/bin/lxd init --auto
109+
- git fetch --tags
109110
script:
110111
- ./scripts/build_snap.sh
111112
after_failure:

scripts/ci/before_install.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
echo >env.sh
1717

18-
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]]; then
18+
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "test" ]]; then
1919
if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
2020
# NOTE: ssh keys for ssh test to be able to ssh to the localhost
2121
ssh-keygen -t rsa -N "" -f mykey
@@ -52,7 +52,11 @@ elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
5252
fi
5353

5454
if [[ -n "$TRAVIS_TAG" ]]; then
55-
echo "export SNAP_CHANNEL=stable" >>env.sh
55+
if [[ $(echo "$TRAVIS_TAG" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$') ]]; then
56+
echo "export SNAP_CHANNEL=stable" >>env.sh
57+
else
58+
echo "export SNAP_CHANNEL=beta" >>env.sh
59+
fi
5660
else
5761
echo "export SNAP_CHANNEL=edge" >>env.sh
5862
fi

snap/snapcraft.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ parts:
2929
- git
3030
override-pull: |
3131
snapcraftctl pull
32-
snapcraftctl set-version `cd $SNAPCRAFT_PART_SRC && git describe --tags`
32+
snapcraftctl set-version $(cd $SNAPCRAFT_PART_SRC && git describe --tags)
3333
git diff --quiet || error_dirty_build
3434
echo 'PKG = "snap"' > $SNAPCRAFT_PART_SRC/dvc/utils/build.py
3535
# install all optional extras
@@ -38,6 +38,9 @@ parts:
3838
sed -rin 's/.*git.*diff.*--quiet.*//' $SNAPCRAFT_PART_SRC/dvc/version.py
3939
override-build: |
4040
snapcraftctl build
41+
# prevent user site packages interfering with this snap - reference:
42+
# https://github.com/snapcore/snapcraft/blob/19393ef36cd773a28131cec10cc0bfb3bf9c7e77/tools/snapcraft-override-build.sh#L18
43+
sed -ri 's/^(ENABLE_USER_SITE = )None$/\1False/' $SNAPCRAFT_PART_INSTALL/usr/lib/python*/site.py
4144
cp $SNAPCRAFT_PART_BUILD/scripts/completion/dvc.bash $SNAPCRAFT_PART_INSTALL/completion.sh
4245
apps:
4346
dvc:

0 commit comments

Comments
 (0)