简体   繁体   English

在python中,如何从distutils包中公开一些命令?

[英]In python, how do I expose some command from my distutils package?

After installing django: 安装django后:

pip install django

I can immediately write: 我可以马上写:

django-admin.py startproject project

And django-admin.py is somehow known to my system. 并且django-admin.py以某种方式为我的系统所知。

I'm developing small webserver and distribute is using PIP - what should I put in my setup.py to expose my runserver.py file system-wide in the same manner as Django does? 我正在开发小型web服务器并使用PIP进行分发 - 我应该在setup.py放置什么来以与Django相同的方式在系统范围内公开我的runserver.py文件?

Use the scripts keyword to setup. 使用scripts关键字进行设置。 For example: 例如:

setup(...,
      scripts=['django_admin.py']
      )

The script is required to be executable. 该脚本必须是可执行的。

In some cases, an alternative is to specify a function in a module that should be an entry_point 在某些情况下,另一种方法是在模块中指定一个应该是entry_point的函数

setup(...,

    entry_points={
        'console_scripts':
             ['myscript = my.package.scripts:main'],
    }
}

暂无
暂无

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

相关问题 可安装的distutils软件包:如何从也是同一软件包一部分的命令行脚本中导入软件包模块? - Installable distutils packages: How do I import package modules from command line scripts which are also part of the same package? 如何从distutils源码包创建Python鸡蛋? - How do I create Python eggs from distutils source packages? 如何防止distutils将-I / usr / include / python2.7添加到gcc命令行? (或将其更改为其他内容) - How do I prevent distutils from adding -I/usr/include/python2.7 to the gcc command line? (or change it to something else) 如何使用 SVN 和 distutils 为 Python package 分配版本号? - How do I assign a version number for a Python package using SVN and distutils? 我如何使用setuptools或distutils来分发脚本而不是Python包? - How do I use setuptools or distutils to distribute a script as opposed to a Python package? 你如何卸载使用distutils安装的python package? - How do you uninstall a python package that was installed using distutils? 如何使用distutils安装Python扩展模块? - How do I install a Python extension module using distutils? 如何使用distutils安装到特定的Python安装? - How do I install with distutils to a specific Python installation? 如何在不导入整个 package 的情况下公开 python class 下的 package? - How do I expose a python class under its containing package without importing the entire package? Python Distutils包分发 - Python Distutils Package Distribution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM