我的脚本是 运行 两次,每次我在使用自定义 setup.py 文件安装后调用它
my script is running twice each time I call it after installing it using a custom setup.py file
我正在构建一个使用命令参数的命令行脚本。在我使用 setuptools 和这个设置文件
完成设置之后
from setuptools import setup
setup(name='notes',
version='0.1',
description='A program used to manage your notes and organize them across your machine.',
url='info',
author='info',
author_email='info',
license='MIT',
install_requires=[
'tabulate',
'argparse'
],
packages=['.'],
data_files=["config.json"],
scripts=[],
include_package_data=True,
zip_safe=False,
entry_points={
'console_scripts': [
'notes = notes:main'
]
}
)
每次我从 cmd 调用它时它都会运行两次!!
notes.main 功能很简单
p = argparse.ArgumentParser(add_help=False, description= " notes management system", usage=help_msg)
p.add_argument("command")
p.add_argument("name")
p.add_argument("--newname")
p.add_argument("--tag", action="store")
p.add_argument("--newtag", action="store")
p.add_argument("--bytag", action="store_true")
p.add_argument("--bydate", action="store_true")
p.add_argument("--byname", action="store_true")
arg_handeler(sys.argv, p)
知道为什么吗?我使用 python 3.7.7
已解决
看来我在入口文件中调用了 main,并且在同一个文件中安装文件调用了它。所以我删除了主函数调用,它工作得很好!
我正在构建一个使用命令参数的命令行脚本。在我使用 setuptools 和这个设置文件
完成设置之后
from setuptools import setup
setup(name='notes',
version='0.1',
description='A program used to manage your notes and organize them across your machine.',
url='info',
author='info',
author_email='info',
license='MIT',
install_requires=[
'tabulate',
'argparse'
],
packages=['.'],
data_files=["config.json"],
scripts=[],
include_package_data=True,
zip_safe=False,
entry_points={
'console_scripts': [
'notes = notes:main'
]
}
)
每次我从 cmd 调用它时它都会运行两次!! notes.main 功能很简单
p = argparse.ArgumentParser(add_help=False, description= " notes management system", usage=help_msg)
p.add_argument("command")
p.add_argument("name")
p.add_argument("--newname")
p.add_argument("--tag", action="store")
p.add_argument("--newtag", action="store")
p.add_argument("--bytag", action="store_true")
p.add_argument("--bydate", action="store_true")
p.add_argument("--byname", action="store_true")
arg_handeler(sys.argv, p)
知道为什么吗?我使用 python 3.7.7
已解决 看来我在入口文件中调用了 main,并且在同一个文件中安装文件调用了它。所以我删除了主函数调用,它工作得很好!