Repository navigation
Description
A couple of things I've realised we need to clearly establish for the packaging user guide are:
- Which commands can folks contributing to the packaging guide or working on the PyPI user experience assume will "just work" on an end user's machine?
- How much guidance should the packaging tutorials provide on ensuring a system is in that state, given the wide variety of potential starting states?
Right now, we don't clearly document those environmental assumptions anywhere, which then makes it hard to provide a checklist for people to work through and ensure their environment is set up correctly.
The closest we currently get to this is to include a fairly cursory introduction to virtualenv in the package installation tutorial, and then implicitly assuming that the following is true in the rest of the guide:
- the user is working at a command prompt (whether inside their IDE, or in an actual system shell)
- the command
pythonwill run the desired version of Python - the commands
pip installandpython -m pip installwill be essentially equivalent (aside from the differences when upgrading pip itself on Windows) and install packages into the desired version of Python - any executables installed that way will be executable from that command prompt
- any Python import packages installed that way will be importable from a Python shell started in that environment
Those assumptions are true once you're inside an activated virtual environment, but they're not true in the general case due to the differences between per-user Python installations and system-wide ones, and the differences in cross-platform conventions when it comes to learning how to start Python.
(Issue prompted by https://mail.python.org/pipermail/python-ideas/2017-November/047708.html, #394, and pypa/pip#3164)
Additional related documentation:
- Bootstrapping guide for Linux: https://packaging.python.org/guides/installing-using-linux-tools/
- CPython's getting started guide: https://docs.python.org/3/installing/
Activity
ncoghlan commentedon Nov 11, 2017
Something else this would let us do is document how various ways of obtaining Python fare in terms of meeting the baseline assumptions:
We'd then encourage alternate distributors to document how their particular solution covers the baseline assumptions.
ncoghlan commentedon Nov 12, 2017
Something I'm wondering is whether or not we could reduce the assumptions to an actual concrete set of commands for a user to optionally work through as a troubleshooting script, such as:
And then have a "Python installation trouble-shooting guide" that walked through each command and the various ways they can go wrong, like:
ncoghlan commentedon Nov 29, 2017
While they're not the main focus of the PR, I've made some improvements to this in #402
theacodes commentedon Feb 9, 2018
There's a lot of good ideas here, but I'm unsure of what is actionable. @ncoghlan can you help me break this down into concrete things that need to happen? Do we need a new guide called
Setting up a baseline Python environmentor similar?ncoghlan commentedon Feb 11, 2018
Yeah, I think a new Guide would be a good way to handle this.
#399 is an example of needing this kind of information, since "apt-get install python3" will give you a Python where venv's are still missing pip by default.
[-]Review initial bootstrapping instructions in pip tutorial[/-][+]Create a new guide for setting up a baseline Python environment[/+]pradyunsg commentedon Mar 29, 2018
Is anyone working on this?
This would be really useful and I'm happy to help in any way to push this forward. Happy to write as well, if someone would be willing to provide some guidance. :)
ncoghlan commentedon Mar 29, 2018
I'm not aware of anyone currently working on it, and even a relatively rough first version becomes something we can iterate on based on feedback.
theacodes commentedon Mar 29, 2018
Go for it. I'm always happy to review. You're welcome to just put up a skeleton/outline and I can review that to ensure structure is good before you start fleshing out sections.
pradyunsg commentedon Mar 30, 2018
Awesome. Will definitely post a structure in a bit.
I'm gonna do a lot of presentations + writing + planning work this weekend. This should fit right in. :)
pradyunsg commentedon Apr 3, 2018
Just noting here that I didn't get the time to work on this.
ncoghlan commentedon May 3, 2018
From pypa/pipenv#2122, another potential issue that can come up is situations where
PATHandsys.pathmay end up checking different locations in different orders, such that a command found onPATHdoesn't find the matching version of itself onsys.path.pradyunsg commentedon May 10, 2018
Coming to this now, I'm thinking of roughly something like:
Talk about why we have this document
Have a list here, of what things should be available and things that should match up etc
Provide instructions on how to verify that your environment matches the requirements above
If an environment isn't meeting the baseline requirements, some pointers on how to debug them.
How do you get from a "fresh" system to an environment described above. (this is where we link to the existing tutorials/guides)
pradyunsg commentedon May 10, 2018
And that last section also provides any platform specific instructions needed. (like you need to not fiddle with system packages on Linux and Mac, PATH caveats, not needing a virtualenv on Windows etc)
pradyunsg commentedon May 20, 2018
Thinking about the expectations:
pradyunsg commentedon May 20, 2018
That last comment went prematurely. Edited to completion.
Thoughts?
ncoghlan commentedon May 21, 2018
Yep, I think that's what we have in mind.
ncoghlan commentedon May 30, 2018
Via @Mariatta, there's a new Real Python article covering getting set up across different platforms: https://realpython.com/installing-python/
pradyunsg commentedon Jun 18, 2018
Thinking about the "validate your Python setup" automation, I'm facing a sort of bootstrapping issue. There's no cross-platform way to actually run something like a script or automated checking unless we're first able to assume that the user knows how to run a script using an installed Python interpreter.
One idea was to explain clearly to the user how to run a script with Python and then use those instructions to make it possible for them to run the script. Any pointers on what we can do for this?
Unrelated: Should we also check
pythonXand the correspondingpipXversions in the automated check?