Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
146 views
in Technique[技术] by (71.8m points)

python - Sharing scripts that require a virtualenv to be activated

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.

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.

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?


Edit: 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.

question from:https://stackoverflow.com/questions/2253712/sharing-scripts-that-require-a-virtualenv-to-be-activated

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...