From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +GPtC5W7oWG5mAAAgWs5BA (envelope-from ) for ; Sat, 27 Nov 2021 06:01:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WEGgB5W7oWH4aAAA1q6Kng (envelope-from ) for ; Sat, 27 Nov 2021 05:01:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BA08C2FA92 for ; Sat, 27 Nov 2021 06:01:08 +0100 (CET) Received: from localhost ([::1]:58422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqppj-0000pP-Pm for larch@yhetil.org; Sat, 27 Nov 2021 00:01:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqppF-0000pH-4m for guix-devel@gnu.org; Sat, 27 Nov 2021 00:00:37 -0500 Received: from [2607:f8b0:4864:20::82f] (port=40579 helo=mail-qt1-x82f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mqpp8-0002Qd-4x for guix-devel@gnu.org; Sat, 27 Nov 2021 00:00:36 -0500 Received: by mail-qt1-x82f.google.com with SMTP id t34so10833544qtc.7 for ; Fri, 26 Nov 2021 21:00:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:subject:references:to:cc:date:in-reply-to:message-id :user-agent:mime-version; bh=0NIIrECGU1A1CiqU0Y+dGM9MUi/5Y04vCbC59QtgtJE=; b=c+QSKeNlDcUGFyR5zc9LcxrPOe3k03uVgIZFR7VDlrxQe5QdbEZFVXpccZEx65RFnI L2jB2hce4I5YT68YuQ3xaJnT66xK5p1EOeTIonywR+yFhLdqSO9ggJIiwbCRgrMJXkaP KHUxxPLlykcIXkrvFqObnqrltdMqStGmMqDjPpB4Gy6+qYK2RrxcxVmBoDrInEG1ktCA i+4F2ydgB3oB9jMf9n4+/5RrH/LseQUOaoyBGwWbmmBXKiHLONwPk2o0eTKcA5aq3dED 5PCh3yLbmuwe7pPFVtDGPo5+NP9dS6mL9vQ/xyDMfauLROPWCSm17F+b4TxLrYk345cM EfdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:references:to:cc:date:in-reply-to :message-id:user-agent:mime-version; bh=0NIIrECGU1A1CiqU0Y+dGM9MUi/5Y04vCbC59QtgtJE=; b=O3iSVZ43vdVPHZuQQib5FUM7ATgNZnNG602EzKgi4TmexBcDg1Ady+0nKT5LCu913w pBke5G2SbfiKgEYc/sqx1sLYRSutYR2h0z7XAni1Yi1obAmm8JV3sYfR8fGd112BJGW+ lZeym918Tvx1aY0vOUyHYkXz0hbq86cCiKVerBFxySxzBInD7KCX/ClIVPy++hGCE1V3 msPIemIfBh5Vq2ApaMuJa6j21kvB4A4DQtQ7Zzti4mTqj9/vjB4PFdwUVQYWX5K65oEH VKA4pC2ek3mdjooNXo56GjRVsj4wn7YX1CWKthwQn3yIPfyxJOkUscknLvrWYmpsyytO ovCA== X-Gm-Message-State: AOAM531Orf4kZJ6Jj5+aptbC3B74J3oQuNMhzsr1c+XtpEIO41XWtvA3 ouoB8XL8/uqpr7jr+UzBR2THCDNX5qzT6A== X-Google-Smtp-Source: ABdhPJygazUI5Bc4Ovei0VZScyabHvTjIk/DBwGx+QhlVzth51ehwS3vHLWS3F5FCFUcN9kJl+U9Ow== X-Received: by 2002:ac8:7fd0:: with SMTP id b16mr29460017qtk.172.1637989228783; Fri, 26 Nov 2021 21:00:28 -0800 (PST) Received: from hurd (dsl-148-169.b2b2c.ca. [66.158.148.169]) by smtp.gmail.com with ESMTPSA id az16sm4532840qkb.124.2021.11.26.21.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Nov 2021 21:00:28 -0800 (PST) From: Maxim Cournoyer Subject: Re: python-build-system does not wrap script correctly References: to: chuanwei.foo@hotmail.com Date: Sat, 27 Nov 2021 00:00:27 -0500 In-Reply-To: (Foo Chuan Wei's message of "Thu, 25 Nov 2021 08:50:42 +0000") Message-ID: <877dcu8a6s.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1637989268; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=0NIIrECGU1A1CiqU0Y+dGM9MUi/5Y04vCbC59QtgtJE=; b=n/Uk3qCa7XiWxFgU7D1w/nrHvhFNgRqApwSvaOLn4tHYky9Ax3p1PvRyRr4NTKXpAbtgh6 4iwyQwwBs9nTXHklYQBRW/4zxX4RKHMHryHPOeX6GvWTJEyaJONIsqedvLHzP1b5c+t6RH KNxdx201jP1BWM44Y+Ob9RwimdwFzW0tmD5QoPpx9ucMV60cc2QTvz9UTfxw0howrMy3rw h3NjeIR/nMVPqVneoq81M1WE3WiLm0dVXQ6LQcmekcxabZPlwYBnXemxwsdzpvqF1eNfpH FWIXOqVijVNID4jA/HXYMeAcJKvbw/rmvEtuU191oGbGEXyJsOTCDWkL5JXMGw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637989268; a=rsa-sha256; cv=none; b=W+p/6BX5tk9ECKVp0aGBQfFkCW5A3lCgYxPHvl1CHOALiV6AnjyU8zjJOzr4oMDAne6tNW XMkCPBH9aQRUteZquqq7SZSIcF8p95vlD92FTO0WVQDPi0hVS1zK4Gd52NbJR47IOY5mG7 xhMmKt0YChO7WRQLIxAdBOTQKslWnsGzJx4XZIQGrZVL2DStQWhB/I6DNkCTvPzxjdqPT3 XGXndygONw/+bma1unmpgIsQXerSe1j7UP0UEGeVxknNLq5xmJO+kYCDaa5i6knDQgIyCI os5i34DEPnYTNyXt+qe10HNSWexu+qtotRbNND2WqJ/8VUmysagyO7vuR8uPNw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c+QSKeNl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.10 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c+QSKeNl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: BA08C2FA92 X-Spam-Score: -4.10 X-Migadu-Scanner: scn0.migadu.com X-TUID: 02AaPXEmm65G Hello Foo, Foo Chuan Wei writes: > I am trying to package "Speedometer" [1]. This is the package > definition: > > (define-public speedometer > (package > (name "speedometer") > (version "2.8") [...] This package is 10 years old and uses Python 2. I hope it is for the Guix Past channel :-). > It builds and installs successfully. However, when the wrapper script is > run, this error appears: > > Traceback (most recent call last): > File "/gnu/store/chr1cx6ia0is8s9d07s1nzdla30r6vs1-speedometer-2.8/bin/.speedometer-real", line 11, in > load_entry_point('Speedometer==2.8', 'console_scripts', 'speedometer')() > File "/gnu/store/d3jwdk2v7xck82z3y3hs99033m9nkkw0-python2-2.7.17/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point > return get_distribution(dist).load_entry_point(group, name) > File "/gnu/store/d3jwdk2v7xck82z3y3hs99033m9nkkw0-python2-2.7.17/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point > return ep.load() > File "/gnu/store/d3jwdk2v7xck82z3y3hs99033m9nkkw0-python2-2.7.17/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load > return self.resolve() > File "/gnu/store/d3jwdk2v7xck82z3y3hs99033m9nkkw0-python2-2.7.17/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve > module = __import__(self.module_name, fromlist=['__name__'], level=0) > File "/gnu/store/chr1cx6ia0is8s9d07s1nzdla30r6vs1-speedometer-2.8/bin/speedometer.py", line 2 > export PYTHONPATH="/gnu/store/chr1cx6ia0is8s9d07s1nzdla30r6vs1-speedometer-2.8/lib/python2.7/site-packages:/gnu/store/d3jwdk2v7xck82z3y3hs99033m9nkkw0-python2-2.7.17/lib/python2.7/site-packages:/gnu/store/1iszjcyvb537m6cif7fqrrh95r0sg9wp-python2-urwid-2.1.0/lib/python2.7/site-packages${PYTHONPATH:+:}$PYTHONPATH" > ^ > SyntaxError: invalid syntax For the record, I used this to reproduce the problem: --8<---------------cut here---------------start------------->8--- (use-modules (gnu packages python) (gnu packages python-xyz) (guix licenses) (guix packages) (guix download) (guix build-system python)) (define speedometer (package (name "speedometer") (version "2.8") (source (origin (method url-fetch) (uri (pypi-uri "Speedometer" version)) (sha256 (base32 "0qgpjmahy0wlfszqxg0067ck2xab5k6j42d0ifxg1j281yqnm9bx")))) (build-system python-build-system) (arguments `(#:python ,python-2)) (propagated-inputs `(("python2-urwid" ,python2-urwid))) (home-page "https://excess.org/speedometer/") (synopsis "Measure and display the rate of data across a network connection") (description "Console monitor of the rate of data across a network connection or data being stored in a file.") (license lgpl2.1+))) speedometer --8<---------------cut here---------------end--------------->8--- > There is apparently something wrong with the wrapper script. What is it? It's because the speedometer script hacks the arg0 path to resolve the speedometer.py script, which it proceeds to invoke as a python script: --8<---------------cut here---------------start------------->8--- # EASY-INSTALL-ENTRY-SCRIPT: 'Speedometer==2.8','console_scripts','speedometer' __requires__ = 'Speedometer==2.8' import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point('Speedometer==2.8', 'console_scripts', 'speedometer')() ) --8<---------------cut here---------------end--------------->8--- but the 'wrap' phase of the python-build-system has wrapped it (that is, speedometer.py is now a shell script that wraps speedometer.py): Perhaps the wrap phase could have known this wasn't a good idea by looking at the file extension, but in general executables put under bin/ do not have file extensions anyway. So it's a special case which is not handled by the wrap phase. I hope that helps! Maxim