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

时间:2022-11-27 23:01:38

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文件?

1 个解决方案

#1


2  

Use the scripts keyword to setup. For example:

使用scripts关键字进行设置。例如:

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'],
    }
}

#1


2  

Use the scripts keyword to setup. For example:

使用scripts关键字进行设置。例如:

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'],
    }
}