unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / Atom feed
* Python Site Package Syntax Runtime Error
@ 2021-09-07 17:39 Antwane Mason
  2021-09-16 12:06 ` Hartmut Goebel
  2021-09-19 17:59 ` Maxime Devos
  0 siblings, 2 replies; 9+ messages in thread
From: Antwane Mason @ 2021-09-07 17:39 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 6056 bytes --]

Has anyone come across the following runtime error when running a
python-based application in guix? I'm wondering if something went wrong
during the package build for python-onlykey-agent that messed up the
PYTHONPATH export for the runtime.  I should note that python-onlykey-agent
is a program that I have packaged to eventually submit to guix.

*--8<---------------cut here---------------start------------->8---*

export
PYTHONPATH="...:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"

SyntaxError: invalid syntax

*--8<---------------cut here---------------end--------------->8---*

Here is the entire stack trace for reference.

*--8<---------------cut here---------------start------------->8---*

antwane@wmguix ~$ onlykey-agent git@github.com
Traceback (most recent call last):
  File
"/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey-agent-real",
line 11, in <module>
    load_entry_point('onlykey-agent==1.1.12', 'console_scripts',
'onlykey-agent')()
  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2852, in load_entry_point
    return ep.load()
  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2443, in load
    return self.resolve()
  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File
"/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py",
line 2
    export
PYTHONPATH="/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/lib/python3.8/site-packages:/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages:/gnu/store/xq0bpzrxy461igy3vwymgmlfg85ghfgv-python-onlykey-1.2.6/lib/python3.8/site-packages:/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages:/gnu/store/gb0xnb6vldlmwiky77w7hxpkjbvp1560-python-wheel-0.36.2/lib/python3.8/site-packages:/gnu/store/7c48ls8c4xddx22yy7rlnszs0fjl56k7-python-unidecode-1.1.1/lib/python3.8/site-packages:/gnu/store/hi8yk6yzivzwpxak2fcggd6zl887n7zj-python-semver-2.9.0/lib/python3.8/site-packages:/gnu/store/gvka9y88b5i6h1fbwb5qxi8vv0ajh6d3-python-pynacl-1.4.0/lib/python3.8/site-packages:/gnu/store/4153n7v3hy0pn2df0c8rag7v4gmgg0ki-python-pymsgbox-1.0.6/lib/python3.8/site-packages:/gnu/store/ppdbw2sl5filj79rl6k0wqy7xkz2603n-python-pycryptodome-3.9.9/lib/python3.8/site-packages:/gnu/store/b2pf54i477iby8f17am9p0x2bz96gn63-python-mnemonic-0.20/lib/python3.8/site-packages:/gnu/store/3vl9a6y7d9r3w3diy2bj15jxd0qgzycv-python-ecdsa-0.14.1/lib/python3.8/site-packages:/gnu/store/1qz6j51mmn2z1za41fb9vs9dgmwisng3-python-docutils-0.16/lib/python3.8/site-packages:/gnu/store/v74q9niaprwv0l25hb1hcyhvyzwp7zmf-python-daemon-2.2.3/lib/python3.8/site-packages:/gnu/store/jvm96kifzns968g0l115chfdp3n5ksba-python-configargparse-1.2.3/lib/python3.8/site-packages:/gnu/store/j3w4j8x76n7wdbjrh377fwx4hwgmfwmy-python-backports.shutil-which-3.5.2/lib/python3.8/site-packages:/gnu/store/hjmz8ymac939ribn7g3jkgms4dk2az3a-python-six-1.14.0/lib/python3.8/site-packages:/gnu/store/bxbhdka9x8pnl7jnpkvz1nvgg2m8xqfs-python-prompt-toolkit-3.0.18/lib/python3.8/site-packages:/gnu/store/2lrpayrb6rrfmscfkfii65jdd328v945-python-onlykey-solo-0.0.28/lib/python3.8/site-packages:/gnu/store/1xmngywbzxx8lb539z4zcggm12gw6lzm-python-hidapi-0.7.99.post21/lib/python3.8/site-packages:/gnu/store/j1qn1pjvpyljmrb7hh1pjsgz44b13y5i-python-cython-0.29.22/lib/python3.8/site-packages:/gnu/store/d5zp1z8vz42c8b69fszck1vqh59npms4-python-aenum-2.2.4/lib/python3.8/site-packages:/gnu/store/sfy8vc8da10appy093izjz4byzd7sfqp-python-cffi-1.14.4/lib/python3.8/site-packages:/gnu/store/wi6ihkh2dq1sj6pq6g28f5vw157kfy8x-python-lockfile-0.12.2/lib/python3.8/site-packages:/gnu/store/xjiplzqxr084ximm4wdhyx3wzf8nxvv0-python-wcwidth-0.1.8/lib/python3.8/site-packages:/gnu/store/kffam5lzshdhb0ygq0r76gqvavs0190c-python-requests-2.25.0/lib/python3.8/site-packages:/gnu/store/qkj3ssg0y3ya0d450pp0kaa7zbg9i0x6-python-pyusb-1.0.2/lib/python3.8/site-packages:/gnu/store/b3k1kmx7rzkykb4ik5nz0jdabqr86vvv-python-pyserial-3.5/lib/python3.8/site-packages:/gnu/store/w3q52n0pc5zvblr8qdsgdfiw33psj6pz-python-intelhex-2.2.1/lib/python3.8/site-packages:/gnu/store/fpk2f2jwqah0s340hdhmr734vvxq3z3j-python-fido2-0.9.1/lib/python3.8/site-packages:/gnu/store/sjiiqs605sfsqxjdkcm3m8rx0ahv5wvv-python-cryptography-3.3.1/lib/python3.8/site-packages:/gnu/store/5a12m99wdfqydzwx46nlfqqvi9q3pq49-python-click-7.1.2/lib/python3.8/site-packages:/gnu/store/k08j1silv8zxfglz3mb5q7ngmya9cv39-python-pycparser-2.20/lib/python3.8/site-packages:/gnu/store/fd7sx13lhrgbrnsa5k3g8inas417p5q5-python-urllib3-1.26.4/lib/python3.8/site-packages:/gnu/store/ihl3h0s000vlkvadxvv21cbn4fqzvmav-python-idna-2.10/lib/python3.8/site-packages:/gnu/store/ysvrcvvaajbg432f7pr0k8x2w21lnz81-python-chardet-3.0.4/lib/python3.8/site-packages:/gnu/store/2j54g0s8db1b10ggs4rirfb5vv8abm2y-python-certifi-2020.12.5/lib/python3.8/site-packages:/gnu/store/q01v2xjfcl7d020y3yh865695gm8i3gx-python-iso8601-0.1.13/lib/python3.8/site-packages:/gnu/store/xkcc4372psi79xiidw4k33nmyf6mk36h-python-asn1crypto-1.4.0/lib/python3.8/site-packages:/gnu/store/xgsczafbfkmqmanm87nx2qfyzp4h313i-python-pysocks-1.7.1/lib/python3.8/site-packages:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"
           ^
