Re: [pgAdmin4] [PATCH] Simplify Server's python setup

From: Jan Alexander Steffens <jan(dot)steffens(at)gmail(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: [pgAdmin4] [PATCH] Simplify Server's python setup
Date: 2017-01-25 14:35:53
Message-ID: CAMQ-g0cYW-K06smzufY=+g485_hoECzHLH0gq__x85Uij58mRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

On Wed, Jan 25, 2017 at 2:57 PM Dave Page <dpage(at)pgadmin(dot)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 Content-Type Size
0001-Simplify-Server-s-python-setup.patch text/x-patch 11.5 KB

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Raffi Holzer 2017-01-25 14:38:29 Re: User Research Findings into PgAdmin
Previous Message Dave Page 2017-01-25 13:57:32 Re: [pgAdmin4] [PATCH] Simplify Server's python setup