[Django] #30003: Manage.py entry point

6 views
Skip to first unread message

Django

unread,
Dec 1, 2018, 2:06:40 PM12/1/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: | Status: new
Uncategorized |
Component: Core | Version: 2.1
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Currently, manage.py-tpl executes in an
{{{
if __name__ == '__main__':
}}}
block.

While this might work when declaring manage.py as script in setup.py, a
popular convention is to use the entry_point feature of setup.py.

To add support for entry_point in manage.py-tpl we only need to move the
code from the if block into a new function ie. main() and call in it in
the if-block.

Then, manage.py-tlp will also work as entry_point with
yourproject.manage:main and using manage.py as script will also still
work.

--
Ticket URL: <https://code.djangoproject.com/ticket/30003>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 1, 2018, 2:08:42 PM12/1/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Pic):

* cc: James Pic (added)
* has_patch: 0 => 1
* type: Uncategorized => New feature


Old description:

> Currently, manage.py-tpl executes in an
> {{{
> if __name__ == '__main__':
> }}}
> block.
>
> While this might work when declaring manage.py as script in setup.py, a
> popular convention is to use the entry_point feature of setup.py.
>
> To add support for entry_point in manage.py-tpl we only need to move the
> code from the if block into a new function ie. main() and call in it in
> the if-block.
>
> Then, manage.py-tlp will also work as entry_point with
> yourproject.manage:main and using manage.py as script will also still
> work.

New description:

Currently, manage.py-tpl executes in an
{{{
if __name__ == '__main__':
}}}
block.

While this might work when declaring manage.py as script in setup.py, a
popular convention is to use the entry_point feature of setup.py.

To add support for entry_point in manage.py-tpl we only need to move the
code from the if block into a new function ie. main() and call in it in
the if-block.

Then, manage.py-tlp will also work as entry_point with
yourproject.manage:main and using manage.py as script will also still
work.

This removes a manual effort every time a project is used by a follower of
the entry_point convention, without causing any issue for regular users.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:1>

Django

unread,
Dec 1, 2018, 2:38:43 PM12/1/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by James Pic:

Old description:

> Currently, manage.py-tpl executes in an
> {{{
> if __name__ == '__main__':
> }}}
> block.
>
> While this might work when declaring manage.py as script in setup.py, a
> popular convention is to use the entry_point feature of setup.py.
>
> To add support for entry_point in manage.py-tpl we only need to move the
> code from the if block into a new function ie. main() and call in it in
> the if-block.
>
> Then, manage.py-tlp will also work as entry_point with
> yourproject.manage:main and using manage.py as script will also still
> work.
>

> This removes a manual effort every time a project is used by a follower
> of the entry_point convention, without causing any issue for regular
> users.

New description:

Currently, manage.py-tpl executes in an
{{{
if __name__ == '__main__':
}}}
block.

While this might work when declaring manage.py as script in setup.py, a

popular convention is to use the console_scripts entry_point in setup.py
to define commands.

For manage.py-tpl to support console_scripts entry_point we only need to
move the code from the if block into a new function ie. main(), then call
main() it in the if-block.

Then, manage.py-tlp will also work as console_scripts entry_point with
yourproject.manage:main, and using manage.py as script will also still
work.

This removes a manual effort every time a project defines a
console_scripts entry_point for the management CLI, without having to set
DJANGO_SETTINGS_MODULE.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:2>

Django

unread,
Dec 5, 2018, 4:33:44 AM12/5/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* type: New feature => Cleanup/optimization


Comment:

Hi James,

You basically mean you want to reference `yourproject.manage:main` in your
own `setup.py` — is that correct?

I would say, "just use a custom project template" but the patch itself is
small/unobjectionable.

--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:3>

Django

unread,
Dec 5, 2018, 5:51:39 AM12/5/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

I'm going to Accept this pending any objections in review.

--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:4>

Django

unread,
Dec 5, 2018, 8:42:59 AM12/5/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:5>

Django

unread,
Dec 6, 2018, 2:46:38 PM12/6/18
to django-...@googlegroups.com
#30003: Manage.py entry point
-------------------------------------+-------------------------------------
Reporter: James Pic | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"9453bc77f4968dc3a8167eadbf97759538133332" 9453bc7]:
{{{
#!CommitTicketReference repository=""
revision="9453bc77f4968dc3a8167eadbf97759538133332"
Fixed #30003 -- Added usable entry point in default manage.py.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30003#comment:6>

Reply all
Reply to author
Forward
0 new messages