SyntaxError: invalid syntax



*--8<---------------cut here---------------end--------------->8---*

Regards,
Antwane

[-- Attachment #2: Type: text/html, Size: 6662 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-07 17:39 Python Site Package Syntax Runtime Error Antwane Mason
@ 2021-09-16 12:06 ` Hartmut Goebel
  2021-09-18 19:44   ` Antwane Mason
  2021-09-19 17:59 ` Maxime Devos
  1 sibling, 1 reply; 9+ messages in thread
From: Hartmut Goebel @ 2021-09-16 12:06 UTC (permalink / raw)
  To: Antwane Mason, guix-devel

Am 07.09.21 um 19:39 schrieb Antwane Mason:
> File 
> "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py", 
> line 2
>     export PYTHONPATH="/gnu/store/…-

This looks like an error in the package definition: A .py-file contains 
a shell command.

HTH

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-16 12:06 ` Hartmut Goebel
@ 2021-09-18 19:44   ` Antwane Mason
  2021-09-19 16:31     ` Antwane Mason
  2021-09-20 12:32     ` Hartmut Goebel
  0 siblings, 2 replies; 9+ messages in thread
From: Antwane Mason @ 2021-09-18 19:44 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 12024 bytes --]

Thank you for the response. I think since there is nothing out of the
ordinary going on in the package definition, this may be some edge-case in
one of the python build stages. Below is the package definition.


























*--8<---------------cut
here---------------start------------->8---(define-public
python-onlykey-agent  (package    (name "python-onlykey-agent")
(version "1.1.12")    (source      (origin        (method url-fetch)
     (uri (pypi-uri "onlykey-agent" version))        (sha256
(base32
"1586zhpph79s12alnyj1iiiwj0c5h1z8na2lqczf560p5mca6gxw"))))
(build-system python-build-system)    (propagated-inputs
`(("python-lib-agent" ,python-lib-agent)        ("python-onlykey"
,python-onlykey)))    (home-page
"http://github.com/trustcrypto/onlykey-agent
<http://github.com/trustcrypto/onlykey-agent>")    (synopsis
"Using OnlyKey as hardware SSH/GPG agent")    (description      "Using
OnlyKey as hardware SSH/GPG agent")    (license
license:lgpl3)))--8<---------------cut
here---------------end--------------->8---*

From what I can tell, one of the build phases responsible for wrapping
executables into shell scripts is wrongly wrapping one of the python files.
This causes the shell script which is named as the original python file to
be loaded as a python module causing a syntax error because the export line
is a shell directive and not valid python syntax. Below is the stack trace
again for reference.  The last file referenced in the stack trace is a
shell script wrapper for the original onlykey_agent.py file which was
renamed .onlykey_agent.py-real. Below is the full file for this shell
script. Can anyone provide guidance as to which build phase needs to change
and how to change it to prevent onlykey_agent.py from being wrapped?



















*--8<---------------cut
here---------------start------------->8---antwane@wmguix ~$
onlykey-agentTraceback (most recent call last):  File
"/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey-agent-real",
line 11, in <module>    load_entry_point('onlykey-agent==1.1.12',
'console_scripts', 'onlykey-agent')()  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 489, in load_entry_point    return
get_distribution(dist).load_entry_point(group, name)  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2852, in load_entry_point    return ep.load()  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2443, in load    return self.resolve()  File
"/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py",
line 2449, in resolve    module = __import__(self.module_name,
fromlist=['__name__'], level=0)  File
"/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py",
line 2    export
PYTHONPATH="/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/lib/python3.8/site-packages:/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages:/gnu/store/xq0bpzrxy461igy3vwymgmlfg85ghfgv-python-onlykey-1.2.6/lib/python3.8/site-packages:/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages:/gnu/store/gb0xnb6vldlmwiky77w7hxpkjbvp1560-python-wheel-0.36.2/lib/python3.8/site-packages:/gnu/store/7c48ls8c4xddx22yy7rlnszs0fjl56k7-python-unidecode-1.1.1/lib/python3.8/site-packages:/gnu/store/hi8yk6yzivzwpxak2fcggd6zl887n7zj-python-semver-2.9.0/lib/python3.8/site-packages:/gnu/store/gvka9y88b5i6h1fbwb5qxi8vv0ajh6d3-python-pynacl-1.4.0/lib/python3.8/site-packages:/gnu/store/4153n7v3hy0pn2df0c8rag7v4gmgg0ki-python-pymsgbox-1.0.6/lib/python3.8/site-packages:/gnu/store/ppdbw2sl5filj79rl6k0wqy7xkz2603n-python-pycryptodome-3.9.9/lib/python3.8/site-packages:/gnu/store/b2pf54i477iby8f17am9p0x2bz96gn63-python-mnemonic-0.20/lib/python3.8/site-packages:/gnu/store/3vl9a6y7d9r3w3diy2bj15jxd0qgzycv-python-ecdsa-0.14.1/lib/python3.8/site-packages:/gnu/store/1qz6j51mmn2z1za41fb9vs9dgmwisng3-python-docutils-0.16/lib/python3.8/site-packages:/gnu/store/v74q9niaprwv0l25hb1hcyhvyzwp7zmf-python-daemon-2.2.3/lib/python3.8/site-packages:/gnu/store/jvm96kifzns968g0l115chfdp3n5ksba-python-configargparse-1.2.3/lib/python3.8/site-packages:/gnu/store/j3w4j8x76n7wdbjrh377fwx4hwgmfwmy-python-backports.shutil-which-3.5.2/lib/python3.8/site-packages:/gnu/store/hjmz8ymac939ribn7g3jkgms4dk2az3a-python-six-1.14.0/lib/python3.8/site-packages:/gnu/store/bxbhdka9x8pnl7jnpkvz1nvgg2m8xqfs-python-prompt-toolkit-3.0.18/lib/python3.8/site-packages:/gnu/store/2lrpayrb6rrfmscfkfii65jdd328v945-python-onlykey-solo-0.0.28/lib/python3.8/site-packages:/gnu/store/1xmngywbzxx8lb539z4zcggm12gw6lzm-python-hidapi-0.7.99.post21/lib/python3.8/site-packages:/gnu/store/j1qn1pjvpyljmrb7hh1pjsgz44b13y5i-python-cython-0.29.22/lib/python3.8/site-packages:/gnu/store/d5zp1z8vz42c8b69fszck1vqh59npms4-python-aenum-2.2.4/lib/python3.8/site-packages:/gnu/store/sfy8vc8da10appy093izjz4byzd7sfqp-python-cffi-1.14.4/lib/python3.8/site-packages:/gnu/store/wi6ihkh2dq1sj6pq6g28f5vw157kfy8x-python-lockfile-0.12.2/lib/python3.8/site-packages:/gnu/store/xjiplzqxr084ximm4wdhyx3wzf8nxvv0-python-wcwidth-0.1.8/lib/python3.8/site-packages:/gnu/store/kffam5lzshdhb0ygq0r76gqvavs0190c-python-requests-2.25.0/lib/python3.8/site-packages:/gnu/store/qkj3ssg0y3ya0d450pp0kaa7zbg9i0x6-python-pyusb-1.0.2/lib/python3.8/site-packages:/gnu/store/b3k1kmx7rzkykb4ik5nz0jdabqr86vvv-python-pyserial-3.5/lib/python3.8/site-packages:/gnu/store/w3q52n0pc5zvblr8qdsgdfiw33psj6pz-python-intelhex-2.2.1/lib/python3.8/site-packages:/gnu/store/fpk2f2jwqah0s340hdhmr734vvxq3z3j-python-fido2-0.9.1/lib/python3.8/site-packages:/gnu/store/sjiiqs605sfsqxjdkcm3m8rx0ahv5wvv-python-cryptography-3.3.1/lib/python3.8/site-packages:/gnu/store/5a12m99wdfqydzwx46nlfqqvi9q3pq49-python-click-7.1.2/lib/python3.8/site-packages:/gnu/store/k08j1silv8zxfglz3mb5q7ngmya9cv39-python-pycparser-2.20/lib/python3.8/site-packages:/gnu/store/fd7sx13lhrgbrnsa5k3g8inas417p5q5-python-urllib3-1.26.4/lib/python3.8/site-packages:/gnu/store/ihl3h0s000vlkvadxvv21cbn4fqzvmav-python-idna-2.10/lib/python3.8/site-packages:/gnu/store/ysvrcvvaajbg432f7pr0k8x2w21lnz81-python-chardet-3.0.4/lib/python3.8/site-packages:/gnu/store/2j54g0s8db1b10ggs4rirfb5vv8abm2y-python-certifi-2020.12.5/lib/python3.8/site-packages:/gnu/store/q01v2xjfcl7d020y3yh865695gm8i3gx-python-iso8601-0.1.13/lib/python3.8/site-packages:/gnu/store/xkcc4372psi79xiidw4k33nmyf6mk36h-python-asn1crypto-1.4.0/lib/python3.8/site-packages:/gnu/store/xgsczafbfkmqmanm87nx2qfyzp4h313i-python-pysocks-1.7.1/lib/python3.8/site-packages:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"
          ^SyntaxError: invalid syntax--8<---------------cut
