msg355599 - (view) |
Author: Peter Bittner (bittner) * |
Date: 2019-10-28 22:39 |
A popular question on StackOverflow is, "How do I find the location of my Python site-packages directory?" [1]
While this may hint at a deeper problem that needs to be solved, a user suggested [2] the accepted answer to be added to Python's official documentation.
The most appropriate place I could find to add related information is ``Doc/tutorial/modules.rst``.
[1] https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory/46071447
[2] https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory/46071447#comment103247041_46071447
|
msg359402 - (view) |
Author: Vinay Keerthi (stonecharioteer) |
Date: 2020-01-06 05:56 |
Just chiming in my opinion, the site-packages directory is also dependent on venv, correct? So would explaining where it is at a global install level be much use? Or do you mean explaining where site-packages is even for a venv?
I could take this up, if some agrees that jr needs doing.
|
msg359404 - (view) |
Author: Inada Naoki (methane) * |
Date: 2020-01-06 06:48 |
There is a document about it in Doc/library/site.rst already.
I'm not sure this should be documented in the tutorial.
|
msg359411 - (view) |
Author: Peter Bittner (bittner) * |
Date: 2020-01-06 09:32 |
There is a specific question this change attempts to answer: "Where is the module I imported located in the file system?"
I suspect this comes up a lot because developers want to inspect or mess with installed modules, add debug output and the like, to understand some of their development issues better.
The site module documentation explains the details.[3] The paragraph the change adds links to that documentation. That should be sufficient (for a tutorial); other technical details probably fit well in the document being linked to.
[3] https://docs.python.org/3/library/site.html#site.getusersitepackages
I tried to keep it concise, adding value with a quick glance over the `site` module features that relate to the module paths topic.
|
msg359412 - (view) |
Author: Inada Naoki (methane) * |
Date: 2020-01-06 09:50 |
> There is a specific question this change attempts to answer: "Where is the module I imported located in the file system?"
So `print(the_module.__file__)` is better answer. (or `pip list -v` if the module is third party package installed via pip).
`python -m site` doesn't tell you where the imported module came from.
> [3] https://docs.python.org/3/library/site.html#site.getusersitepackages
After merging PR 17858, you can use :ref:`site-commandline` for cross reference.
|
msg359447 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2020-01-06 18:25 |
I agree with Inada-san that pointing out how to get the file path on a module is a better solution then explaining directory layouts which are borderline implementation details.
|
msg359493 - (view) |
Author: Inada Naoki (methane) * |
Date: 2020-01-07 07:58 |
New changeset ca94677a6216e2d41b04574986ce49d31a0b329c by Inada Naoki in branch 'master':
bpo-38623: Doc: Add section for site module CLI. (GH-17858)
https://github.com/python/cpython/commit/ca94677a6216e2d41b04574986ce49d31a0b329c
|
msg359494 - (view) |
Author: miss-islington (miss-islington) |
Date: 2020-01-07 08:04 |
New changeset 72995c5cdd7ad4af6252bbe129e8fc63f5006130 by Miss Islington (bot) in branch '3.7':
bpo-38623: Doc: Add section for site module CLI. (GH-17858)
https://github.com/python/cpython/commit/72995c5cdd7ad4af6252bbe129e8fc63f5006130
|
msg359495 - (view) |
Author: miss-islington (miss-islington) |
Date: 2020-01-07 08:04 |
New changeset a6b37589a05c63abec122d3a00785641a3bcd85a by Miss Islington (bot) in branch '3.8':
bpo-38623: Doc: Add section for site module CLI. (GH-17858)
https://github.com/python/cpython/commit/a6b37589a05c63abec122d3a00785641a3bcd85a
|
msg359497 - (view) |
Author: Inada Naoki (methane) * |
Date: 2020-01-07 08:23 |
It is tempting that putting some paragraphs to the tutorial when you think "this should be documented!" but there is no good place in the library reference.
HOWTOs is the document for advanced topics. But it doesn't cover wide area yet. There is no topic about module search path or site-packages.
Since the tutorial covers a wide area, including module, it is very tempting to add many random notes about module.
But please remember that the primary reader is people new to Python. (I learned Python 2.4 by the tutorial!)
The reader has learned Python syntax and basic types in chapters 1~5 and now learning how to split a Python program into multiple files.
So please don't try to answer the question in Stackoverflow in the tutorial, unless it is worth enough for the reader.
|
msg359560 - (view) |
Author: Peter Bittner (bittner) * |
Date: 2020-01-07 23:18 |
Python learners deserve to know about "site-packages" and (optionally) "dist-packages". This is a "random note", it's an explanation that is missing in the tutorial.
- Site-packages "is the target directory of manually built Python packages", does someone explain.[4]
- It is the "expected convention for locally installed packages", explains Greg Ward in "Installing Python Modules".[5]
- Their location is only a subset of `sys.path`, as visible from the Python code in the `site` module.[6]
The tutorial currently mentions its special role only briefly [7], saying:
> * The installation-dependent default.
We should explain that part. I'll give it a shot replacing my earlier proposal.
[4] https://stackoverflow.com/questions/31384639/what-is-pythons-site-packages-directory
[5] https://docs.python.org/3.8/install/#modifying-python-s-search-path
[6] https://github.com/python/cpython/blob/master/Lib/site.py#L319-L344
[7] https://docs.python.org/3.8/tutorial/modules.html?highlight=installation-dependent%20default#the-module-search-path
|
msg359566 - (view) |
Author: Inada Naoki (methane) * |
Date: 2020-01-08 06:04 |
> The tutorial currently mentions its special role only briefly [7], saying:
>
>> * The installation-dependent default.
>
> We should explain that part. I'll give it a shot replacing my earlier proposal.
I don't think so. At there, the tutorial doesn't explain about even standard library. We shouldn't explain about it there.
It should be explained much later in the tutorial, or document other than the tutorial.
|
msg359623 - (view) |
Author: Brett Cannon (brett.cannon) * |
Date: 2020-01-08 18:55 |
I think "Python learners deserve to know about "site-packages" and (optionally) "dist-packages" " is a bit strong of a statement. I don't think the tutorial covers how to install third-party package which is what goes into site-packages, so I don't know what benefit they will garner from having that covered in the tutorial to teach the basics of Python. In an intermediate tutorial I can totally understand the explanation along with using e.g. pip, but for a tutorial like this I still think it's unnecessary.
|
msg402533 - (view) |
Author: Łukasz Langa (lukasz.langa) * |
Date: 2021-09-23 21:40 |
New changeset 55b45bf707c6c8084db259fe2f8aa08e84ea0d99 by Peter Bittner in branch 'main':
bpo-38623: Add note about site module (site-packages) (GH-16974)
https://github.com/python/cpython/commit/55b45bf707c6c8084db259fe2f8aa08e84ea0d99
|
msg402536 - (view) |
Author: Łukasz Langa (lukasz.langa) * |
Date: 2021-09-23 22:48 |
New changeset 87f97fe5e6434da51246d70af9e2cd7d63c29fba by Miss Islington (bot) in branch '3.10':
bpo-38623: Add note about site module (site-packages) (GH-16974) (GH-28536)
https://github.com/python/cpython/commit/87f97fe5e6434da51246d70af9e2cd7d63c29fba
|
msg402537 - (view) |
Author: Łukasz Langa (lukasz.langa) * |
Date: 2021-09-23 22:48 |
New changeset d672dd34f0bc3addeaf1789d4183e3a37ab110d5 by Miss Islington (bot) in branch '3.9':
bpo-38623: Add note about site module (site-packages) (GH-16974) (GH-28537)
https://github.com/python/cpython/commit/d672dd34f0bc3addeaf1789d4183e3a37ab110d5
|
msg402538 - (view) |
Author: Łukasz Langa (lukasz.langa) * |
Date: 2021-09-23 22:48 |
Thanks, Peter! ✨ 🍰 ✨
|
msg403170 - (view) |
Author: Pablo Galindo Salgado (pablogsal) * |
Date: 2021-10-04 19:18 |
New changeset cdfbe581bae1b33d4eb135597cd27b0f3782e97e by Pablo Galindo (Miss Islington (bot)) in branch '3.10':
bpo-38623: Add note about site module (site-packages) (GH-16974) (GH-28536)
https://github.com/python/cpython/commit/cdfbe581bae1b33d4eb135597cd27b0f3782e97e
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:22 | admin | set | github: 82804 |
2021-10-04 19:18:43 | pablogsal | set | nosy:
+ pablogsal messages:
+ msg403170
|
2021-09-23 22:48:59 | lukasz.langa | set | status: open -> closed versions:
+ Python 3.10, Python 3.11, - Python 3.7, Python 3.8 messages:
+ msg402538
resolution: fixed stage: patch review -> resolved |
2021-09-23 22:48:29 | lukasz.langa | set | messages:
+ msg402537 |
2021-09-23 22:48:12 | lukasz.langa | set | messages:
+ msg402536 |
2021-09-23 21:40:11 | miss-islington | set | pull_requests:
+ pull_request26922 |
2021-09-23 21:40:07 | miss-islington | set | pull_requests:
+ pull_request26921 |
2021-09-23 21:40:02 | lukasz.langa | set | nosy:
+ lukasz.langa messages:
+ msg402533
|
2020-01-08 18:55:26 | brett.cannon | set | messages:
+ msg359623 |
2020-01-08 06:04:29 | methane | set | messages:
+ msg359566 |
2020-01-07 23:18:32 | bittner | set | messages:
+ msg359560 |
2020-01-07 08:23:48 | methane | set | messages:
+ msg359497 |
2020-01-07 08:04:47 | miss-islington | set | messages:
+ msg359495 |
2020-01-07 08:04:38 | miss-islington | set | nosy:
+ miss-islington messages:
+ msg359494
|
2020-01-07 07:58:59 | miss-islington | set | pull_requests:
+ pull_request17301 |
2020-01-07 07:58:52 | miss-islington | set | pull_requests:
+ pull_request17300 |
2020-01-07 07:58:46 | methane | set | messages:
+ msg359493 |
2020-01-06 18:25:00 | brett.cannon | set | messages:
+ msg359447 |
2020-01-06 09:50:58 | methane | set | messages:
+ msg359412 |
2020-01-06 09:32:48 | bittner | set | messages:
+ msg359411 |
2020-01-06 07:25:09 | methane | set | pull_requests:
+ pull_request17278 |
2020-01-06 06:48:02 | methane | set | nosy:
+ methane messages:
+ msg359404
|
2020-01-06 05:56:44 | stonecharioteer | set | nosy:
+ stonecharioteer messages:
+ msg359402
|
2020-01-06 00:09:41 | cheryl.sabella | set | nosy:
+ brett.cannon
versions:
- Python 2.7, Python 3.5, Python 3.6 |
2019-10-28 22:45:51 | bittner | set | keywords:
+ patch stage: patch review pull_requests:
+ pull_request16500 |
2019-10-28 22:39:25 | bittner | create | |