[英]Packaging a Python Project to an Executable
I have a project with the below structure:我有一个具有以下结构的项目:
projectname/projectname/__main__.py
I execute the program using python -m projectname
.我使用
python -m projectname
执行程序。
If I want to install it locally in my system so that I can just call projectname
, How can I achieve this?如果我想在我的系统中本地安装它以便我可以调用
projectname
,我该如何实现呢?
You'll want to make a file setup.py
in the top-level projectname
that installs the package and adds some command (eg yeet
) to your path.您需要在顶级项目名称中创建一个文件
setup.py
来安装projectname
并将一些命令(例如yeet
)添加到您的路径中。 That command will call some function inside projectname/__main__.py
:该命令将在
projectname/__main__.py
:
from setuptools import setup
setup(
name='mypackagename',
version='0.0.1',
packages=['mypackagename'],
install_requires=[
'tensorflow>=2.0.0', # put your modules from requirements.txt here
],
entry_points={
'console_scripts': [
'yeet=projectname:function_to_run',
],
},
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.