You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aurora.apache.org by Bhuvan Arumugam <bh...@apache.org> on 2014/12/02 17:20:06 UTC

override python interpreter when building pex using pants

It's more of pants/pex question.

I've installed python2.7 in a custom path. I want to build
aurora_client using this interpreter. By default, it use python2.7 in
the PATH (#!/usr/bin/env python2.7). How do I change it to use
python2.7 in custom path? pex support this feature with --interpreter
option, but pants dont seem to expose it.

IOW, the first line of pex is #!/usr/bin/env python2.7; i want to
change it as #!/my/custom/python/bin/python2.7.

The current workaround is to add /my/custom/python/bin to PATH
everytime we execute pex. It's not feasible with thermos_executor.
It's launched from mesos-slave, unless i fix mesos-slave to expose
/my/custom/python/bin in PATH, i can't launch thermos_executor.

Is there a workaround? Is there any undocumented pants env that can
help to override the interpreter?

-- 
Regards,
Bhuvan Arumugam
www.livecipher.com

Re: override python interpreter when building pex using pants

Posted by Kevin Sweeney <ke...@apache.org>.
I don't believe this is possible until
https://issues.apache.org/jira/browse/AURORA-358 is complete.

On Tue, Dec 2, 2014 at 10:23 AM, Brian Wickman <wi...@apache.org> wrote:

> You can use ./pants build -i <interpreter> <target> to build with a
> specific interpreter, but it will still revert to a #!/usr/bin/env
> pythonX.X hashbang line.  There is not yet a pants environment variable to
> switch interpreters at runtime but it would be a straightforward feature to
> add.  I've filed https://github.com/pantsbuild/pex/issues/27
>
> As a workaround, I *think* you can use -thermos_executor_path in the
> scheduler to just do:
>
> -thermos_executor_path="/my/custom/python/bin/python2.7
> /usr/local/bin/thermos_executor"
>
> or whatever the path to the executor is, since pex files can be invoked as
> ordinary python scripts.  If for whatever reason Aurora doesn't like the
> space there, you can always just create a wrapper e.g.
> /usr/local/bin/thermos_executor.sh that just contains the same.
>
> ~brian
>
> On Tue, Dec 2, 2014 at 8:20 AM, Bhuvan Arumugam <bh...@apache.org> wrote:
>
> > It's more of pants/pex question.
> >
> > I've installed python2.7 in a custom path. I want to build
> > aurora_client using this interpreter. By default, it use python2.7 in
> > the PATH (#!/usr/bin/env python2.7). How do I change it to use
> > python2.7 in custom path? pex support this feature with --interpreter
> > option, but pants dont seem to expose it.
> >
> > IOW, the first line of pex is #!/usr/bin/env python2.7; i want to
> > change it as #!/my/custom/python/bin/python2.7.
> >
> > The current workaround is to add /my/custom/python/bin to PATH
> > everytime we execute pex. It's not feasible with thermos_executor.
> > It's launched from mesos-slave, unless i fix mesos-slave to expose
> > /my/custom/python/bin in PATH, i can't launch thermos_executor.
> >
> > Is there a workaround? Is there any undocumented pants env that can
> > help to override the interpreter?
> >
> > --
> > Regards,
> > Bhuvan Arumugam
> > www.livecipher.com
> >
>

Re: override python interpreter when building pex using pants

Posted by Brian Wickman <wi...@apache.org>.
You can use ./pants build -i <interpreter> <target> to build with a
specific interpreter, but it will still revert to a #!/usr/bin/env
pythonX.X hashbang line.  There is not yet a pants environment variable to
switch interpreters at runtime but it would be a straightforward feature to
add.  I've filed https://github.com/pantsbuild/pex/issues/27

As a workaround, I *think* you can use -thermos_executor_path in the
scheduler to just do:

-thermos_executor_path="/my/custom/python/bin/python2.7
/usr/local/bin/thermos_executor"

or whatever the path to the executor is, since pex files can be invoked as
ordinary python scripts.  If for whatever reason Aurora doesn't like the
space there, you can always just create a wrapper e.g.
/usr/local/bin/thermos_executor.sh that just contains the same.

~brian

On Tue, Dec 2, 2014 at 8:20 AM, Bhuvan Arumugam <bh...@apache.org> wrote:

> It's more of pants/pex question.
>
> I've installed python2.7 in a custom path. I want to build
> aurora_client using this interpreter. By default, it use python2.7 in
> the PATH (#!/usr/bin/env python2.7). How do I change it to use
> python2.7 in custom path? pex support this feature with --interpreter
> option, but pants dont seem to expose it.
>
> IOW, the first line of pex is #!/usr/bin/env python2.7; i want to
> change it as #!/my/custom/python/bin/python2.7.
>
> The current workaround is to add /my/custom/python/bin to PATH
> everytime we execute pex. It's not feasible with thermos_executor.
> It's launched from mesos-slave, unless i fix mesos-slave to expose
> /my/custom/python/bin in PATH, i can't launch thermos_executor.
>
> Is there a workaround? Is there any undocumented pants env that can
> help to override the interpreter?
>
> --
> Regards,
> Bhuvan Arumugam
> www.livecipher.com
>