共享需要激活 virtualenv 的脚本 [英] Sharing scripts that require a virtualenv to be activated

查看:33
本文介绍了共享需要激活 virtualenv 的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有默认设置的共享 Linux 服务器上安装了 virtualenv 和 virtualenvwrapper(virtualenvs 在 ~/.virtualenvs 中).我有几个 Python 脚本只能在激活正确的 virtualenv 时运行.

I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated.

现在我想与服务器上的其他用户共享这些脚本,但不要求他们了解有关 virtualenv 的任何信息...这样他们就可以运行 python scriptname./scriptname 并且脚本将使用我的 virtualenv 中可用的库运行.

Now I want to share those scripts with other users on the server, but without requiring them to know anything about virtualenv... so they can run python scriptname or ./scriptname and the script will run with the libraries available in my virtualenv.

最干净的方法是什么?我尝试了一些选项(例如更改 shebang 行以指向 virtualenv 提供的解释器),但它们似乎非常不灵活.有什么建议吗?

What's the cleanest way to do this? I've toyed with a few options (like changing the shebang line to point at the virtualenv provided interpreter), but they seem quite inflexible. Any suggestions?

这是一个开发服务器,其他几个人都有帐户.但是,他们都不是 Python 程序员(我目前正在尝试转换他们).我只是想让他们轻松地运行这些脚本并可能检查他们的逻辑,而不会将非 Pythonista 暴露给环境细节.谢谢.

This is a development server where several other people have accounts. However, none of them are Python programmers (I'm currently trying to convert them). I just want to make it easy for them to run these scripts and possibly inspect their logic, without exposing non-Pythonistas to environment details. Thanks.

推荐答案

如果只是在一台服务器上,那么灵活性就无关紧要了.修改shebang.如果您对此感到担心,请在不使用 virtualenv 的开发服务器上制作一个打包的、已安装的副本.一旦开发完毕,无论是针对本地用户还是危地马拉用户,virtualenv 都不再是正确的工具.

If it's only on one server, then flexibility is irrelevant. Modify the shebang. If you're worried about that, make a packaged, installed copy on the dev server that doesn't use the virtualenv. Once it's out of develepment, whether that's for local users or users in guatemala, virtualenv is no longer the right tool.

这篇关于共享需要激活 virtualenv 的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