我可以让 pip 删除我安装但不再需要的脚本吗?
Can I get pip to delete scripts that I installed but no longer want?
假设我有以下项目:
confectionary/
__init__.py
confections.py
scripts/
crunchy_frog.py
anthrax_ripple.py
spring_surprise.py
我的用户已经安装了它,所以他们只需输入
$ spring_surprise.py
他们的电脑上有不锈钢螺栓 spring,刺穿了双颊。
但是,Constable Parrot 说服我进入更多传统 糖果领域,所以我将不再提供此类糖果。我已将脚本更改为如下所示:
scripts/
praline.py
lime_coconut.py
然而,当我安装这个较新的版本时,旧脚本仍然存在。
是否可以在我的 setup.py 中以某种方式指定我在升级应用程序时不再需要这些旧脚本?
正确的方法是通过设置工具。令人愉快的 Click library has a great example.
与其拥有 scripts
目录,不如将这些信息简单地合并到应用程序本身的某处,因此 confections.py
应该包含如下内容:
def crunchy_frog():
'''Only the freshest killed frogs... '''
# TODO: implement
def anthrax_ripple():
'''A delightful blend of Anthrax spores... '''
# TODO: implement
def spring_surprise():
'''Deploy stainless steel bolts, piercing both cheeks'''
# TODO: implement
然后在 setup.py
中:
from setuptools import setup
setup(
name='confectionary',
version='1.0.0',
py_modules=['confectionary'],
entry_points='''
[console_scripts]
crunchy_frog=confectionary.confections:crunchy_frog
anthrax_ripple=confectionary.confections:anthrax_ripple
spring_surprise=confectionary.confections:spring_surprise
''',
)
当你改变它时,显然你会适当地改变 confections.py
,但是你可以改变你的 setup.py
:
from setuptools import setup
setup(
name='confectionary',
version='2.0.0',
py_modules=['confectionary'],
entry_points='''
[console_scripts]
praline=confectionary.confections:praline
lime_coconut=confectionary.confections:lime_coconut
''',
)
现在一切都会很幸福!作为额外的好处,您会发现 setuptools 也会在 Windows 上创建 appropriate files。
好吃!
假设我有以下项目:
confectionary/
__init__.py
confections.py
scripts/
crunchy_frog.py
anthrax_ripple.py
spring_surprise.py
我的用户已经安装了它,所以他们只需输入
$ spring_surprise.py
他们的电脑上有不锈钢螺栓 spring,刺穿了双颊。
但是,Constable Parrot 说服我进入更多传统 糖果领域,所以我将不再提供此类糖果。我已将脚本更改为如下所示:
scripts/
praline.py
lime_coconut.py
然而,当我安装这个较新的版本时,旧脚本仍然存在。
是否可以在我的 setup.py 中以某种方式指定我在升级应用程序时不再需要这些旧脚本?
正确的方法是通过设置工具。令人愉快的 Click library has a great example.
与其拥有 scripts
目录,不如将这些信息简单地合并到应用程序本身的某处,因此 confections.py
应该包含如下内容:
def crunchy_frog():
'''Only the freshest killed frogs... '''
# TODO: implement
def anthrax_ripple():
'''A delightful blend of Anthrax spores... '''
# TODO: implement
def spring_surprise():
'''Deploy stainless steel bolts, piercing both cheeks'''
# TODO: implement
然后在 setup.py
中:
from setuptools import setup
setup(
name='confectionary',
version='1.0.0',
py_modules=['confectionary'],
entry_points='''
[console_scripts]
crunchy_frog=confectionary.confections:crunchy_frog
anthrax_ripple=confectionary.confections:anthrax_ripple
spring_surprise=confectionary.confections:spring_surprise
''',
)
当你改变它时,显然你会适当地改变 confections.py
,但是你可以改变你的 setup.py
:
from setuptools import setup
setup(
name='confectionary',
version='2.0.0',
py_modules=['confectionary'],
entry_points='''
[console_scripts]
praline=confectionary.confections:praline
lime_coconut=confectionary.confections:lime_coconut
''',
)
现在一切都会很幸福!作为额外的好处,您会发现 setuptools 也会在 Windows 上创建 appropriate files。
好吃!