Re: [pgadmin-hackers] [pgAdmin4] [PATCH] Simplify Server's python setup - Mailing list pgadmin-hackers

From Jan Alexander Steffens
Subject Re: [pgadmin-hackers] [pgAdmin4] [PATCH] Simplify Server's python setup
Date
Msg-id CAMQ-g0cYW-K06smzufY=+g485_hoECzHLH0gq__x85Uij58mRw@mail.gmail.com
Whole thread Raw
In response to Re: [pgadmin-hackers] [pgAdmin4] [PATCH] Simplify Server's python setup  (Dave Page <dpage@pgadmin.org>)
Responses Re: [pgadmin-hackers] [pgAdmin4] [PATCH] Simplify Server's python setup  (Dave Page <dpage@pgadmin.org>)
List pgadmin-hackers


On Wed, Jan 25, 2017 at 2:57 PM Dave Page <dpage@pgadmin.org> wrote:
One where the virtualenv is in a path that's not related to the
location of the runtime. If I'm reading the code correctly, you're
taking the appDir (the location of the runtime executable) and
appending a platform-specific path to the virtual env (e.g. on Linux,
"/../venv/bin/"), and expecting to find the Python executable in the
resulting directory.

However, in a dev environment, we may have the venv in
~/.virtualenvs/pgadmin4 and the runtime in
~/git/pgadmin4/runtime/<builddir> for example. In an RPM based
installation, there is no virtualenv - the Python code is installed in
the system site-packages directory, and the runtime in /usr/bin (which
may or may not be where python is found - assuming it's called that,
and not python3).

> Granted, "/python" is nonsense and should probably just be "python". Also, I
> think PATH doesn't need to be touched at all anymore, so the lines involving
> pathEnv can be removed.

I've now implemented this (see attached updated patch) and Python will configure itself to match whatever usable "python" it finds first in the PATH, including any activated virtualenv.

I think the RPM setup will still work properly, as the non-virtual environment with all system packages is the fallback case.
 
>
> How about a settings key to force the program name? That would allow
> choosing any other virtualenv to run with.

That might be a better option, and is basically how (for example)
Pycharms does it. In that case I'd argue that we should search
relative known locations first (such as the installers on Windows/Mac
would lay down), and then fall back to the configured Python
executable. That would allow installed copies to remain independent of
development copies. The only possible wrinkle would be whether a
relocatable installation such as the aforementioned installers would
be able to find their environments based purely on the executable
name.

Wouldn't the installed Python on Windows or OSX be caught be the PATH search Python does, too? Unfortunately I can't test either.
Attachment

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: [pgadmin-hackers] [pgAdmin4] [PATCH] Simplify Server's python setup
Next
From: Raffi Holzer
Date:
Subject: Re: [pgadmin-hackers] User Research Findings into PgAdmin