# Support setting up PEX in runtime\_env

**URL:** https://discuss.ray.io/t/support-setting-up-pex-in-runtime-env/1903
**Category:** Ray Core
**Created:** [April 26, 2021, 9:26am UTC](https://discuss.ray.io/t/support-setting-up-pex-in-runtime-env/1903 "2021-04-26T09:26:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mingshi\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingshi_wang/32/606_2.png) [@Mingshi\_Wang](https://discuss.ray.io/u/Mingshi_Wang)
#### Post date: [April 26, 2021, 9:26am UTC](https://discuss.ray.io/t/support-setting-up-pex-in-runtime-env/1903/1 "2021-04-26T09:26:41Z")

</div>

This is a feature request for supporting PEX in the runtime\_env of ray, which is similar to how conda is supported (see [issue #14524](https://github.com/ray-project/ray/issues/14524)).

For example, we can package an actor “foo” in a PEX file “my\_package.pex”:

`@ray.remote class Foo(object): ... `

And then initialize ray with the PEX environment to enable the worker to run “foo” in the PEX environment:  
`ray.init(runtime_env = { "pex": "path/to/my_package.pex" });`

We have an example repo [GitHub - leozc/fp20](https://github.com/leozc/fp20) to package ray actors into PEX files and run the actor in a local ray cluster. The commands are:

build ray\_demo.pex in dist:  
`./pants package ray_demo:ray_demo`

run ray workers in PEX environment:  
`./dist/ray_demo/ray_demo.pex`

What we would like to have is to execute the code in a real cluster (e.g. cloud, k8s, etc.).

---

<div class="post-metadata">

### Author: ![eoakes](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/eoakes/32/7825_2.png) [@eoakes](https://discuss.ray.io/u/eoakes)
#### Post date: [April 26, 2021, 9:23pm UTC](https://discuss.ray.io/t/support-setting-up-pex-in-runtime-env/1903/2 "2021-04-26T21:23:37Z")

</div>

Hi Mingshi, I just created a feature request to track this on the Ray repo:

> <https://github.com/ray-project/ray/issues/15518>
>
> This is a feature request for supporting PEX in the runtime\_env of ray, which is… similar to how conda is supported (see issue #14524 2).
> 
> For example, we can package an actor “foo” in a PEX file “my\_package.pex”:
> 
> @ray.remote class Foo(object): ...
> 
> And then initialize ray with the PEX environment to enable the worker to run “foo” in the PEX environment:
> ray.init(runtime\_env = { "pex": "path/to/my\_package.pex" });
> 
> We have an example repo GitHub - leozc/fp20 1 to package ray actors into PEX files and run the actor in a local ray cluster. The commands are:
> 
> build ray\_demo.pex in dist:
> ./pants package ray\_demo:ray\_demo
> 
> run ray workers in PEX environment:
> ./dist/ray\_demo/ray\_demo.pex
> 
> What we would like to have is to execute the code in a real cluster (e.g. cloud, k8s, etc.).

Let’s discuss more there, but if you’d be willing to contribute this we’d be happy to help you figure out the best approach 🙂

---

<div class="post-metadata">

### Author: ![Mingshi\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mingshi_wang/32/606_2.png) [@Mingshi\_Wang](https://discuss.ray.io/u/Mingshi_Wang)
#### Post date: [April 26, 2021, 10:16pm UTC](https://discuss.ray.io/t/support-setting-up-pex-in-runtime-env/1903/3 "2021-04-26T22:16:40Z")

</div>

Thanks Edward! We’d be happy to contribute if you could help us with the right approach!
