Code for inserting paths into system configuration?

Hi,
I was reflecting on the detail of putting pip user bin directories on the user's path, and was then thinking of making a tiny pip package like this:
pip install pip_user_config python -m pip_user_config
where the latter would cleverly insert the user bin directory into the user's configuration.
Does anyone know of any code to do something like that?
Best,
Matthew

On Sep 13, 2016, at 12:58 PM, Matthew Brett matthew.brett@gmail.com wrote:
Hi,
I was reflecting on the detail of putting pip user bin directories on the user's path, and was then thinking of making a tiny pip package like this:
pip install pip_user_config python -m pip_user_config
where the latter would cleverly insert the user bin directory into the user's configuration.
Does anyone know of any code to do something like that?
This is shell- and platform-specific. This would be a great idea! But it would be a challenging integration project.
-glyph

On 14 September 2016 at 07:00, Glyph Lefkowitz glyph@twistedmatrix.com wrote:
On Sep 13, 2016, at 12:58 PM, Matthew Brett matthew.brett@gmail.com wrote:
I was reflecting on the detail of putting pip user bin directories on the user's path, and was then thinking of making a tiny pip package like this:
pip install pip_user_config python -m pip_user_config
where the latter would cleverly insert the user bin directory into the user's configuration.
Does anyone know of any code to do something like that?
This is shell- and platform-specific. This would be a great idea! But it would be a challenging integration project.
I know the Anaconda installer (the Continuum Analytics one) does this (since I've reported a bug against it for messing up user level access to the system SQLite installation), but I don't know if the code for that is publicly available anywhere (conda itself is open source, but I'm not sure about the build scripts for their installers).
That said, as far as I know, just covering the discrepancy on Debian and Ubuntu between "the system pip is patched to use --user by default" and "~/.local/bin is not on PATH by default when using the default shell" would cover most of the cases where this comes up.
Even short of automating the config change though, there could be significant value in having a "check_install_config" utility that you ran as:
pip install [--user] check_install_config python -m check_install_config
and answered some essential fault diagnosis questions like:
- which Python version is being used? - is there an active virtual environment? - is it a venv environment or a virtualenv one? - where will package installations go by default? - where will they go with --user specified? - where will script installations go in those two cases? - are both of the binary install directories on the user's executable path?
Cheers, NIck.

On 14 September 2016 at 14:13, Nick Coghlan ncoghlan@gmail.com wrote:
On 14 September 2016 at 07:00, Glyph Lefkowitz glyph@twistedmatrix.com wrote:
On Sep 13, 2016, at 12:58 PM, Matthew Brett matthew.brett@gmail.com wrote:
I was reflecting on the detail of putting pip user bin directories on the user's path, and was then thinking of making a tiny pip package like this:
pip install pip_user_config python -m pip_user_config
where the latter would cleverly insert the user bin directory into the user's configuration.
Does anyone know of any code to do something like that?
This is shell- and platform-specific. This would be a great idea! But it would be a challenging integration project.
I know the Anaconda installer (the Continuum Analytics one) does this (since I've reported a bug against it for messing up user level access to the system SQLite installation)
Thinking about that a bit more, I realised I was misremembering - the bug was in the way "conda env" activation scripts worked, not in the initial installation of Anaconda.
So those activation scripts and the equivalent ones for virtualenv and venv are worth a look for understanding how to configure a currently active shell session (which is shell dependent), while venv management tools like vex and pew show how to launch a new subshell with a reconfigured environment (which is easier to make shell independent and portable across platforms).
What we don't currently have is anything which makes it easy to set up a shell session where you're still using the system Python, but "pip install" is targeting your user site-packages directory (regardless of the system-wide default behaviour - this is the default on Debian & Ubuntu for example, but not yet the default on Fedora et al), and you can run scripts from "~/.local/bin" (this is the default on Fedora, but not on Debian and Ubuntu, and not necessarily on Fedora derivatives either)
Cheers, Nick.
participants (3)
-
Glyph Lefkowitz
-
Matthew Brett
-
Nick Coghlan