Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65617 > unrolled thread

Re: Using virtualenv to bypass sudoer issues

Started byCameron Simpson <cs@zip.com.au>
First post2014-02-08 12:18 +1100
Last post2014-02-07 20:31 -0800
Articles 4 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Using virtualenv to bypass sudoer issues Cameron Simpson <cs@zip.com.au> - 2014-02-08 12:18 +1100
    Re: Using virtualenv to bypass sudoer issues Asaf Las <roegltd@gmail.com> - 2014-02-07 19:03 -0800
      Re: Using virtualenv to bypass sudoer issues Cameron Simpson <cs@zip.com.au> - 2014-02-08 14:32 +1100
        Re: Using virtualenv to bypass sudoer issues Asaf Las <roegltd@gmail.com> - 2014-02-07 20:31 -0800

#65617 — Re: Using virtualenv to bypass sudoer issues

FromCameron Simpson <cs@zip.com.au>
Date2014-02-08 12:18 +1100
SubjectRe: Using virtualenv to bypass sudoer issues
Message-ID<mailman.6503.1391822294.18130.python-list@python.org>
On 06Feb2014 18:32, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
> Assuming I have a debian workstation for which I don't have any
> sudo rights, in order to be able to install / remove python packages,
> should I be using virtualenv ? Is it a suited solution ?

It is well suited.

You can also do far simpler (and far smaller setups) like this:

  mkdir -p $HOME/lib/python

and in your environment (eg $HOME/.profile or $HOME/.bash_profile) add:

  PYTHONPATH=$HOME/lib/python:$PYTHON_PATH
  export PYTHONPATH

and simply install (copy) packages into that directory.

This is conceptually the same as having a $HOME/bin with commands
or your own in it, etc.

If you're getting your packages from pypi, virutalenv may be easier
to use in the long run.  besides, it lets you make multiple
environments for different flavours of Python (2 vs 3, etc).

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

I just kept it wide-open thinking it would correct itself.
Then I ran out of talent.       - C. Fittipaldi

[toc] | [next] | [standalone]


#65619

FromAsaf Las <roegltd@gmail.com>
Date2014-02-07 19:03 -0800
Message-ID<a07a9b62-0aad-437c-96ab-c9f991f72261@googlegroups.com>
In reply to#65617
On Saturday, February 8, 2014 3:18:02 AM UTC+2, Cameron Simpson wrote:
> On 06Feb2014 18:32, Jean-Michel Pichavant <je...@sequans.com> wrote:
> 
> > Assuming I have a debian workstation for which I don't have any
> > sudo rights, in order to be able to install / remove python packages,
> > should I be using virtualenv ? Is it a suited solution ?
> 
> It is well suited.
> 
> You can also do far simpler (and far smaller setups) like this:
> 
>   mkdir -p $HOME/lib/python
> 
> and in your environment (eg $HOME/.profile or $HOME/.bash_profile) add:
> 
>   PYTHONPATH=$HOME/lib/python:$PYTHON_PATH
>   export PYTHONPATH
> and simply install (copy) packages into that directory.
> 
> This is conceptually the same as having a $HOME/bin with commands
> or your own in it, etc.
> 
> If you're getting your packages from pypi, virutalenv may be easier
> to use in the long run.  besides, it lets you make multiple
> environments for different flavours of Python (2 vs 3, etc).
> 
> Cheers,
> 
> Cameron Simpson <cs@zip.com.au>
> 
> I just kept it wide-open thinking it would correct itself.
> Then I ran out of talent.       - C. Fittipaldi

Hi 

Does this approach work with mixed packages comprising non python
code? 

/Asaf

[toc] | [prev] | [next] | [standalone]


#65620

