forked from dolph/rtox
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds untox script to rtox and allows using it as --untox parameter. Fixes #8 Signed-off-by: Sorin Sbarnea <[email protected]>
- Loading branch information
Showing
8 changed files
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
/ChangeLog | ||
/dist | ||
/rtox.egg-info | ||
/tests/untox/tox.ini | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
# Wipes any packet installation code from tox.ini in order to be able | ||
# to run tox commands using system packages. | ||
# | ||
import os | ||
import re | ||
|
||
|
||
def main(): | ||
f = open('tox.ini', 'r+') | ||
data = f.read() | ||
|
||
# comments to avoid weird accidents while parsing | ||
data = re.sub(r'\s*\#.*\n', '', data) | ||
|
||
# consolidate contiuation line breaks | ||
data = re.sub(r'^(.*)\\\n\s*([^\r\n]+)\n', | ||
r'\1\2\n', | ||
data, | ||
flags=re.MULTILINE) | ||
|
||
# remove install_commands | ||
data = re.sub(r'\s*install_command.*', '', data) | ||
|
||
# remove pip install commands (including multiline) | ||
data = re.sub(r'(?m)^\s*pip (.*)?install.*\n?', '', data) | ||
|
||
# remove deps, single and multiline ones | ||
data = re.sub(r'^\s*deps.*\n(([^\S\n]+[^\n]+\n)+)?', | ||
r'', | ||
data, | ||
flags=re.MULTILINE) | ||
|
||
# replace any existing sitepackages value as True | ||
data = re.sub(r'\s*sitepackages.*', '\nsitepackages = True', data) | ||
|
||
# adds sitepackages=True to [testenv*] section(s) if needed | ||
pattern = re.compile(r'^\[testenv[^\]\r\n]+](?:\r?\n(?:[^[\r\n].*)?)*', | ||
flags=re.MULTILINE) | ||
for s in re.findall(pattern, data): | ||
if 'sitepackages' not in s: | ||
data = data.replace(s, s + 'sitepackages = True\n') | ||
|
||
f.seek(0) | ||
f.write(data) | ||
f.truncate() | ||
|
||
# truncates requirement files just in case they are used in a different way | ||
for reqs in ['requirements.txt', 'test-requirements.txt']: | ||
if os.path.isfile(reqs): | ||
open(reqs, "w").truncate(0) | ||
|
||
# logs changes made as a diff file | ||
os.system("git diff | tee untox-diff.log") | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[tox] | ||
minversion = 1.6 | ||
skipsdist = True | ||
envlist = py27,pep8 | ||
|
||
[testenv] | ||
usedevelop = True | ||
sitepackages = True | ||
commands = | ||
bash tools/pretty_tox.sh '{posargs}' | ||
|
||
[testenv:pep8] | ||
commands = | ||
flake8 {posargs} . foo | ||
sitepackages = True | ||
[testenv:pylint] | ||
|
||
commands = bash tools/lintstack.sh | ||
|
||
sitepackages = True | ||
[testenv:cover] | ||
commands = | ||
python setup.py testr --coverage --testr-args='^(?!.*test.*coverage).*$ --concurrency 1' | ||
|
||
sitepackages = True | ||
[testenv:venv] | ||
commands = | ||
{posargs} | ||
sitepackages = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[tox] | ||
minversion = 1.6 | ||
skipsdist = True | ||
envlist = py27,pep8 | ||
|
||
[testenv] | ||
usedevelop = True | ||
sitepackages = False | ||
commands = | ||
pip install pip>=9.0.1 | ||
pip install -c{toxinidir}/upper-constraints.txt -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt | ||
bash tools/pretty_tox.sh '{posargs}' | ||
|
||
[testenv:pep8] | ||
deps = pip>=9.0.1 | ||
commands = | ||
pip install pip>=9.0.1 | ||
pip install -c{toxinidir}/upper-constraints.txt -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt | ||
flake8 {posargs} . foo | ||
# Check that .po and .pot files are valid: | ||
|
||
[testenv:pylint] | ||
deps = -r{toxinidir}/requirements.txt | ||
pylint==0.26.0 | ||
foo | ||
|
||
commands = bash tools/lintstack.sh | ||
|
||
[testenv:cover] | ||
commands = | ||
pip install pip>=9.0.1 | ||
pip install -c{toxinidir}/upper-constraints.txt \ | ||
-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt | ||
python setup.py testr --coverage \ | ||
--testr-args='^(?!.*test.*coverage).*$ --concurrency 1' | ||
|
||
[testenv:venv] | ||
commands = | ||
pip install pip>=9.0.1 | ||
pip install -c{toxinidir}/upper-constraints.txt -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt | ||
{posargs} | ||
sitepackages=False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters