[py-dev] adding env option to xspec (initialy posted to [execnet-dev])

Jakub Gustak jgustak at gmail.com
Fri Jun 25 16:10:08 CEST 2010


> Hi Jakub,
>
> not sure it makes sense to add this to execnet, maybe better
> to xdist code?  Things is it's easy to set environment variables
> when initializing gateways yourself. Just when using pytest-xdist
> you cannot easily do this because that API level is not exposed.
> So xdist could grow a configuration option to interpret
> some additional xspec settings.
>
> I suggest to use
>
>    popen//env:NAME=value
>
> as syntax.   That being said i am not totally opposed to adding
> it directly to execnet.  Maybe other people here on the list also
> have comments ...
>
> best,
> holger
>
> On Thu, Jun 24, 2010 at 13:30 +0100, Jakub Gustak wrote:
>> Hello,
>>
>> I need to specify some ENV variable when running a sub-process (this
>> case for xdist). AFAIK there is no support for such feature.
>>
>> I do a workaround by popen//python=./python_with_env where
>> ./python_with_env does specify required ENV.
>>
>> It would be nice to have xspec env option (e.g. popen//env='VAR1=value
>> VAR2=value' ).
>>
>> I can fry up a patch for this functionality if you consider it a
>> feature worth inclusion.
>>
>> Cheers,
>> Jakub Gustak

Moving this topic to py-dev list in this case.

I prepared a patch, please review.

What I don't like about it is using XSspec.__dict__ because
env:NAME=VALUE requires a iteration through XSpec attributes:

+    def env(self):
+        return [(env.lstrip('env:'), value)
+                    for env, value in  self.gateway.spec.__dict__.iteritems()
+                    if env.startswith('env:')]

I believe a small extension to XSpec API would be nice. Any other ideas?

regards,
jakub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: env_xspec.patch
Type: application/octet-stream
Size: 3570 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20100625/1f6d535e/attachment.obj>


More information about the Pytest-dev mailing list