简体   繁体   English

运行使用 setup.py 文件的应用程序

[英]run application that uses setup.py file

I have the application that uses setup.py with entry point like this我有使用setup.py的应用程序和这样的入口点

  entry_points={
      'console_scripts': [
          'service = service.main:main',
      ]
  }

When building whl package using setup.py file, I can install it and run the application just fine using the application name.使用setup.py文件构建whl package 时,我可以使用应用程序名称安装并运行应用程序。

The project itself is organized in a way that I have src folder with the source code.项目本身的组织方式是我将src文件夹与源代码放在一起。

src/
    service/
       main.py

But I need to deploy it to CloudFoundry.但我需要将它部署到 CloudFoundry。 I thought to specify the start command in a manifest file.我想在清单文件中指定启动命令。

applications:
 - buildpack: https://github.com/cloudfoundry/python-buildpack#v1.7.15
   disk_quota: 2G
   command: python setup.py ???

But how to run it without creating and then installing a package?但是如何在不创建然后安装 package 的情况下运行它? Because running it like python src/service/main.py doesn't work, so I presume I need to execute it differently or something.因为像python src/service/main.py一样运行它不起作用,所以我认为我需要以不同的方式执行它。

In the end I dropped setup.py altogether, adjusted project structure and created __main__.py file.最后我完全删除了setup.py ,调整了项目结构并创建了__main__.py文件。

service\
    __main__.py
    ....

Then I set command: python -m service and that at least started the application.然后我设置command: python -m service并且至少启动了应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM