别碰我的妖bang [英] Don't touch my shebang

查看:79
本文介绍了别碰我的妖bang的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我讨厌关于 distutils 的一件事(我想他是做这件事的罪魁祸首)是它改变了shebang线。换句话说,更合理和更环境的变量决定了经文

One thing I hate about distutils (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture

#!/usr/bin/env python

神奇地转换为

#!/whatever/absolute/path/is/my/python

这也可以看到与grok一起使用:我在virtualenv中使用grokproject启动了我的项目,但是现在我不能再移动开发目录了,因为它在shebang指令中放置了绝对路径。

This is seen also with grok: I used grokproject in a virtualenv to start my project, but now I cannot move the development directory around anymore, because it puts absolute paths in the shebang directive.

我问这个问题有两个原因

The reason why I ask this is twofold


  • 我想移动它,因为我开始在一个目录(实验)中进行开发,现在我想要将其移至正确的路径,但我做不到。因此,我创建了一个新的virtualenv和grokproject并复制了我的文件。这就解决了问题,但我对寻求更合理解决方案的好奇心未得到满足。特别是,如果对virtualenv python解释器的引用是相对的,则该问题首先不会出现。您知道virtualenv的布局,并且可以轻松引用virtualenv python。

  • 第二个原因是我希望能够将virtualenv扩展到另一台计算机并运行它那里没有麻烦。如果您有硬编码的路径,则不可能。

推荐答案

当然,您可以移动开发目录周围。 Distutils更改了在运行python时应使用的路径。运行扩展时,它在Grok中运行。移动并重新运行引导程序和扩展。

Of course you can move the development directory around. Distutils changes the paths to the python that you should run with when you run it. It's in Grok run when you run the buildout. Move and re-run the bootstrap and the buildout. Done!

Distutils更改了用于运行distutils的Python的路径。如果没有,那么您可能最终会在一个python版本中安装一个库,但是当您尝试运行该脚本时,它将失败,因为它将与另一个没有该库的python版本一起运行。

Distutils changes the path to the Python you use to run distutils with. If it didn't, then you might end up installing a library in one python version, but when you try to run the script it would fail, because it would run with another python version that didn't have the library.

那不是精神错乱,事实上,这是唯一的理智之举。

That's not insanity, it's in fact the only sane way to do it.

更新:
如果您知道自己在做什么,则可以执行以下操作:

Update: If you know what you are doing, you can do this:

/path/to/install/python setup.py build -e "/the/path/you/want/python" install

请确保您清理了构建目录首先。 :)

Make sure you clean the build directory first though. :)

这篇关于别碰我的妖bang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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