Make tox and Makefile more similar.
This does a few things with the end goal of making simplifying and making consistent tox and 'make' methods of test or check. Things here: * move python programs out of bin and into their own main. Use entry_points to get scripts written for them. One gain here is that we no longer have python programs that are not named .py. flake8 and friends would not check those programs by default. * install scripts in bin/ using the setup.py scripts and adjust snapcraft.yaml and debian packaging for that. * declare and use PYTHON in Makefile to avoid repeating 'python3' * declare and use CHECK_DIRS in Makefile for list of dirs to check. * no longer run 'flake8' from 'make check' by default. * remove the old tests/ directory.
This commit is contained in:
parent
bf807867c3
commit
af94275618
|
@ -0,0 +1,3 @@
|
||||||
|
[flake8]
|
||||||
|
# gettext inserts _ into builtin path.
|
||||||
|
builtins = _
|
25
Makefile
25
Makefile
|
@ -9,6 +9,9 @@ PROBERT_REPO=https://github.com/CanonicalLtd/probert
|
||||||
export PYTHONPATH
|
export PYTHONPATH
|
||||||
CWD := $(shell pwd)
|
CWD := $(shell pwd)
|
||||||
|
|
||||||
|
CHECK_DIRS := console_conf/ subiquity/ subiquitycore/
|
||||||
|
PYTHON := python3
|
||||||
|
|
||||||
ifneq (,$(MACHINE))
|
ifneq (,$(MACHINE))
|
||||||
MACHARGS=--machine=$(MACHINE)
|
MACHARGS=--machine=$(MACHINE)
|
||||||
endif
|
endif
|
||||||
|
@ -21,10 +24,10 @@ install_deps:
|
||||||
sudo apt-get install -y python3-urwid python3-pyudev python3-nose python3-flake8 \
|
sudo apt-get install -y python3-urwid python3-pyudev python3-nose python3-flake8 \
|
||||||
python3-yaml python3-coverage python3-dev pkg-config libnl-genl-3-dev \
|
python3-yaml python3-coverage python3-dev pkg-config libnl-genl-3-dev \
|
||||||
libnl-route-3-dev python3-attr python3-distutils-extra python3-requests \
|
libnl-route-3-dev python3-attr python3-distutils-extra python3-requests \
|
||||||
python3-requests-unixsocket pep8
|
python3-requests-unixsocket
|
||||||
|
|
||||||
i18n:
|
i18n:
|
||||||
python3 setup.py build
|
$(PYTHON) setup.py build
|
||||||
|
|
||||||
dryrun: probert i18n
|
dryrun: probert i18n
|
||||||
$(MAKE) ui-view DRYRUN="--dry-run --uefi"
|
$(MAKE) ui-view DRYRUN="--dry-run --uefi"
|
||||||
|
@ -35,27 +38,25 @@ ui-view:
|
||||||
ui-view-serial:
|
ui-view-serial:
|
||||||
(TERM=att4424 bin/$(PYTHONSRC)-tui $(DRYRUN) --serial)
|
(TERM=att4424 bin/$(PYTHONSRC)-tui $(DRYRUN) --serial)
|
||||||
|
|
||||||
lint: pep8 pyflakes3
|
lint: flake8
|
||||||
|
|
||||||
pep8:
|
flake8:
|
||||||
@$(CWD)/scripts/run-pep8
|
@echo 'tox -e flake8' is preferred to 'make flake8'
|
||||||
|
$(PYTHON) -m flake8 $(CHECK_DIRS)
|
||||||
pyflakes3:
|
|
||||||
@$(CWD)/scripts/run-pyflakes3
|
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
echo "Running unit tests..."
|
echo "Running unit tests..."
|
||||||
nosetests3 $(PYTHONSRC)/tests
|
$(PYTHON) -m nose $(CHECK_DIRS)
|
||||||
|
|
||||||
check: lint unit
|
check: unit
|
||||||
|
|
||||||
probert:
|
probert:
|
||||||
@if [ ! -d "$(PROBERTDIR)" ]; then \
|
@if [ ! -d "$(PROBERTDIR)" ]; then \
|
||||||
git clone -q $(PROBERT_REPO) $(PROBERTDIR); \
|
git clone -q $(PROBERT_REPO) $(PROBERTDIR); \
|
||||||
(cd probert && python3 setup.py build_ext -i); \
|
(cd probert && $(PYTHON) setup.py build_ext -i); \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
./debian/rules clean
|
./debian/rules clean
|
||||||
|
|
||||||
.PHONY: lint pyflakes3 pep8
|
.PHONY: flake8 lint
|
||||||
|
|
|
@ -15,11 +15,14 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from console_conf.controllers.identity import write_login_details_standalone
|
from console_conf.controllers.identity import write_login_details_standalone
|
||||||
|
|
||||||
from subiquitycore.log import setup_logger
|
from subiquitycore.log import setup_logger
|
||||||
|
|
||||||
setup_logger(dir='/var/log/console-conf')
|
|
||||||
|
|
||||||
sys.exit(write_login_details_standalone())
|
def main():
|
||||||
|
setup_logger(dir='/var/log/console-conf')
|
||||||
|
write_login_details_standalone()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
|
@ -1,5 +1,5 @@
|
||||||
bin/console-conf-tui usr/share/subiquity
|
debian/tmp/usr/bin/console-conf-tui usr/share/subiquity
|
||||||
bin/console-conf-wait usr/share/subiquity
|
debian/tmp/usr/bin/console-conf-wait usr/share/subiquity
|
||||||
bin/console-conf-wrapper usr/share/subiquity
|
debian/tmp/usr/bin/console-conf-wrapper usr/share/subiquity
|
||||||
bin/console-conf-write-login-details usr/share/subiquity
|
debian/tmp/usr/bin/console-conf-write-login-details usr/share/subiquity
|
||||||
usr/share/subiquity/console_conf
|
usr/share/subiquity/console_conf
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
bin/subiquity-tui usr/share/subiquity
|
debian/tmp/usr/bin/subiquity-debug usr/share/subiquity
|
||||||
bin/subiquity-debug usr/share/subiquity
|
debian/tmp/usr/bin/subiquity-loadkeys usr/share/subiquity
|
||||||
bin/subiquity-loadkeys usr/share/subiquity
|
debian/tmp/usr/bin/subiquity-tui usr/share/subiquity
|
||||||
|
debian/tmp/usr/bin/subiquity-service usr/share/subiquity
|
||||||
usr/share/subiquity/subiquity
|
usr/share/subiquity/subiquity
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
usr/share/subiquity/subiquitycore
|
|
||||||
usr/share/locale
|
usr/share/locale
|
||||||
|
usr/share/subiquity/subiquitycore
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# This file is part of subiquity. See LICENSE file for copyright and license info.
|
|
||||||
|
|
||||||
pycheck_dirs=(
|
|
||||||
"console_conf/"
|
|
||||||
"subiquity/"
|
|
||||||
"subiquitycore/"
|
|
||||||
"tests/"
|
|
||||||
)
|
|
||||||
bin_files=(
|
|
||||||
"bin/console-conf-tui"
|
|
||||||
"bin/subiquity-tui"
|
|
||||||
)
|
|
||||||
CR="
|
|
||||||
"
|
|
||||||
[ "$1" = "-v" ] && { verbose="$1"; shift; } || verbose=""
|
|
||||||
|
|
||||||
set -f
|
|
||||||
if [ $# -eq 0 ]; then unset IFS
|
|
||||||
IFS="$CR"
|
|
||||||
files=( "${bin_files[@]}" "${pycheck_dirs[@]}" )
|
|
||||||
unset IFS
|
|
||||||
else
|
|
||||||
files=( "$@" )
|
|
||||||
fi
|
|
||||||
|
|
||||||
myname=${0##*/}
|
|
||||||
cmd=( "${myname#run-}" $verbose "${files[@]}" )
|
|
||||||
echo "Running: " "${cmd[@]}" 1>&2
|
|
||||||
exec "${cmd[@]}"
|
|
||||||
|
|
||||||
# vi: ts=4 expandtab syntax=sh
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# This file is part of curtin. See LICENSE file for copyright and license info.
|
|
||||||
|
|
||||||
pycheck_dirs=(
|
|
||||||
"console_conf/"
|
|
||||||
"subiquity/"
|
|
||||||
"subiquitycore/"
|
|
||||||
"tests/"
|
|
||||||
)
|
|
||||||
|
|
||||||
bin_files=(
|
|
||||||
"bin/console-conf-tui"
|
|
||||||
"bin/subiquity-tui"
|
|
||||||
)
|
|
||||||
CR="
|
|
||||||
"
|
|
||||||
[ "$1" = "-v" ] && { verbose="$1"; shift; } || verbose=""
|
|
||||||
|
|
||||||
set -f
|
|
||||||
if [ $# -eq 0 ]; then unset IFS
|
|
||||||
IFS="$CR"
|
|
||||||
files=( "${bin_files[@]}" "${pycheck_dirs[@]}" )
|
|
||||||
unset IFS
|
|
||||||
else
|
|
||||||
files=( "$@" )
|
|
||||||
fi
|
|
||||||
|
|
||||||
cmd=( "python3" -m "pyflakes" "${files[@]}" )
|
|
||||||
|
|
||||||
echo "Running: " "${cmd[@]}" 1>&2
|
|
||||||
export PYFLAKES_BUILTINS="_"
|
|
||||||
exec "${cmd[@]}"
|
|
||||||
|
|
||||||
# vi: ts=4 expandtab syntax=sh
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
python3 -m unittest discover
|
python3 -m unittest discover
|
||||||
# The --foreground is important to avoid subiquity getting SIGTTOU-ed.
|
# The --foreground is important to avoid subiquity getting SIGTTOU-ed.
|
||||||
timeout --foreground 60 sh -c 'LANG=C.UTF-8 PYTHONPATH=. python3 bin/subiquity-tui --answers examples/answers.yaml --dry-run --machine-config examples/mwhudson.json'
|
timeout --foreground 60 sh -c 'LANG=C.UTF-8 PYTHONPATH=. python3 -m subiquity.cmd.tui --answers examples/answers.yaml --dry-run --machine-config examples/mwhudson.json'
|
||||||
|
|
18
setup.py
18
setup.py
|
@ -36,7 +36,8 @@ if sys.argv[1] in ("build", "install"):
|
||||||
'build_i18n': build_i18n.build_i18n}
|
'build_i18n': build_i18n.build_i18n}
|
||||||
|
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), 'subiquitycore', '__init__.py')) as init:
|
with open(os.path.join(os.path.dirname(__file__),
|
||||||
|
'subiquitycore', '__init__.py')) as init:
|
||||||
lines = [line for line in init if 'i18n' not in line]
|
lines = [line for line in init if 'i18n' not in line]
|
||||||
ns = {}
|
ns = {}
|
||||||
exec('\n'.join(lines), ns)
|
exec('\n'.join(lines), ns)
|
||||||
|
@ -56,5 +57,20 @@ setup(name='subiquity',
|
||||||
url='https://github.com/CanonicalLtd/subiquity',
|
url='https://github.com/CanonicalLtd/subiquity',
|
||||||
license="AGPLv3+",
|
license="AGPLv3+",
|
||||||
packages=find_packages(exclude=["tests"]),
|
packages=find_packages(exclude=["tests"]),
|
||||||
|
scripts=[
|
||||||
|
'bin/console-conf-wait',
|
||||||
|
'bin/console-conf-wrapper',
|
||||||
|
'bin/subiquity-debug',
|
||||||
|
'bin/subiquity-loadkeys',
|
||||||
|
'bin/subiquity-service',
|
||||||
|
],
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'subiquity-tui = subiquity.cmd.tui:main',
|
||||||
|
'console-conf-tui = console_conf.cmd.tui:main',
|
||||||
|
('console-conf-write-login-details = '
|
||||||
|
'console_conf.cmd.write_login_details:main'),
|
||||||
|
],
|
||||||
|
},
|
||||||
data_files=[],
|
data_files=[],
|
||||||
**setup_kwargs)
|
**setup_kwargs)
|
||||||
|
|
|
@ -43,21 +43,12 @@ parts:
|
||||||
#- urwid
|
#- urwid
|
||||||
source: .
|
source: .
|
||||||
source-type: git
|
source-type: git
|
||||||
wrappers:
|
|
||||||
plugin: dump
|
|
||||||
source: .
|
|
||||||
source-type: git
|
|
||||||
organize:
|
organize:
|
||||||
'bin/console-conf-tui': usr/bin/console-conf
|
'bin/console-conf-tui': usr/bin/console-conf
|
||||||
'bin/subiquity-tui': usr/bin/subiquity
|
'bin/subiquity-tui': usr/bin/subiquity
|
||||||
'bin/subiquity-loadkeys': usr/bin/subiquity-loadkeys
|
'bin/subiquity-loadkeys': usr/bin/subiquity-loadkeys
|
||||||
'bin/curtin-journald-forwarder': usr/bin/curtin-journald-forwarder
|
'bin/curtin-journald-forwarder': usr/bin/curtin-journald-forwarder
|
||||||
'bin/subiquity-service': usr/bin/subiquity-service
|
'bin/subiquity-service': usr/bin/subiquity-service
|
||||||
stage-packages: [libc6]
|
|
||||||
stage:
|
|
||||||
- usr/bin
|
|
||||||
prime:
|
|
||||||
- usr/bin
|
|
||||||
users-and-groups:
|
users-and-groups:
|
||||||
plugin: dump
|
plugin: dump
|
||||||
build-packages:
|
build-packages:
|
||||||
|
|
10
tox.ini
10
tox.ini
|
@ -26,14 +26,14 @@ deps =
|
||||||
pyflakes==1.6.0
|
pyflakes==1.6.0
|
||||||
|
|
||||||
commands = {envpython} -m flake8 \
|
commands = {envpython} -m flake8 \
|
||||||
{posargs:subiquity/ subiquitycore/ console_conf/ bin/}
|
{posargs:console_conf/ subiquity/ subiquitycore/}
|
||||||
|
|
||||||
[testenv:py3]
|
[testenv:py3]
|
||||||
deps =
|
deps =
|
||||||
{[testenv]deps}
|
{[testenv]deps}
|
||||||
nose
|
nose
|
||||||
commands = {envpython} -m nose \
|
commands = {envpython} -m nose \
|
||||||
{posargs:subiquity/ subiquitycore/ console_conf/ bin/}
|
{posargs:console_conf/ subiquity/ subiquitycore/}
|
||||||
|
|
||||||
[testenv:coverage]
|
[testenv:coverage]
|
||||||
deps = {[testenv:py3]deps}
|
deps = {[testenv:py3]deps}
|
||||||
|
@ -43,8 +43,4 @@ commands = {envpython} -m nose \
|
||||||
--with-timer --timer-top-n 10 \
|
--with-timer --timer-top-n 10 \
|
||||||
--with-coverage --cover-erase --cover-branches --cover-inclusive \
|
--with-coverage --cover-erase --cover-branches --cover-inclusive \
|
||||||
--cover-package=subiquity --cover-package=subiquitycore \
|
--cover-package=subiquity --cover-package=subiquitycore \
|
||||||
{posargs:subiquity/ subiquitycore/ console_conf/ bin/}
|
{posargs:console_conf subiquity/ subiquitycore/}
|
||||||
|
|
||||||
[flake8]
|
|
||||||
# gettext inserts _ into builtin path.
|
|
||||||
builtins = _
|
|
||||||
|
|
Loading…
Reference in New Issue