here---------------end--------------->8---*







*--8<---------------cut
here---------------start------------->8---#!/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16/bin/bashexport
PYTHONPATH="/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/lib/python3.8/site-packages:/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages:/gnu/store/xq0bpzrxy461igy3vwymgmlfg85ghfgv-python-onlykey-1.2.6/lib/python3.8/site-packages:/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages:/gnu/store/gb0xnb6vldlmwiky77w7hxpkjbvp1560-python-wheel-0.36.2/lib/python3.8/site-packages:/gnu/store/7c48ls8c4xddx22yy7rlnszs0fjl56k7-python-unidecode-1.1.1/lib/python3.8/site-packages:/gnu/store/hi8yk6yzivzwpxak2fcggd6zl887n7zj-python-semver-2.9.0/lib/python3.8/site-packages:/gnu/store/gvka9y88b5i6h1fbwb5qxi8vv0ajh6d3-python-pynacl-1.4.0/lib/python3.8/site-packages:/gnu/store/4153n7v3hy0pn2df0c8rag7v4gmgg0ki-python-pymsgbox-1.0.6/lib/python3.8/site-packages:/gnu/store/ppdbw2sl5filj79rl6k0wqy7xkz2603n-python-pycryptodome-3.9.9/lib/python3.8/site-packages:/gnu/store/b2pf54i477iby8f17am9p0x2bz96gn63-python-mnemonic-0.20/lib/python3.8/site-packages:/gnu/store/3vl9a6y7d9r3w3diy2bj15jxd0qgzycv-python-ecdsa-0.14.1/lib/python3.8/site-packages:/gnu/store/1qz6j51mmn2z1za41fb9vs9dgmwisng3-python-docutils-0.16/lib/python3.8/site-packages:/gnu/store/v74q9niaprwv0l25hb1hcyhvyzwp7zmf-python-daemon-2.2.3/lib/python3.8/site-packages:/gnu/store/jvm96kifzns968g0l115chfdp3n5ksba-python-configargparse-1.2.3/lib/python3.8/site-packages:/gnu/store/j3w4j8x76n7wdbjrh377fwx4hwgmfwmy-python-backports.shutil-which-3.5.2/lib/python3.8/site-packages:/gnu/store/hjmz8ymac939ribn7g3jkgms4dk2az3a-python-six-1.14.0/lib/python3.8/site-packages:/gnu/store/bxbhdka9x8pnl7jnpkvz1nvgg2m8xqfs-python-prompt-toolkit-3.0.18/lib/python3.8/site-packages:/gnu/store/2lrpayrb6rrfmscfkfii65jdd328v945-python-onlykey-solo-0.0.28/lib/python3.8/site-packages:/gnu/store/1xmngywbzxx8lb539z4zcggm12gw6lzm-python-hidapi-0.7.99.post21/lib/python3.8/site-packages:/gnu/store/j1qn1pjvpyljmrb7hh1pjsgz44b13y5i-python-cython-0.29.22/lib/python3.8/site-packages:/gnu/store/d5zp1z8vz42c8b69fszck1vqh59npms4-python-aenum-2.2.4/lib/python3.8/site-packages:/gnu/store/sfy8vc8da10appy093izjz4byzd7sfqp-python-cffi-1.14.4/lib/python3.8/site-packages:/gnu/store/wi6ihkh2dq1sj6pq6g28f5vw157kfy8x-python-lockfile-0.12.2/lib/python3.8/site-packages:/gnu/store/xjiplzqxr084ximm4wdhyx3wzf8nxvv0-python-wcwidth-0.1.8/lib/python3.8/site-packages:/gnu/store/kffam5lzshdhb0ygq0r76gqvavs0190c-python-requests-2.25.0/lib/python3.8/site-packages:/gnu/store/qkj3ssg0y3ya0d450pp0kaa7zbg9i0x6-python-pyusb-1.0.2/lib/python3.8/site-packages:/gnu/store/b3k1kmx7rzkykb4ik5nz0jdabqr86vvv-python-pyserial-3.5/lib/python3.8/site-packages:/gnu/store/w3q52n0pc5zvblr8qdsgdfiw33psj6pz-python-intelhex-2.2.1/lib/python3.8/site-packages:/gnu/store/fpk2f2jwqah0s340hdhmr734vvxq3z3j-python-fido2-0.9.1/lib/python3.8/site-packages:/gnu/store/sjiiqs605sfsqxjdkcm3m8rx0ahv5wvv-python-cryptography-3.3.1/lib/python3.8/site-packages:/gnu/store/5a12m99wdfqydzwx46nlfqqvi9q3pq49-python-click-7.1.2/lib/python3.8/site-packages:/gnu/store/k08j1silv8zxfglz3mb5q7ngmya9cv39-python-pycparser-2.20/lib/python3.8/site-packages:/gnu/store/fd7sx13lhrgbrnsa5k3g8inas417p5q5-python-urllib3-1.26.4/lib/python3.8/site-packages:/gnu/store/ihl3h0s000vlkvadxvv21cbn4fqzvmav-python-idna-2.10/lib/python3.8/site-packages:/gnu/store/ysvrcvvaajbg432f7pr0k8x2w21lnz81-python-chardet-3.0.4/lib/python3.8/site-packages:/gnu/store/2j54g0s8db1b10ggs4rirfb5vv8abm2y-python-certifi-2020.12.5/lib/python3.8/site-packages:/gnu/store/q01v2xjfcl7d020y3yh865695gm8i3gx-python-iso8601-0.1.13/lib/python3.8/site-packages:/gnu/store/xkcc4372psi79xiidw4k33nmyf6mk36h-python-asn1crypto-1.4.0/lib/python3.8/site-packages:/gnu/store/xgsczafbfkmqmanm87nx2qfyzp4h313i-python-pysocks-1.7.1/lib/python3.8/site-packages:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"exec
-a "$0" "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey_agent.py-real"
"$@"--8<---------------cut here---------------end--------------->8---*




