如何在python中指定可选的依赖项setup.py?
这是我为我的开源库指定可选依赖项的尝试,但它似乎没有做太多.
https://github.com/od-eon/django-cherrypy/blob/master/setup.py
具体extra_requires在这个片段中:
setup(
name='django-cherrypy',
version='0.1',
packages=packages,
license='LICENSE',
description='cherrypy, running under django',
long_description=open('README.md').read(),
author='Calvin Cheng',
author_email='calvin@calvinx.com',
install_requires=['cherrypy-wsgiserver'],
extra_requires=['newrelic'],
url='https://github.com/od-eon/django-cherrypy',
)
Run Code Online (Sandbox Code Playgroud)
建议?
我无法弄清楚如何使用sed来搜索和替换/文本文件中包含该字符的字符串/etc/myconfig.
例如,在我现有的文本文件中,我有:
myparam /path/to/a argB=/path/to/B xo
Run Code Online (Sandbox Code Playgroud)
我希望将其替换为:
myparam /path/to/c argB=/path/to/D xo
Run Code Online (Sandbox Code Playgroud)
我尝试在bash中这样做:
line='myparam /path/to/a argB=/path/to/B xo'
line_new='myparam /path/to/c argB=/path/to/D xo'
sed -i 's/$line/$line_new/g' /etc/myconfig
Run Code Online (Sandbox Code Playgroud)
但没有任何反应.
尝试
grep -rn "$line" /etc/myconfig
Run Code Online (Sandbox Code Playgroud)
虽然回来了'myparam /path/to/a argB=/path/to/B xo'.
表达sed执行此搜索并替换并正确处理命令的命令的正确方法是什么/?(我认为/我的字符串中的字符是给我问题的字符,因为我使用类似的sed命令来搜索和替换文本文件中的另一行没有问题,并且该行没有/字符.
我对流浪者来说比较新,但到目前为止肯定喜欢它.
我经常面临的一个小问题是,当我的主机网络暂时停机时,它会影响我与流浪客户的连接.
当我的主机网络再次恢复时,我必须 - 在我的主机上 - 运行vagrant halt然后vagrant up为了"重置"我的客户流浪者vm的网络,以便它可以再次连接到互联网.
是否有更"优雅"的方式通过我的主机网络获取我的虚拟机互联网连接,以检测互联网网络连接是否已备份?
从django 1.5开始,https://docs.djangoproject.com/en/1.5/releases/1.5/#iscellaneous
模板标签库adminmedia仅包含已弃用的模板标签{%admin_media_prefix%},已被删除.尝试使用{%load adminmedia%}加载它将失败.如果您的模板仍包含该行,则必须将其删除.
那么替换遗留库中的代码以及仍然使用{% load adminmedia %}和加载css的遗留项目的适当方法是什么: -
<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/login.css">
Run Code Online (Sandbox Code Playgroud)
?
:sp
Run Code Online (Sandbox Code Playgroud)
默认情况下,在顶部打开一个拆分缓冲区.
如何给出split命令以便新缓冲区立即打开为"底部"缓冲区?(我不想做一个我知道旋转缓冲区的Cwr,以便我新打开的缓冲区旋转到底部)
所以我读过这个 - https://wiki.archlinux.org/index.php/Python
从这个wiki可以清楚地看到我可以通过安装Python 2.7.2
pacman -S python2
Run Code Online (Sandbox Code Playgroud)
我为python2创建一个符号链接是否合理
ln -s python2 /usr/bin/python
Run Code Online (Sandbox Code Playgroud)
如果我不认为自己很快就会切换到python 3.0?或者有更好的方法来管理多个python版本,就像我通常在debian系统(update-alternatives --config python)或mac os x系统(python select)上使用的那样?
澄清:
在python(django)项目中,当我用pip更改现有依赖项的位置,并在另一台机器上重新安装更新的requirements.txt文件时,系统会提示我这样的消息: -
Obtaining South from git+git://github.com/lambdafu/django-south.git@7bb081348d854d0b1aa82b87da5b446ad5d6f2a6#egg=South-dev (from -r requirements.txt (line 5))
git clone in ./src/south exists with URL git://github.com/clones/django-south.git
The plan is to install the git repository git://github.com/lambdafu/django-south.git
What to do? (s)witch, (i)gnore, (w)ipe, (b)ackup
Run Code Online (Sandbox Code Playgroud)
此时,我将选择"w"(擦除)来清除django-south的旧副本,并从新的存储库位置使用django-south.
我想将此作为默认行为,而无需键入"w".
给我的时候我可以指定一个选项
pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
命令,以便安装过程会自动知道我要删除旧版本,不会提示我选择s/i/w/b?
我已经尝试了一堆Python代码折叠插件,我已经在这里看到过这个问题,但是它们对于以这种方式实现Python代码折叠似乎并不太有用:
class myClass(models.Model):
[folded code]
class Meta:
[folded code]
def __unicode__(self):
[folded code]
def save(self, *args, **kwargs):
[folded code]
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,是否有任何Python代码折叠插件可以做到这一点? 到目前为止我还没有找到任何东西,我已经尝试了很多这样的Vim插件.
假设以下项目布局: -
mainrepo_git
|____ .git
|____ .gitmodules
|____ proj <------- directory containing the code files for mainrepo
|____ 3rdpartysourcecode <-- directory containing upstream open source code
| |____ .git
| |____ 3rdpartyfiles
|
|____ mainrepofilesanddirectories
Run Code Online (Sandbox Code Playgroud)
mainrepo_git包含我直接负责的源代码.我有读/写访问权限,可以直接推送到我管理的远程git存储库.
嵌套在mainrepo_git中的是一个名为3rdpartysourcecode的目录.这个3rdpartysourcecode目录实际上是另一个git repo(通常也称为"git submodule"),它指向由其他开发人员管理的开源第三方git存储库.我只有读取权限.没有写访问权限.
有没有办法'冻结'git子模块的特定提交哈希与我的主存储库中提交的相关?
例如,如果我在(或我恢复)在我的mainrepo中提交a12ucak,我的git子模块也会被恢复为特定版本,我将其绑定为提交a12ucak?当我切换到提交b349jdsak时,我的git子模块也会恢复到我绑定到b349jdsak的版本?
所以我的问题是:有一种方法可以在主仓库中的特定提交与git子模块中的相应提交之间创建链接吗?以这种方式,当我在主git repo中检出特定提交时,git子模块中的相应提交也将是checkout.
阅读http://bugs.python.org/msg160297,我可以看到一个由Stephen White编写的简单脚本,它演示了python线程如何在这个异常中出错
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading'
Run Code Online (Sandbox Code Playgroud)
鉴于Stephen White的源代码(http://bugs.python.org/file25511/bad-thread.py),
import os
import thread
import threading
import time
def t():
threading.currentThread() # Populate threading._active with a DummyThread
time.sleep(3)
thread.start_new_thread(t, ())
time.sleep(1)
pid = os.fork()
if pid == 0:
os._exit(0)
os.waitpid(pid, 0)
Run Code Online (Sandbox Code Playgroud)
我们如何重新编写它以便解决此错误?
python ×5
vim ×2
archlinux ×1
bash ×1
django ×1
django-1.5 ×1
folding ×1
git ×1
pip ×1
pypi ×1
python-3.x ×1
sed ×1
setup.py ×1
vagrant ×1
virtualbox ×1