Move to python3.7

- Now getting python packages using pip instead of the ubuntu versions.
- System wide installations now aren't supported.
This commit is contained in:
Andrew Hamilton 2018-09-02 15:54:18 +10:00
parent bf8d35f2f3
commit 8ae0f203f2
22 changed files with 46 additions and 47 deletions

View file

@ -11,7 +11,7 @@ Vigil maintains an up-to-date set of reports for every file in a codebase.
# git clone https://github.com/ahamilton/vigil # git clone https://github.com/ahamilton/vigil
# cd vigil # cd vigil
# ./install-dependencies # ./install-dependencies
# pip3 install . # python3.7 -m pip install .
To test its working properly: To test its working properly:

5
TODO
View file

@ -1,5 +1,9 @@
Todo Todo
- Publish on pypi. - Publish on pypi.
- Make a snap build work.
- Make a flatpak build work.
- Check the appimage build.
- Rename project to Eris.
Todo (tool related) Todo (tool related)
@ -167,6 +171,7 @@ Done
- Add cppcheck tool for C and C++. - Add cppcheck tool for C and C++.
- Add shellcheck tool for shell scripts. - Add shellcheck tool for shell scripts.
- Add "git log <path>". - Add "git log <path>".
- Change to using python3.7.
A-syntax, B-tests, C-auto docs, D-lint, E-coverage, F-profile, G-tidy, H-import deps A-syntax, B-tests, C-auto docs, D-lint, E-coverage, F-profile, G-tidy, H-import deps
A B C D E F G H A B C D E F G H

View file

@ -13,7 +13,7 @@ export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/local/bin/:"${PATH}"
export UNION_PRELOAD="${HERE}" export UNION_PRELOAD="${HERE}"
export LD_PRELOAD="${HERE}/libunionpreload.so" export LD_PRELOAD="${HERE}/libunionpreload.so"
export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}"
export PYTHONPATH=/usr/local/lib/python3.6/dist-packages:"${PYTHONPATH}" export PYTHONPATH=/usr/local/lib/python3.7/dist-packages:"${PYTHONPATH}"
if [ -z $APPIMAGE_ENTER ]; then if [ -z $APPIMAGE_ENTER ]; then
EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g') EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
exec ${EXEC} $@ exec ${EXEC} $@

View file

@ -13,8 +13,8 @@ if [ $DIST_ID != "ubuntu" ]; then
exit 1 exit 1
fi fi
echo "Installing the dependencies of the vigil script..." echo "Installing the dependencies of the vigil script..."
sudo apt --yes install python3-pyinotify python3-pygments python3-docopt \ sudo apt --yes install python3.7 util-linux
python3-pillow util-linux python3-toml python3.7 -m pip install pyinotify pygments docopt pillow toml
echo echo
echo "Installing all the tools vigil may need..." echo "Installing all the tools vigil may need..."
./install-tools ./install-tools

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.
@ -17,14 +17,12 @@ for dependency in vigil.tools.dependencies():
dist_deps.add(dependency) dist_deps.add(dependency)
if pip_deps: if pip_deps:
dist_deps.add("python-pip") dist_deps.add("python-pip")
if pip3_deps:
dist_deps.add("python3-pip")
if dist_deps: if dist_deps:
subprocess.run(["sudo", "apt-get", "-y", "install"] + list(dist_deps), subprocess.run(["sudo", "apt-get", "-y", "install"] + list(dist_deps),
check=True) check=True)
if pip_deps: if pip_deps:
subprocess.run(["sudo", "pip", "install"] + list(pip_deps), subprocess.run(["python", "-m", "pip", "install"] + list(pip_deps),
check=True) check=True)
if pip3_deps: if pip3_deps:
subprocess.run(["sudo", "pip3", "install"] + list(pip3_deps), subprocess.run(["python" + vigil.tools.PYTHON_VERSION, "-m", "pip",
check=True) "install"] + list(pip3_deps), check=True)

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
@ -35,7 +35,7 @@ Vigil maintains an up-to-date set of reports for every file in a codebase.
# git clone https://github.com/ahamilton/vigil # git clone https://github.com/ahamilton/vigil
# cd vigil # cd vigil
# ./install-dependencies # ./install-dependencies
# pip3 install . # python3.7 -m pip install .
To test its working properly: To test its working properly:

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.

View file