Regards,
Antwane


On Thu, Sep 16, 2021 at 8:06 AM Hartmut Goebel <h.goebel@crazy-compilers.com>
wrote:

> Am 07.09.21 um 19:39 schrieb Antwane Mason:
> > File
> >
> "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py",
>
> > line 2
> >     export PYTHONPATH="/gnu/store/…-
>
> This looks like an error in the package definition: A .py-file contains
> a shell command.
>
> HTH
>
> --
> Regards
> Hartmut Goebel
>
> | Hartmut Goebel          | h.goebel@crazy-compilers.com               |
> | www.crazy-compilers.com | compilers which you thought are impossible |
>
>

[-- Attachment #2: Type: text/html, Size: 13332 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-18 19:44   ` Antwane Mason
@ 2021-09-19 16:31     ` Antwane Mason
  2021-09-20 12:32     ` Hartmut Goebel
  1 sibling, 0 replies; 9+ messages in thread
From: Antwane Mason @ 2021-09-19 16:31 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 10728 bytes --]

On Sat, Sep 18, 2021 at 3:44 PM Antwane Mason <ad.mason1413@gmail.com>
wrote:

>
> From what I can tell, one of the build phases responsible for wrapping
> executables into shell scripts is wrongly wrapping one of the python files.
> This causes the shell script which is named as the original python file to
> be loaded as a python module causing a syntax error because the export line
> is a shell directive and not valid python syntax. Below is the stack trace
> again for reference.  The last file referenced in the stack trace is a
> shell script wrapper for the original onlykey_agent.py file which was
> renamed .onlykey_agent.py-real. Below is the full file for this shell
> script. Can anyone provide guidance as to which build phase needs to change
> and how to change it to prevent onlykey_agent.py from being wrapped?
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *--8<---------------cut here---------------start------------->8---antwane@wmguix ~$ onlykey-agentTraceback (most recent call last):  File "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey-agent-real", line 11, in <module>    load_entry_point('onlykey-agent==1.1.12', 'console_scripts', 'onlykey-agent')()  File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point    return get_distribution(dist).load_entry_point(group, name)  File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point    return ep.load()  File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load    return self.resolve()  File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve    module = __import__(self.module_name, fromlist=['__name__'], level=0)  File "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py", line 2    export PYTHONPATH="/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/lib/python3.8/site-packages:/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages:/gnu/store/xq0bpzrxy461igy3vwymgmlfg85ghfgv-python-onlykey-1.2.6/lib/python3.8/site-packages:/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages:/gnu/store/gb0xnb6vldlmwiky77w7hxpkjbvp1560-python-wheel-0.36.2/lib/python3.8/site-packages:/gnu/store/7c48ls8c4xddx22yy7rlnszs0fjl56k7-python-unidecode-1.1.1/lib/python3.8/site-packages:/gnu/store/hi8yk6yzivzwpxak2fcggd6zl887n7zj-python-semver-2.9.0/lib/python3.8/site-packages:/gnu/store/gvka9y88b5i6h1fbwb5qxi8vv0ajh6d3-python-pynacl-1.4.0/lib/python3.8/site-packages:/gnu/store/4153n7v3hy0pn2df0c8rag7v4gmgg0ki-python-pymsgbox-1.0.6/lib/python3.8/site-packages:/gnu/store/ppdbw2sl5filj79rl6k0wqy7xkz2603n-python-pycryptodome-3.9.9/lib/python3.8/site-packages:/gnu/store/b2pf54i477iby8f17am9p0x2bz96gn63-python-mnemonic-0.20/lib/python3.8/site-packages:/gnu/store/3vl9a6y7d9r3w3diy2bj15jxd0qgzycv-python-ecdsa-0.14.1/lib/python3.8/site-packages:/gnu/store/1qz6j51mmn2z1za41fb9vs9dgmwisng3-python-docutils-0.16/lib/python3.8/site-packages:/gnu/store/v74q9niaprwv0l25hb1hcyhvyzwp7zmf-python-daemon-2.2.3/lib/python3.8/site-packages:/gnu/store/jvm96kifzns968g0l115chfdp3n5ksba-python-configargparse-1.2.3/lib/python3.8/site-packages:/gnu/store/j3w4j8x76n7wdbjrh377fwx4hwgmfwmy-python-backports.shutil-which-3.5.2/lib/python3.8/site-packages:/gnu/store/hjmz8ymac939ribn7g3jkgms4dk2az3a-python-six-1.14.0/lib/python3.8/site-packages:/gnu/store/bxbhdka9x8pnl7jnpkvz1nvgg2m8xqfs-python-prompt-toolkit-3.0.18/lib/python3.8/site-packages:/gnu/store/2lrpayrb6rrfmscfkfii65jdd328v945-python-onlykey-solo-0.0.28/lib/python3.8/site-packages:/gnu/store/1xmngywbzxx8lb539z4zcggm12gw6lzm-python-hidapi-0.7.99.post21/lib/python3.8/site-packages:/gnu/store/j1qn1pjvpyljmrb7hh1pjsgz44b13y5i-python-cython-0.29.22/lib/python3.8/site-packages:/gnu/store/d5zp1z8vz42c8b69fszck1vqh59npms4-python-aenum-2.2.4/lib/python3.8/site-packages:/gnu/store/sfy8vc8da10appy093izjz4byzd7sfqp-python-cffi-1.14.4/lib/python3.8/site-packages:/gnu/store/wi6ihkh2dq1sj6pq6g28f5vw157kfy8x-python-lockfile-0.12.2/lib/python3.8/site-packages:/gnu/store/xjiplzqxr084ximm4wdhyx3wzf8nxvv0-python-wcwidth-0.1.8/lib/python3.8/site-packages:/gnu/store/kffam5lzshdhb0ygq0r76gqvavs0190c-python-requests-2.25.0/lib/python3.8/site-packages:/gnu/store/qkj3ssg0y3ya0d450pp0kaa7zbg9i0x6-python-pyusb-1.0.2/lib/python3.8/site-packages:/gnu/store/b3k1kmx7rzkykb4ik5nz0jdabqr86vvv-python-pyserial-3.5/lib/python3.8/site-packages:/gnu/store/w3q52n0pc5zvblr8qdsgdfiw33psj6pz-python-intelhex-2.2.1/lib/python3.8/site-packages:/gnu/store/fpk2f2jwqah0s340hdhmr734vvxq3z3j-python-fido2-0.9.1/lib/python3.8/site-packages:/gnu/store/sjiiqs605sfsqxjdkcm3m8rx0ahv5wvv-python-cryptography-3.3.1/lib/python3.8/site-packages:/gnu/store/5a12m99wdfqydzwx46nlfqqvi9q3pq49-python-click-7.1.2/lib/python3.8/site-packages:/gnu/store/k08j1silv8zxfglz3mb5q7ngmya9cv39-python-pycparser-2.20/lib/python3.8/site-packages:/gnu/store/fd7sx13lhrgbrnsa5k3g8inas417p5q5-python-urllib3-1.26.4/lib/python3.8/site-packages:/gnu/store/ihl3h0s000vlkvadxvv21cbn4fqzvmav-python-idna-2.10/lib/python3.8/site-packages:/gnu/store/ysvrcvvaajbg432f7pr0k8x2w21lnz81-python-chardet-3.0.4/lib/python3.8/site-packages:/gnu/store/2j54g0s8db1b10ggs4rirfb5vv8abm2y-python-certifi-2020.12.5/lib/python3.8/site-packages:/gnu/store/q01v2xjfcl7d020y3yh865695gm8i3gx-python-iso8601-0.1.13/lib/python3.8/site-packages:/gnu/store/xkcc4372psi79xiidw4k33nmyf6mk36h-python-asn1crypto-1.4.0/lib/python3.8/site-packages:/gnu/store/xgsczafbfkmqmanm87nx2qfyzp4h313i-python-pysocks-1.7.1/lib/python3.8/site-packages:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"           ^SyntaxError: invalid syntax--8<---------------cut here---------------end--------------->8---*
>
>
>
>
>
>
>
> *--8<---------------cut here---------------start------------->8---#!/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16/bin/bashexport PYTHONPATH="/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/lib/python3.8/site-packages:/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages:/gnu/store/xq0bpzrxy461igy3vwymgmlfg85ghfgv-python-onlykey-1.2.6/lib/python3.8/site-packages:/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages:/gnu/store/gb0xnb6vldlmwiky77w7hxpkjbvp1560-python-wheel-0.36.2/lib/python3.8/site-packages:/gnu/store/7c48ls8c4xddx22yy7rlnszs0fjl56k7-python-unidecode-1.1.1/lib/python3.8/site-packages:/gnu/store/hi8yk6yzivzwpxak2fcggd6zl887n7zj-python-semver-2.9.0/lib/python3.8/site-packages:/gnu/store/gvka9y88b5i6h1fbwb5qxi8vv0ajh6d3-python-pynacl-1.4.0/lib/python3.8/site-packages:/gnu/store/4153n7v3hy0pn2df0c8rag7v4gmgg0ki-python-pymsgbox-1.0.6/lib/python3.8/site-packages:/gnu/store/ppdbw2sl5filj79rl6k0wqy7xkz2603n-python-pycryptodome-3.9.9/lib/python3.8/site-packages:/gnu/store/b2pf54i477iby8f17am9p0x2bz96gn63-python-mnemonic-0.20/lib/python3.8/site-packages:/gnu/store/3vl9a6y7d9r3w3diy2bj15jxd0qgzycv-python-ecdsa-0.14.1/lib/python3.8/site-packages:/gnu/store/1qz6j51mmn2z1za41fb9vs9dgmwisng3-python-docutils-0.16/lib/python3.8/site-packages:/gnu/store/v74q9niaprwv0l25hb1hcyhvyzwp7zmf-python-daemon-2.2.3/lib/python3.8/site-packages:/gnu/store/jvm96kifzns968g0l115chfdp3n5ksba-python-configargparse-1.2.3/lib/python3.8/site-packages:/gnu/store/j3w4j8x76n7wdbjrh377fwx4hwgmfwmy-python-backports.shutil-which-3.5.2/lib/python3.8/site-packages:/gnu/store/hjmz8ymac939ribn7g3jkgms4dk2az3a-python-six-1.14.0/lib/python3.8/site-packages:/gnu/store/bxbhdka9x8pnl7jnpkvz1nvgg2m8xqfs-python-prompt-toolkit-3.0.18/lib/python3.8/site-packages:/gnu/store/2lrpayrb6rrfmscfkfii65jdd328v945-python-onlykey-solo-0.0.28/lib/python3.8/site-packages:/gnu/store/1xmngywbzxx8lb539z4zcggm12gw6lzm-python-hidapi-0.7.99.post21/lib/python3.8/site-packages:/gnu/store/j1qn1pjvpyljmrb7hh1pjsgz44b13y5i-python-cython-0.29.22/lib/python3.8/site-packages:/gnu/store/d5zp1z8vz42c8b69fszck1vqh59npms4-python-aenum-2.2.4/lib/python3.8/site-packages:/gnu/store/sfy8vc8da10appy093izjz4byzd7sfqp-python-cffi-1.14.4/lib/python3.8/site-packages:/gnu/store/wi6ihkh2dq1sj6pq6g28f5vw157kfy8x-python-lockfile-0.12.2/lib/python3.8/site-packages:/gnu/store/xjiplzqxr084ximm4wdhyx3wzf8nxvv0-python-wcwidth-0.1.8/lib/python3.8/site-packages:/gnu/store/kffam5lzshdhb0ygq0r76gqvavs0190c-python-requests-2.25.0/lib/python3.8/site-packages:/gnu/store/qkj3ssg0y3ya0d450pp0kaa7zbg9i0x6-python-pyusb-1.0.2/lib/python3.8/site-packages:/gnu/store/b3k1kmx7rzkykb4ik5nz0jdabqr86vvv-python-pyserial-3.5/lib/python3.8/site-packages:/gnu/store/w3q52n0pc5zvblr8qdsgdfiw33psj6pz-python-intelhex-2.2.1/lib/python3.8/site-packages:/gnu/store/fpk2f2jwqah0s340hdhmr734vvxq3z3j-python-fido2-0.9.1/lib/python3.8/site-packages:/gnu/store/sjiiqs605sfsqxjdkcm3m8rx0ahv5wvv-python-cryptography-3.3.1/lib/python3.8/site-packages:/gnu/store/5a12m99wdfqydzwx46nlfqqvi9q3pq49-python-click-7.1.2/lib/python3.8/site-packages:/gnu/store/k08j1silv8zxfglz3mb5q7ngmya9cv39-python-pycparser-2.20/lib/python3.8/site-packages:/gnu/store/fd7sx13lhrgbrnsa5k3g8inas417p5q5-python-urllib3-1.26.4/lib/python3.8/site-packages:/gnu/store/ihl3h0s000vlkvadxvv21cbn4fqzvmav-python-idna-2.10/lib/python3.8/site-packages:/gnu/store/ysvrcvvaajbg432f7pr0k8x2w21lnz81-python-chardet-3.0.4/lib/python3.8/site-packages:/gnu/store/2j54g0s8db1b10ggs4rirfb5vv8abm2y-python-certifi-2020.12.5/lib/python3.8/site-packages:/gnu/store/q01v2xjfcl7d020y3yh865695gm8i3gx-python-iso8601-0.1.13/lib/python3.8/site-packages:/gnu/store/xkcc4372psi79xiidw4k33nmyf6mk36h-python-asn1crypto-1.4.0/lib/python3.8/site-packages:/gnu/store/xgsczafbfkmqmanm87nx2qfyzp4h313i-python-pysocks-1.7.1/lib/python3.8/site-packages:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"exec -a "$0" "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey_agent.py-real" "$@"--8<---------------cut here---------------end--------------->8---*
>
>
> I think that the build phase that I need to modify is wrap. Does anyone
know how to modify wrap phase to exclude a file from being wrapped? I am
still a GNU Guile beginner so I am having trouble understanding definitions
for wrap phase in guix/build/python-build-system.scm and wrap-program in
guix/build/utils.scm.

