Skip to content

Commit 8371049

Browse files
committed
Conditionally write requirements.txt for snyk, only when travis runs tests for python 2.7
1 parent 0b15954 commit 8371049

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ before_install:
3636
if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then
3737
sudo apt-get install -y nodejs;
3838
npm install -g snyk;
39-
pip install -r requirements.txt;
4039
fi
4140
42-
install:
43-
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then snyk test --org=maxmind; fi
44-
4541
script:
4642
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then export MM_FORCE_EXT_TESTS=1; fi
4743
- CFLAGS="-Werror -Wall -Wextra" coverage run --source maxminddb setup.py test
44+
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then snyk test --org=maxmind --file=requirements.txt; fi
4845
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then pylint --rcfile .pylintrc maxminddb/*.py; fi
4946
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then ./.travis-yapf.sh; fi
5047

requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
if sys.version_info[0] == 2 or (sys.version_info[0] == 3
2020
and sys.version_info[1] < 3):
2121
requirements.append('ipaddress')
22+
if os.environ.get('SNYK_TOKEN'):
23+
f = open('requirements.txt', 'w')
24+
[f.write(r + '\n') for r in requirements]
2225

2326
compile_args = ['-Wall', '-Wextra']
2427

@@ -38,6 +41,7 @@
3841
# Taken from SQLAlchemy, but this same basic code exists in many modules.
3942
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
4043

44+
4145
class BuildFailed(Exception):
4246
def __init__(self):
4347
self.cause = sys.exc_info()[1] # work around py 2/3 different syntax

0 commit comments

Comments
 (0)