leo*_*ger 21 python node.js npm
在node中,您可以定义一个package.json。然后定义一个script块如下:
"scripts": {
"start": "concurrently -k -r -s first \"yarn test:watch\" \"yarn open:src\" \"yarn lint:watch\"",
},
Run Code Online (Sandbox Code Playgroud)
所以在根目录中,我可以yarn start运行concurrently -k -r -s first \"yarn test:watch\" \"yarn open:src\" \"yarn lint:watch\"
Python 3 中的等效项是什么?如果我想调用一个脚本python test来运行python -m unittest discover -v
ale*_*der 25
使用make,太棒了。
创建Makefile并添加一些目标来运行特定的 shell 命令:
install:
pip install -r requirements.txt
test:
python -m unittest discover -v
# and so on, you got the idea
Run Code Online (Sandbox Code Playgroud)
运行(假设Makefile在当前目录中):
install:
pip install -r requirements.txt
test:
python -m unittest discover -v
# and so on, you got the idea
Run Code Online (Sandbox Code Playgroud)
注意:如果您想在目标内的同一环境中运行更多命令,请执行以下操作:
install:
source ./venv/bin/activate; \
pip install -r requirements.txt; \
echo "do other stuff after in the same environment"
Run Code Online (Sandbox Code Playgroud)
关键是;\它将命令放在一次运行中,并且由于;\. 这个空间; \只是为了美观。
Eub*_*per 13
为什么不直接使用pipelinev呢?它是 python 的 npm,你可以在[scripts]你的.Pipfile
请参阅其他问题以了解更多信息:pipenv stack Overflow Question
确实不是最好的解决方案。如果您已经熟悉,那么这完全有效npm,但就像其他人建议的那样,使用 makefile。
嗯,这是一个解决方法,但显然npm如果你安装了它就可以使用。package.json我在 python 应用程序的根目录中创建了一个文件。
{
"name": "fff-connectors",
"version": "1.0.0",
"description": "fff project to UC Davis",
"directories": {
"test": "tests"
},
"scripts": {
"install": "pip install -r requirements.txt",
"test": "python -m unittest discover -v"
},
"keywords": [],
"author": "Leo Qiu",
"license": "ISC"
}
Run Code Online (Sandbox Code Playgroud)
然后我可以使用npm install或yarn install安装所有依赖项,yarn test或npm test运行测试脚本。
你也可以做preinstall和postinstall挂钩。例如,您可能需要删除文件或创建文件夹结构。
另一个好处是此设置允许您使用任何 npm 库,例如concurrently,因此您可以一起运行多个文件等。
| 归档时间: |
|
| 查看次数: |
9988 次 |
| 最近记录: |