[-- Attachment #2: Type: text/html, Size: 11389 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-07 17:39 Python Site Package Syntax Runtime Error Antwane Mason
  2021-09-16 12:06 ` Hartmut Goebel
@ 2021-09-19 17:59 ` Maxime Devos
       [not found]   ` <CAAztfgL+ZmbupibJtAeEQLdLoPwR=BNmnU80YU10Ea35P3jdeA@mail.gmail.com>
  1 sibling, 1 reply; 9+ messages in thread
From: Maxime Devos @ 2021-09-19 17:59 UTC (permalink / raw)
  To: Antwane Mason, guix-devel

[-- Attachment #1: Type: text/plain, Size: 2895 bytes --]

Antwane Mason schreef op di 07-09-2021 om 13:39 [-0400]:
> Has anyone come across the following runtime error when running a python-based
> application in guix? I'm wondering if something went wrong during the package build
>  for python-onlykey-agent that messed up the PYTHONPATH export for the runtime.  I should
>  note that python-onlykey-agent is a program that I have packaged to eventually submit to guix.
> 
> --8<---------------cut here---------------start------------->8---
> export PYTHONPATH="...:/gnu/store/wand0zrwwnds6x636746116cfh3sy50k-python-pyopenssl-20.0.0/lib/python3.8/site-packages${PYTHONPATH:+:}$PYTHONPATH"
> 
> SyntaxError: invalid syntax
> --8<---------------cut here---------------end--------------->8---
> Here is the entire stack trace for reference.
> 
> --8<---------------cut here---------------start------------->8---
> antwane@wmguix ~$ onlykey-agent git@github.com
> Traceback (most recent call last):
>   File "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/.onlykey-agent-real", line 11, in <module>
>     load_entry_point('onlykey-agent==1.1.12', 'console_scripts', 'onlykey-agent')()
>   File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
>     return get_distribution(dist).load_entry_point(group, name)
>   File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
>     return ep.load()
>   File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
>     return self.resolve()
>   File "/gnu/store/sd2ic7bpv8fx3imy1j8xcjclx71sv6q0-python-3.8.2/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
>     module = __import__(self.module_name, fromlist=['__name__'], level=0)
>   File "/gnu/store/s2w1lq80x9vcwp5382kn98f5pi2k4b7b-python-onlykey-agent-1.1.12/bin/onlykey_agent.py", line 2

Why is "onlykey_agent.py" in "bin"?  If it is not a stand-alone library,
shouldn't it be in "share" or "lib"?

Anyway, to prevent onlykey_agent.py from being wrapped, you can replace
the 'wrap' phase with a custom 'wrap' phase adjusted for onlykey-agent pecularities:

(package
  (name "python-onlykey-agent")
  ...
  (arguments
    `(#:phases
      (modify-phases %standard-phases
        (replace 'wrap
          (lambda* (#:key outputs #:allow-other-keys)
            (define bin (string-append (assoc-ref outputs "out") "/bin")
            ;; Replace ??? with something appropriate for onlykey-agent 
            (wrap-program (string-append bin "/onlykey-agent)
               `("PYTHONPATH" '??? '???))
            'maybe-wrap-other-things
            '???))))))

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-18 19:44   ` Antwane Mason
  2021-09-19 16:31     ` Antwane Mason
@ 2021-09-20 12:32     ` Hartmut Goebel
  2021-09-20 20:28       ` Antwane Mason
  1 sibling, 1 reply; 9+ messages in thread
From: Hartmut Goebel @ 2021-09-20 12:32 UTC (permalink / raw)
  To: Antwane Mason; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]

Am 18.09.21 um 21:44 schrieb Antwane Mason:
> From what I can tell, one of the build phases responsible for wrapping 
> executables into shell scripts is wrongly wrapping one of the python 
> files. This causes the shell script which is named as the original 
> python file to be loaded as a python module causing a syntax error 
> because the export line is a shell directive and not valid python 
> syntax. Below is the stack trace again for reference.  The last file 
> referenced in the stack trace is a shell script wrapper for the 
> original onlykey_agent.py file which was renamed 
> .onlykey_agent.py-real. Below is the full file for this shell script. 
> Can anyone provide guidance as to which build phase needs to change 
> and how to change it to prevent onlykey_agent.py from being wrapped?


Looking at the code of the package - which actually is quite simple - I 
discover

    scripts=['onlykey_agent.py'],

This might indeed trigger some issue in phase wrap. Please open a 
bug-report for this, explicitly pointing to release v1.1.11 of that package.

As a solution for you I propose replacing the aforementioned line in 
setup.py by this line:

     py_modules=['onlykey_agent'],

I also suggest reporting this upstream, since I assume having 
onlykey_agent.py in bin is not desired. (Actually this is not a working 
script at all.)

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |


[-- Attachment #2: Type: text/html, Size: 2558 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
       [not found]   ` <CAAztfgL+ZmbupibJtAeEQLdLoPwR=BNmnU80YU10Ea35P3jdeA@mail.gmail.com>
@ 2021-09-20 20:10     ` Antwane Mason
  0 siblings, 0 replies; 9+ messages in thread
From: Antwane Mason @ 2021-09-20 20:10 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 5891 bytes --]

On Sun, Sep 19, 2021 at 1:59 PM Maxime Devos <maximedevos@telenet.be> wrote:

> Anyway, to prevent onlykey_agent.py from being wrapped, you can replace
> the 'wrap' phase with a custom 'wrap' phase adjusted for onlykey-agent
> pecularities:
>
> (package
>   (name "python-onlykey-agent")
>   ...
>   (arguments
>     `(#:phases
>       (modify-phases %standard-phases
>         (replace 'wrap
>           (lambda* (#:key outputs #:allow-other-keys)
>             (define bin (string-append (assoc-ref outputs "out") "/bin")
>             ;; Replace ??? with something appropriate for onlykey-agent
>             (wrap-program (string-append bin "/onlykey-agent)
>                `("PYTHONPATH" '??? '???))
>             'maybe-wrap-other-things
>             '???))))))
>
>
Maxime, thank you for the suggestion! I ended up with the following which
worked somewhat better but was running into runtime issues. Wanted to post
my code snippet here in case this is helpful to someone else.
This is a slight modification of code for wrap phase from
guix/build/python-build-system.scm.

--8<---------------cut here---------------start------------->8---
(arguments
     '(#:phases
       (modify-phases %standard-phases
         ;; prevents runtime error where shell wrapper for onlykey_agent.py
is loaded as module
         (replace 'wrap
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (define (list-of-files dir)
               (find-files dir (lambda (file stat)
                                 (and (eq? 'regular (stat:type stat))
                                      (not (wrapper? file))
                                      (not ((file-name-predicate
"onlykey_agent.py")
                                            file
                                            stat))))))

             (define bindirs
               (let ((out (assoc-ref outputs "out")))
                 (list (string-append out "/bin")
                       (string-append out "/sbin"))))

             (let* ((out  (assoc-ref outputs "out"))
                    (python (assoc-ref inputs "python"))
                    (var `("PYTHONPATH" prefix
                           ,(cons (string-append out "/lib/python"
                                                 (python-version python)
                                                 "/site-packages")
                                  (search-path-as-string->list
                                   (or (getenv "PYTHONPATH") ""))))))
               (for-each (lambda (dir)
                           (let ((files (list-of-files dir)))
                             (for-each (lambda (file) (wrap-program file
var))
                                       files)))
                         bindirs)
               #t))))))
--8<---------------cut here---------------end--------------->8---

Regards,
Antwane


On Mon, Sep 20, 2021 at 4:09 PM Antwane Mason <ad.mason1413@gmail.com>
wrote:

>
> On Sun, Sep 19, 2021 at 1:59 PM Maxime Devos <maximedevos@telenet.be>
> wrote:
>
>> Anyway, to prevent onlykey_agent.py from being wrapped, you can replace
>> the 'wrap' phase with a custom 'wrap' phase adjusted for onlykey-agent
>> pecularities:
>>
>> (package
>>   (name "python-onlykey-agent")
>>   ...
>>   (arguments
>>     `(#:phases
>>       (modify-phases %standard-phases
>>         (replace 'wrap
>>           (lambda* (#:key outputs #:allow-other-keys)
>>             (define bin (string-append (assoc-ref outputs "out") "/bin")
>>             ;; Replace ??? with something appropriate for onlykey-agent
>>             (wrap-program (string-append bin "/onlykey-agent)
>>                `("PYTHONPATH" '??? '???))
>>             'maybe-wrap-other-things
>>             '???))))))
>>
>>
> Thank you for the suggestion! I ended up with the following which worked
> somewhat better but was running into runtime issues. Wanted to post my code
> snippet here in case this is helpful to someone else.
> This is a slight modification of code for wrap phase from
> guix/build/python-build-system.scm.
>
> --8<---------------cut here---------------start------------->8---
> (arguments
>      '(#:phases
>        (modify-phases %standard-phases
>          ;; prevents runtime error where shell wrapper for
> onlykey_agent.py is loaded as module
>          (replace 'wrap
>            (lambda* (#:key inputs outputs #:allow-other-keys)
>              (define (list-of-files dir)
>                (find-files dir (lambda (file stat)
>                                  (and (eq? 'regular (stat:type stat))
>                                       (not (wrapper? file))
>                                       (not ((file-name-predicate
> "onlykey_agent.py")
>                                             file
>                                             stat))))))
>
>              (define bindirs
>                (let ((out (assoc-ref outputs "out")))
>                  (list (string-append out "/bin")
>                        (string-append out "/sbin"))))
>
>              (let* ((out  (assoc-ref outputs "out"))
>                     (python (assoc-ref inputs "python"))
>                     (var `("PYTHONPATH" prefix
>                            ,(cons (string-append out "/lib/python"
>                                                  (python-version python)
>                                                  "/site-packages")
>                                   (search-path-as-string->list
>                                    (or (getenv "PYTHONPATH") ""))))))
>                (for-each (lambda (dir)
>                            (let ((files (list-of-files dir)))
>                              (for-each (lambda (file) (wrap-program file
> var))
>                                        files)))
>                          bindirs)
>                #t))))))
> --8<---------------cut here---------------end--------------->8---
>

[-- Attachment #2: Type: text/html, Size: 8774 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-20 12:32     ` Hartmut Goebel
@ 2021-09-20 20:28       ` Antwane Mason
  2021-09-20 20:45         ` Hartmut Goebel
  0 siblings, 1 reply; 9+ messages in thread
From: Antwane Mason @ 2021-09-20 20:28 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 3637 bytes --]

On Mon, Sep 20, 2021 at 8:32 AM Hartmut Goebel <h.goebel@crazy-compilers.com>
wrote:

> Looking at the code of the package - which actually is quite simple - I
> discover
>
> scripts=['onlykey_agent.py'],
>
> This might indeed trigger some issue in phase wrap. Please open a
> bug-report for this, explicitly pointing to release v1.1.11 of that package.
>
> As a solution for you I propose replacing the aforementioned line in
> setup.py by this line:
>
>     py_modules=['onlykey_agent'],
>
> I also suggest reporting this upstream, since I assume having onlykey_agent.py
> in bin is not desired. (Actually this is not a working script at all.)
>
> Thank you for the suggestion!  Taking your advice, I ended up with the
following snippet which ends up being simpler than overwriting the wrap
phase.
The main parts added are the modules field and snippet field; I simply
added the whole source field so it is clear where those two fields go
within the package definition.

--8<---------------cut here---------------start------------->8---
(source
      (origin
        (method url-fetch)
        (uri (pypi-uri "onlykey-agent" version))
        (sha256
          (base32
            "1586zhpph79s12alnyj1iiiwj0c5h1z8na2lqczf560p5mca6gxw"))
        (modules '((guix build utils)))
        (snippet
         '(begin (substitute* "setup.py"
                   (("scripts=\\['onlykey_agent.py'\\]")
                    "py_modules=['onlykey_agent']"))
                 #t))))
--8<---------------cut here---------------end--------------->8---

After reinstalling onlykey-agent with the above change, I got the following
runtime error when running onlykey-gpg init "Firstname Lastname <
test@gmail.com>".

--8<---------------cut here---------------start------------->8---
Traceback (most recent call last):
  File
"/gnu/store/rg6jn2bhrgmfhbkiprsjp3rc5gxi55lp-python-onlykey-agent-1.1.12/bin/.onlykey-gpg-real",
line 11, in <module>
    load_entry_point('onlykey-agent==1.1.12', 'console_scripts',
'onlykey-gpg')()
  File
"/gnu/store/rg6jn2bhrgmfhbkiprsjp3rc5gxi55lp-python-onlykey-agent-1.1.12/lib/python3.8/site-packages/onlykey_agent.py",
line 6, in <lambda>
    gpg_tool = lambda: libagent.gpg.main(DeviceType)
  File
"/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages/libagent/gpg/__init__.py",
line 381, in main
    return args.func(device_type=device_type, args=args)
  File
"/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages/libagent/gpg/__init__.py",
line 154, in run_init
    agent_path = util.which('{}-gpg-agent'.format(device_name))
  File
"/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages/libagent/util.py",
line 212, in wrapper
    result = func(*args, **kwargs)
  File
"/gnu/store/ahbp2qnrx7m6m5yrxcfsf37gqmgkm13c-python-lib-agent-1.0.3/lib/python3.8/site-packages/libagent/util.py",
line 248, in which
    raise OSError('Cannot find {!r} in $PATH'.format(cmd))
OSError: Cannot find '.onlykey-gpg-gpg-agent' in $PATH
--8<---------------cut here---------------end--------------->8---

From what I can tell, the issue is that the inherited __str__ for Onlykey
class uses __name__ which resolves to '.onlykey-gpg'. This results in
trying to get the full path for
'.onlykey-gpg-gpg-agent' which doesn't exist. I think it should be instead
trying to get the path of 'onlykey-gpg-agent'. I plan on trying to patch
lib-agent to define a __str__ method that returns 'onlykey' for Onlykey
class.
I'm hoping that will fix the issue.

At the end of this, I plan to submit a bug report as you suggested.

[-- Attachment #2: Type: text/html, Size: 5536 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Python Site Package Syntax Runtime Error
  2021-09-20 20:28       ` Antwane Mason
@ 2021-09-20 20:45         ` Hartmut Goebel
  0 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2021-09-20 20:45 UTC (permalink / raw)
  To: Antwane Mason; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

Am 20.09.21 um 22:28 schrieb Antwane Mason:
>         (snippet
>          '(begin (substitute* "setup.py"
>                    (("scripts=\\['onlykey_agent.py'\\]")
>                     "py_modules=['onlykey_agent']"))
>                  #t))))
>
Typically these kind of changes go into a phase. Search other package 
declarations for "substitute" to see how this is done. source-snippets 
are primary for removing binaries and proprietary code.

Regarding the other issue, I can't give any advice, since I don't know 
the code :-)

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |


[-- Attachment #2: Type: text/html, Size: 1813 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-20 20:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 17:39 Python Site Package Syntax Runtime Error Antwane Mason
2021-09-16 12:06 ` Hartmut Goebel
2021-09-18 19:44   ` Antwane Mason
2021-09-19 16:31     ` Antwane Mason
2021-09-20 12:32     ` Hartmut Goebel
2021-09-20 20:28       ` Antwane Mason
2021-09-20 20:45         ` Hartmut Goebel
2021-09-19 17:59 ` Maxime Devos
     [not found]   ` <CAAztfgL+ZmbupibJtAeEQLdLoPwR=BNmnU80YU10Ea35P3jdeA@mail.gmail.com>
2021-09-20 20:10     ` Antwane Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).