Closed dotlambda closed 4 years ago
The original version passes for me with py3.8.3 on master and develop.
I am also wondering as these failures do not show up on travis or my local computer. Can you please report your OS, python version and how you installed it.
I'm on NixOS, Python 3.8.3.
I build khard from nixpkgs using nix-build -A khard
.
I tried bisecting nixpkgs to find a culprit but it seems this exists since updating khard from 0.14.0 to 0.15.1.
I suspect this might be due to to the sandbox in which Nix builds packages. Maybe the options are printed on multiple lines if the terminal width is too small? The latter might not be set/recognized/... in the sandbox.
I am also sometimes working no nixos. I did not have any luck with any of these:
nix-shell --pure --command 'python setup.py test -A nixos.khard # error: attribute 'nixos' in selection path 'nixos.khard' not found
nix-shell --pure --command 'python setup.py test -p khard # missing setuptools
But I hacked together this shell.nix
some time ago and it works:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
(python3.withPackages(ps: with ps; [
atomicwrites
configobj
ruamel_yaml
setuptools
wheel
twine
unidecode
vobject
coverage
sphinx
importlib-metadata
pip
]))
hyperfine
git
termite # for the terminfo
];
shellHook = ''
alias pip="PIP_PREFIX='$(pwd)/_build/pip_packages' \pip"
export PYTHONPATH="$(pwd)/_build/pip_packages/lib/python3.7/site-packages:$PYTHONPATH"
unset SOURCE_DATE_EPOCH
export TERM=xterm
'';
}
I just played around a bit and this seems to be a minimal version that works:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
(python3.withPackages(ps: with ps; [
setuptools
]))
git
];
}
but than setuptools will download the dependencies itself.
I am new to development on nixos (only used arch linux before) and would be happy to learn how to do that "better".
I just checked https://github.com/NixOS/nixpkgs/blob/34b9b139bbf743e88b5a27cc876a979dae1ace85/pkgs/applications/misc/khard/default.nix and it seems that @matthiasbeyer maintains it. Maybe he can help us?
I suggest you do nix-shell --pure -A khard
in a checkout of the nixpkgs git repo. To get setuptools_scm
working you will have to add git
to e.g. nativeBuildInputs
in pkgs/applications/misc/khard/default.nix
. Then you can cd
to a directory with the khard source code.
Using this, python setup.py test
will work fine, suggesting that it's really due to sandboxing,
Maybe @FRidh has some insight.
What does khard list -h
show in and outside the sandbox?
The output of khard -h
inside sandbox:
usage: khard
[-h]
[-c CONFIG]
[--debug]
[--skip-unparsable]
[-v]
{list,ls,show,details,template,birthdays,bdays,email,phone,postaddress,post,postaddr,new,add,add-email,merge,edit,modify,ed,copy,cp,move,mv,remove,delete,del,rm,addressbooks,abooks,filename,file,export,source,src}
...
positional arguments:
{list,ls,show,details,template,birthdays,bdays,email,phone,postaddress,post,postaddr,new,add,add-email,merge,edit,modify,ed,copy,cp,move,mv,remove,delete,del,rm,addressbooks,abooks,filename,file,export,source,src}
list (ls)
list all
(selected)
contacts
show (details)
display
detailed
information
about one
contact
template
print an
empty yaml
template
birthdays (bdays)
list
birthdays
(sorted by
month and
day)
email
list email
addresses
phone
list phone
numbers
postaddress (post, postaddr)
list postal
addresses
new (add)
create a
new contact
add-email
Extract
email
address
from the
"From:"
field of an
email
header and
add to an
existing
contact or
create a
new one
merge
merge two
contacts
edit (modify, ed)
edit the
data of a
contact
copy (cp)
copy a
contact to
a different
addressbook
move (mv)
move a
contact to
a different
addressbook
remove (delete, del, rm)
remove a
contact
addressbooks (abooks)
list addres
sbooks
filename (file)
list
filenames
of all
matching
contacts
export
DEPRECATED
use 'show -
-format=yam
l'
source (src)
DEPRECATED
use 'edit -
-format=vca
rd'
optional arguments:
-h, --help
show this
help
message and
exit
-c CONFIG, --config CONFIG
config file
to use
--debug
enable
debug
output
--skip-unparsable
skip
unparsable
vcard files
-v, --version
show
program's
version
number and
exit
outside sandbox:
usage: khard [-h] [-c CONFIG] [--debug] [--skip-unparsable] [-v]
{list,ls,show,details,template,birthdays,bdays,email,phone,postaddress,post,postaddr,new,add,add-email,merge,edit,modify,ed,copy,cp,move,mv,remove,delete,del,rm,addressbooks,abooks,filename,file,export,source,src}
...
positional arguments:
{list,ls,show,details,template,birthdays,bdays,email,phone,postaddress,post,postaddr,new,add,add-email,merge,edit,modify,ed,copy,cp,move,mv,remove,delete,del,rm,addressbooks,abooks,filename,file,export,source,src}
list (ls) list all (selected) contacts
show (details) display detailed information about one contact
template print an empty yaml template
birthdays (bdays) list birthdays (sorted by month and day)
email list email addresses
phone list phone numbers
postaddress (post, postaddr)
list postal addresses
new (add) create a new contact
add-email Extract email address from the "From:" field of an email header and add to an
existing contact or create a new one
merge merge two contacts
edit (modify, ed) edit the data of a contact
copy (cp) copy a contact to a different addressbook
move (mv) move a contact to a different addressbook
remove (delete, del, rm)
remove a contact
addressbooks (abooks)
list addressbooks
filename (file) list filenames of all matching contacts
export DEPRECATED use 'show --format=yaml'
source (src) DEPRECATED use 'edit --format=vcard'
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
config file to use
--debug enable debug output
--skip-unparsable skip unparsable vcard files
-v, --version show program's version number and exit
I got these by setting doCheck = false
and adding $out/bin/khard -h
to postInstall
.
@dotlambda I conclude that the sandbox is somehow breaking things here. I am not sure if I can help with that but you can surely use this issue to discuss it.
This is the commit that changed the argparse
behaviour for Python 3.8: https://github.com/python/cpython/commit/74102c9a5f2327c4fc47feefa072854a53551d1f
Here's where the value for get_terminal_size().columns
is set:
https://github.com/python/cpython/blob/3.8/Lib/shutil.py#L1318
Thus the easiest fix for nixpkgs would be export COLUMNS=80
.
@dotlambda please check khard list -h
, that's what is used in that test I think.
Oh that's a surprising cause
@dotlambda please check
khard list -h
, that's what is used in that test I think.
That doesn't work because OSError: Config file not found: "/home/rschuetz/.config/khard/khard.conf".
However the test actually tests khard -h
, khard list -h
, and khard -h list
. I think the outcome would be the same for the others.
The testsuite currently results in
Thus I patched the testsuite to use
assertRegex
:and get
This does not happen when using Python 3.7.