@ -1 +0,0 @@
No config file found, using default configuration

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2011, 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2011, 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -9,6 +9,8 @@ import contextlib
import enum import enum
import functools import functools
import gzip import gzip
import importlib
import importlib.resources
import math import math
import os import os
import os.path import os.path
@ -26,12 +28,15 @@ import pygments.lexers
import pygments.styles import pygments.styles
import toml import toml
import vigil
import vigil.fill3 as fill3 import vigil.fill3 as fill3
import vigil.gut as gut import vigil.gut as gut
import vigil.lscolors as lscolors import vigil.lscolors as lscolors
import vigil.termstr as termstr import vigil.termstr as termstr
PYTHON_VERSION = "3.7"
PYTHON_EXECUTABLE = "python" + PYTHON_VERSION
CACHE_PATH = ".vigil" CACHE_PATH = ".vigil"
@ -235,7 +240,7 @@ def metadata(path):
return (Status.normal, fill3.Text(fill3.join("", text))) return (Status.normal, fill3.Text(fill3.join("", text)))
@deps(deps={"python3-pygments"}, url="python3-pygments") @deps(deps={"pip3/pygments"}, url="python3-pygments")
def contents(path): def contents(path):
with open(path) as file_: with open(path) as file_:
try: try:
@ -267,10 +272,10 @@ def _is_python_syntax_correct(path, python_version):
def _python_version(path): # Need a better hueristic def _python_version(path): # Need a better hueristic
for version in ["python3", "python"]: for version in [PYTHON_EXECUTABLE, "python"]:
if _is_python_syntax_correct(path, version): if _is_python_syntax_correct(path, version):
return version return version
return "python3" return PYTHON_EXECUTABLE
@deps(deps={"python"}, @deps(deps={"python"},
@ -330,7 +335,7 @@ def _colorize_coverage_report(text):
for line in text.splitlines(keepends=True)]) for line in text.splitlines(keepends=True)])
@deps(deps={"python-coverage", "python3-coverage"}, url="python3-coverage") @deps(deps={"pip/coverage", "pip3/coverage"}, url="python3-coverage")
def python_coverage(path): def python_coverage(path):
# FIX: Also use test_*.py files. # FIX: Also use test_*.py files.
test_path = path[:-(len(".py"))] + "_test.py" test_path = path[:-(len(".py"))] + "_test.py"
@ -355,24 +360,22 @@ def python_coverage(path):
"No corresponding test file: " + os.path.normpath(test_path)) "No corresponding test file: " + os.path.normpath(test_path))
@deps(deps={"python-pycodestyle", "python3-pycodestyle"}, @deps(deps={"pip/pycodestyle", "pip3/pycodestyle"}, url="python-pycodestyle")
url="python-pycodestyle")
def pycodestyle(path): def pycodestyle(path):
return _run_command([_python_version(path), "-m", "pycodestyle", path]) return _run_command([_python_version(path), "-m", "pycodestyle", path])
@deps(deps={"pydocstyle", "python3-pydocstyle"}, @deps(deps={"pip/pydocstyle", "pip3/pydocstyle"}, url="python3-pydocstyle")
url="python3-pydocstyle")
def pydocstyle(path): def pydocstyle(path):
return _run_command([_python_version(path), "-m", "pydocstyle", path]) return _run_command([_python_version(path), "-m", "pydocstyle", path])
@deps(deps={"python-pyflakes", "python3-pyflakes"}, url="pyflakes") @deps(deps={"pip/pyflakes", "pip3/pyflakes"}, url="pyflakes")
def pyflakes(path): def pyflakes(path):
return _run_command([_python_version(path), "-m", "pyflakes", path]) return _run_command([_python_version(path), "-m", "pyflakes", path])
@deps(deps={"pylint", "pylint3"}, url="pylint3") @deps(deps={"pip/pylint", "pip3/pylint"}, url="pylint3")
def pylint(path): def pylint(path):
return _run_command([_python_version(path), "-m", "pylint", return _run_command([_python_version(path), "-m", "pylint",
"--errors-only", path]) "--errors-only", path])
@ -402,7 +405,7 @@ def dis(path):
def _get_mccabe_line_score(line, python_version): def _get_mccabe_line_score(line, python_version):
position, function_name, score = line.split() position, function_name, score = line.split()
return int(score if python_version == "python3" else score[:-1]) return int(score if python_version == PYTHON_EXECUTABLE else score[:-1])
def _colorize_mccabe(text, python_version): def _colorize_mccabe(text, python_version):
@ -412,7 +415,7 @@ def _colorize_mccabe(text, python_version):
for line in text.splitlines(keepends=True)]) for line in text.splitlines(keepends=True)])
@deps(deps={"python-mccabe", "python3-mccabe"}, url="python3-mccabe") @deps(deps={"pip/mccabe", "pip3/mccabe"}, url="python3-mccabe")
def python_mccabe(path): def python_mccabe(path):
python_version = _python_version(path) python_version = _python_version(path)
stdout, *rest = _do_command([python_version, "-m", "mccabe", path]) stdout, *rest = _do_command([python_version, "-m", "mccabe", path])
@ -424,11 +427,6 @@ def python_mccabe(path):
return status, fill3.Text(_colorize_mccabe(stdout, python_version)) return status, fill3.Text(_colorize_mccabe(stdout, python_version))
def python_tidy(path): # Deps: found on internet?
stdout, *rest = _do_command(["python", "python-tidy.py", path])
return Status.normal, _syntax_highlight_using_path(stdout, path)
# FIX: Reenable when pydisasm is not causing problems # FIX: Reenable when pydisasm is not causing problems
# @deps(deps={"pip3/xdis"}, executables={"pydisasm"}, # @deps(deps={"pip3/xdis"}, executables={"pydisasm"},
# url="https://pypi.python.org/pypi/xdis") # url="https://pypi.python.org/pypi/xdis")
@ -437,7 +435,7 @@ def python_tidy(path): # Deps: found on internet?
# Status.not_applicable) # Status.not_applicable)
@deps(deps={"python-bandit", "python3-bandit"}, url="python3-bandit") @deps(deps={"pip/bandit", "pip3/bandit"}, url="python3-bandit")
def bandit(path): def bandit(path):
python_version = _python_version(path) python_version = _python_version(path)
stdout, stderr, returncode = _do_command( stdout, stderr, returncode = _do_command(
@ -597,8 +595,7 @@ def make_tool_function(dependencies, url, command, success_status=None,
return func return func
tools_toml_path = os.path.join(os.path.dirname(__file__), "tools.toml") with importlib.resources.open_text(vigil, "tools.toml") as tools_toml_file:
with open(tools_toml_path) as tools_toml_file:
tools_toml = toml.load(tools_toml_file) tools_toml = toml.load(tools_toml_file)
tools_for_extensions = tools_toml["tools_for_extensions"] tools_for_extensions = tools_toml["tools_for_extensions"]
del tools_toml["tools_for_extensions"] del tools_toml["tools_for_extensions"]

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3.6 #!/usr/bin/env python3.7
# Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved. # Copyright (C) 2015-2018 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0. # Licensed under the Artistic License 2.0.