FromCameron Simpson <cs@zip.com.au>
Date2014-02-08 14:32 +1100
Message-ID<mailman.6504.1391830351.18130.python-list@python.org>
In reply to#65619
On 07Feb2014 19:03, Asaf Las <roegltd@gmail.com> wrote:
> On Saturday, February 8, 2014 3:18:02 AM UTC+2, Cameron Simpson wrote:
> > On 06Feb2014 18:32, Jean-Michel Pichavant <je...@sequans.com> wrote:
> > 
> > > Assuming I have a debian workstation for which I don't have any
> > > sudo rights, in order to be able to install / remove python packages,
> > > should I be using virtualenv ? Is it a suited solution ?
> > 
> > It is well suited.
> > 
> > You can also do far simpler (and far smaller setups) like this:
> >   mkdir -p $HOME/lib/python
> > and in your environment (eg $HOME/.profile or $HOME/.bash_profile) add:
> >   PYTHONPATH=$HOME/lib/python:$PYTHON_PATH
> >   export PYTHONPATH
> > and simply install (copy) packages into that directory.
> > This is conceptually the same as having a $HOME/bin with commands
> > or your own in it, etc.
[...]
> 
> Does this approach work with mixed packages comprising non python
> code? 

Persuming you are asking about "just make a lib directory and point
$PYTHONPATH at it" instead of virtualenv, in principle yes.
But it is more work; virtualenv is essentially a well standardised and more
thorough version.

Most such mixed packages install with a setup.py that compiles the
relevant bits, and you'll need to tell setup.py where to install
things, so it is not as easy as just copying in the files.

I think such packages are about the point where I would consider
virtualenv; once you have the virtualenv set up, installing packages
is more automatic.

For pure python packages, just copying them into your personal lib
works well, and is very simple. As soon as you get mixed packages,
it is probably more worthwhile to use virtualenv. I think.

Virtualenv looks like a bit of a leap to set up to start with, but
I found it easier than I expected. As I recall, you can do two basic
types of virtualenv: a "complete" one which installs copies of all
the system packages, or a much smaller one that itself hooks into
the system python packages.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Life IS pain, highness...  anyone who tries to tell you different is
trying to sell you something.   - Wesley, The_Princess_Bride

[toc] | [prev] | [next] | [standalone]


#65622

FromAsaf Las <roegltd@gmail.com>
Date2014-02-07 20:31 -0800
Message-ID<76eaff32-0167-4e57-b9f8-73c88250518c@googlegroups.com>
In reply to#65620
On Saturday, February 8, 2014 5:32:22 AM UTC+2, Cameron Simpson wrote:
> On 07Feb2014 19:03, Asaf Las <r.....@gmail.com> wrote:
> 
> Persuming you are asking about "just make a lib directory and point
> $PYTHONPATH at it" instead of virtualenv, in principle yes.
> But it is more work; virtualenv is essentially a well standardised and more
> thorough version.
> 
> Most such mixed packages install with a setup.py that compiles the
> relevant bits, and you'll need to tell setup.py where to install
> things, so it is not as easy as just copying in the files.
> 
> I think such packages are about the point where I would consider
> virtualenv; once you have the virtualenv set up, installing packages
> is more automatic.
> 
> For pure python packages, just copying them into your personal lib
> works well, and is very simple. As soon as you get mixed packages,
> it is probably more worthwhile to use virtualenv. I think.
> 
> Virtualenv looks like a bit of a leap to set up to start with, but
> I found it easier than I expected. As I recall, you can do two basic
> types of virtualenv: a "complete" one which installs copies of all
> the system packages, or a much smaller one that itself hooks into
> the system python packages.
> 
> 
> Cheers,
> 
> Cameron Simpson <cs@zip.com.au>

Thanks 

still there are changes 
http://docs.python.org/3.4/library/venv.html

i hope one day it will be possible to deploy app over net 
by just unpacking tar ball done at test machine on production 
one, though this seems questionable:
http://www.virtualenv.org/en/latest/virtualenv.html#making-environments-relocatable

it might be for some packages relying on 3rd party libs such as lxml, root 
account had to be provided. 
or may be there are some acceptable hacks similar to patching 
RPATH on bin's? 

Regards

Asaf

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web