[Scons-users] Virtualenv and Scons?

Larry Gadallah lgadalla at impinj.com
Fri Sep 6 15:25:59 EDT 2013






>Message: 1

>Date: Thu, 5 Sep 2013 13:10:05 -0700

>From: William Deegan <bill at baddogconsulting.com>

>Subject: Re: [Scons-users] Virtualenv and Scons?

>To: SCons users mailing list <scons-users at scons.org>

>Message-ID:

> <510C5085-C8E0-43D1-BBCC-50ECE10B73C2 at baddogconsulting.com>

>Content-Type: text/plain; charset=us-ascii

>

>Larry,

>On Sep 5, 2013, at 8:20 AM, Larry Gadallah <lgadalla at impinj.com> wrote:

>

>> Hello all:

>>

>> We use virtualenv quite extensively for building and testing, and I was

>>wondering if it is possible (or advisable) to use virtualenv either as a

>>wrapper around SCons or within an SConstruct file? I made a brief

>>attempt to setup a virtualenv environment and then tried invoking SCons

>>within it, and it did not seem to work. Is there a conflict between

>>SCons use of Python and the "external" Python environment at work here?

>

>Can you show some examples of what you're trying to do (shell commands

>and/or code)?

>

>-Bill


Hello Bill:

We have a local PyPI repo, and during builds, we use Python packages like
Sphinx, so we typically have a build flow that looks like this:

# Setup Python virtual environment
virtualenv .env
# Activate virtual Python environment
source .env/bin/activate
# Install local Python modules/packages
pip install sphinx <other Python modules, etc.> -f <our PyPI repo URL>
# Then here we call build scripts, Make, MSBuild (or possibly Scons)
# This could look like any of the following:
# make
# source ./build.sh
# call build.bat
# MSBuild <solution file>
# python setup.py build
# nosetests test_script.py
#
# But the goal is to invoke Scons and have it invoke the above internally
#

I have also tried scons directives like this (bear in mind I'm an scons
noob) to do things in the reverse order (i.e. Invoke virtualenv within
scons instead of scons within a virtualenv):

env = Environment()

Command('.env', None, 'virtualenv $TARGET; source $TARGET/bin/activate; cd
$TARGET; pip install sphinx -f <URL>')

This seems to work, but in this case, the dilemma is that if I want to
use, for example, sphinx in the Sconstruct file, I will need to import it,
but before the virtualenv setup is done, it is not available to import.

I'd like to be able to use Scons to have a self-contained, one-line build
(i.e. scons <target>) instead of having to do the virtualenv setup outside
of Scons.

Thanks,

--
Larry Gadallah
lgadalla at impinj.com
x9706









More information about the Scons-users mailing list