Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You can rent this space for only $5 a week.


comp / comp.lang.python / Correct module for site customization of path

SubjectAuthor
* Correct module for site customization of pathTim Johnson
`- Re: Correct module for site customization of pathStefan Ram

1
Subject: Correct module for site customization of path
From: Tim Johnson
Newsgroups: comp.lang.python
Date: Thu, 31 Oct 2024 23:37 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: thjmmj15@gmail.com (Tim Johnson)
Newsgroups: comp.lang.python
Subject: Correct module for site customization of path
Date: Thu, 31 Oct 2024 15:37:44 -0800
Lines: 22
Message-ID: <mailman.65.1730420509.4695.python-list@python.org>
References: <adfac553-cac7-4441-b70a-9197723279d8@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de MuvLB50OuU/TvNydKyxPyAn02JAKf0I1p/2LP3FeZPCA==
Cancel-Lock: sha1:0VEYKhz8gWt1L0KBWVspa0fS+Sc= sha256:5vOhVWs6h4IB2ErMq+f4kWRyBLnEBnoQ95C6L0PC6Pk=
Return-Path: <thjmmj15@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=O6n42lVF;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.037
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'programmer': 0.07;
'subject:module': 0.07; 'received:mail-pg1-x52e.google.com': 0.09;
'ubuntu': 0.09; 'import': 0.15; 'append': 0.16; 'privileges':
0.16; 'take.': 0.16; 'welcome.': 0.16; 'python': 0.16; 'message-
id:@gmail.com': 0.18; 'to:addr:python-list': 0.20; 'option': 0.20;
'ran': 0.22; 'install': 0.23; 'tim': 0.26; 'version.': 0.28;
'error': 0.29; 'header:User-Agent:1': 0.30; 'module': 0.31; 'but':
0.32; 'received:192.168.1': 0.32; 'subject:for': 0.32; 'there':
0.33; 'path': 0.33; 'script': 0.33; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.34; 'using': 0.37; 'received:192.168':
0.37; 'thanks': 0.39; 'single': 0.39; 'appears': 0.40; 'email
addr:gmail.com': 0.63; 'invited': 0.64; 'upgrade': 0.64; 'time.':
0.66; 'site': 0.68; 'matter': 0.68; 'desktop': 0.70;
'subject:site': 0.70; 'hobbyist': 0.84; 'upgrades': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1730417866; x=1731022666; darn=python.org;
h=subject:from:to:content-language:user-agent:mime-version:date
:message-id:from:to:cc:subject:date:message-id:reply-to;
bh=8yGZsq5Cn6pwoYOrzOs1QDzuTsouHzc8iVM2jVJkJRU=;
b=O6n42lVFw0cvTn7fzbc4O3YWpjr9Yht+WXQl3YjaI0J0llaVxpQP4J7i3VlKq03iw+
63E3uKokUXcl6wl4GPxxDsz70Owe1y0MLLFW2it/e7pJhKKFzqdjssYbOeO/yqcio+hU
hp+TY/gPzf2nYz9vUeJj1a3/zgtAAZwiDPD5hFWKMa3lT3Qg7BEDUg8RMGXfpRL4hcT2
wDOIU09u//YOBzTEJMHxuvg4viQTDM4GDxeooRHfqQCEKVRiGI0Jjuoq4EgPzKgwKwCT
sLgf15lOHFPkaGGyWnOMtDnyQIJS4ws5CWSsYBhbamxugHZB1JhDH1gxQFiOBZDR3BfY
+9+Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1730417866; x=1731022666;
h=subject:from:to:content-language:user-agent:mime-version:date
:message-id:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=8yGZsq5Cn6pwoYOrzOs1QDzuTsouHzc8iVM2jVJkJRU=;
b=dBC9gphMn+iqNEAddsKtYa2EL4mGlaDRl4P7YLtL558i14TS8gHdhW2tCdCb8BzLzi
PL2u+/1i5M3afaMaHFSD6RXAVyqcREWjMcmvAI5Okv1HoFG9IDOK2ZWFHLXDC8UbgqGb
YuCagwtifLEADYTfdI39bv7f+MWj4V+YGO5hFLoGgdYrHj305/QtPKpYIO6Zo36Xan7H
emZ/aO/M0bA/UYuf0IZtm7NPbSyvAfjECk6bUPs2DjCkXWdMpo6UIjLHEhYcqFNjpV9O
BIq1nPucekdkptWgHWbjhZux3iFD1YYT/0kkCn/pncckZDq97/81Q+GBxoiIM15MXkYk
ceyw==
X-Gm-Message-State: AOJu0YwaoSmQ+jcbIy8hQONlXThX9/XvoXLRd6Ag+t3ueM4EJ+dyBpo8
lDeNOlfTNkDkuSZhF112M29moiIREZEUjry/Rx2wDxS5Kf5+s0vHf42O7g==
X-Google-Smtp-Source: AGHT+IEqSiDyUl7P7o6OQnlRGyPTCbFZh/HpyPktINbMcWfCXicc419VbhsRA8RfXIcOi//mVk4VbA==
X-Received: by 2002:a17:902:e890:b0:20c:8abc:733a with SMTP id
d9443c01a7336-210c6ca8b77mr275638155ad.53.1730417865552;
Thu, 31 Oct 2024 16:37:45 -0700 (PDT)
User-Agent: Mozilla Thunderbird
Content-Language: en-US
X-Mailman-Approved-At: Thu, 31 Oct 2024 20:21:48 -0400
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <adfac553-cac7-4441-b70a-9197723279d8@gmail.com>
View all headers

FYI: I am retired programmer using a recent upgrade to ubuntu 24.04 and
python 3.12
My needs are that of a hobbyist at this time. I am on a single user home
desktop with root privileges available.

After the recent upgrades I had to install youtube_dl with pipx for the
new python version.
When I ran the script which imported youtube_dl, I got an import error
as it appears the path to the module
was not in sys.path. For me,  it was a simple matter of appending the
path for youtube_dl to sys.path, however,
I would prefer to not have to do an append at every script using it.

There is a boatload of documentation of site path configuration, but
still, I am not sure what option to take.
Recommendations are invited and welcome.

Thanks

--
Tim
thjmmj15@gmail.com

Subject: Re: Correct module for site customization of path
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Fri, 1 Nov 2024 13:26 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Correct module for site customization of path
Date: 1 Nov 2024 13:26:44 GMT
Organization: Stefan Ram
Lines: 40
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <sys.path-20241101141837@ram.dialup.fu-berlin.de>
References: <mailman.65.1730420509.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de NiKV7X27VWyuK8616FaRZQTA4LYr15TFp4LeOSNF2M1zZC
Cancel-Lock: sha1:jlg1XlbmuHvQglIbknMb7jhXEI8= sha256:f9X0TDdrjzGuaHbDEMmpXOruswABgdTjCszbu8tjYMM=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Tim Johnson <thjmmj15@gmail.com> wrote or quoted:
>There is a boatload of documentation of site path configuration, but
>still, I am not sure what option to take.

This import situation's got more layers than a Bay Area burrito:

First off, if you've pip-installed a module like a good little
dev, you should be golden for importing. No sweat.

Now, for your homegrown modules, you can make them pip-friendly by
tossing in the right files and giving them the ol' pip install.

If you wanna keep tweaking that bad boy, you can go for an
"editable" install with pip, but lately, they're asking for
all these extra files now, like you're trying to get a permit
to build a tiny house in your backyard.

Some Python versions have this janky workaround where you
manually create a .pth file in the Lib/site-packages directory
with the path to your module. Not sure if this flies on Linux,
but it might be worth taking for a spin since it could be just
what the doctor ordered for your use case. Fair warning though,
you'll probably have to rinse and repeat this little dance
every time you slap a fresh Python version on your rig.

Of course, you can always expand sys.path at runtime before
importing, but some libraries (looking at you, mypy) might
ghost you harder than a Tinder date.

Then there's relative imports, which let you pull from
subdirectories (or even parent directories, but only if
you're working within a package).

Lastly, there's what I call the "Silicon Valley startup
office" approach: just throw everything – scripts, modules,
the kitchen sink – into one directory. It's messy as hell,
but hey, at least you know where everything is, right?
No need to fiddle with sys.path or installations.

1

rocksolid light 0.9.8
clearnet tor