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


Groups > comp.lang.python > #108746

Re: How to create development Python environment on Linux.

From Zachary Ware <zachary.ware+pylist@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to create development Python environment on Linux.
Date 2016-05-17 10:32 -0500
Message-ID <mailman.64.1463499178.19823.python-list@python.org> (permalink)
References <815aa265-45c4-40a4-860d-beb89cd9a78e@googlegroups.com> <29b59dce-2036-43f6-8166-7e3ad15e8e4c@googlegroups.com> <CAKJDb-OMEwTYsHUxoZh+5MDKk0Q7zcHv4zJdegBfEtvzLo+7Uw@mail.gmail.com>

Show all headers | View raw


On Mon, May 16, 2016 at 4:28 PM,  <redirect.null@gmail.com> wrote:
> Thanks Zach, that's a big help. The only reason I want to get a Python 2.7 environment working first is because I'll be working on third party code and that's the platform it uses. For any new projects I would use Python 3.

Fair enough :)

> After considering your guidance I think what I will do is install virtualenv using apt-get and then use that to create a dev environment. Is it ok to run get-pip.py in a virtual environment?

Sounds like a plan.  get-pip.py should work fine in a venv, but first
check to see if pip is already there, as Michael mentioned.

> I won't worry about using the latest version of 2.7 for now, since it's only one or two third party open source projects I'll use 2.7 for and they don't need a more recent version.
>
> There are a couple of other things I'm not quite clear on, such as where it would be best to create my new virtual environment (I'm tempted to put it in /usr/local if that means it can be used by all user accounts on my machine), and how I can can control which Python environment is used by the various system and user programs that depend on them, but I expect I can find that information on the web, though I'll make another post here if I do get stuck.

The thing about virtual environments is that you can create as many as
you want wherever you want, and they're all independent of each other.
All you need to do is have a way to consistently recreate the same
environment, which is usually easiest to do with a 'requirements.txt'
file with all of your dependencies' versions pinned.  Then recreating
the venv is as simple as `virtualenv --python=some_python
/path/to/venv && /path/to/venv/bin/pip install -r
/path/to/requirements.txt`.  Then you can do your development wherever
you want and install into somewhere in `/usr/local` when you deploy.
For example, one project I work on creates a venv in
`/usr/local/lib/project_name/`, then creates links to the entry point
scripts (that actually live in `/usr/local/lib/project_name/bin/`) in
`/usr/local/bin/`.

As for controlling which environment is used: all system scripts/apps
should specify some version-specific flavor of /usr/bin/python in
their shebang--if they don't it's an OS bug and should be filed as
such.  For your stuff, the path of least headache is probably to
create a venv for each one, and specify the path to the venv's python
in shebang lines.

Hope this helps,
-- 
Zach

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How to create development Python environment on Linux. redirect.null@gmail.com - 2016-05-16 04:22 -0700
  Re: How to create development Python environment on Linux. redirect.null@gmail.com - 2016-05-16 04:29 -0700
  Re: How to create development Python environment on Linux. Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-05-16 11:25 -0500
    Re: How to create development Python environment on Linux. Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-01 17:17 -0700
      Re: How to create development Python environment on Linux. Marc Brooks <marcwbrooks@gmail.com> - 2016-06-01 20:30 -0400
  Re: How to create development Python environment on Linux. redirect.null@gmail.com - 2016-05-16 14:28 -0700
    Re: How to create development Python environment on Linux. Michael Selik <michael.selik@gmail.com> - 2016-05-16 21:56 +0000
    Re: How to create development Python environment on Linux. Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-05-17 10:32 -0500

csiph-web