Changes between Initial Version and Version 5 of Ticket #30300


Ignore:
Timestamp:
Mar 29, 2019, 9:29:21 AM (5 years ago)
Author:
Tim Graham
Comment:

What's the use case? When makemigrations generates the first migration, it adds an __init__.py file. There was some concern about encouraging namespace packages in ticket:23919#comment:102.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30300

    • Property Owner changed from nobody to Benjy Weinberger
    • Property Status newassigned
    • Property Triage Stage UnreviewedAccepted
    • Property Type BugNew feature
    • Property Summary migrate silently ignores apps whose migrations directory doesn't have an __init__.pyAllow migrations directories without __init__.py files
  • Ticket #30300 – Description

    initial v5  
    11Background: In python 3 a package with no `__init__.py` is implicitly a namespace package, so it has no `__file__` attribute.
    22
    3 The migrate command currently checks for existence of a `__file__` attribute on the `migrations` package. This check was introduced in https://code.djangoproject.com/ticket/21015, because the `__file__` attribute was used in migration file discovery.
     3The migrate command currently checks for existence of a `__file__` attribute on the `migrations` package. This check was introduced in #21015, because the `__file__` attribute was used in migration file discovery.
    44
    5 However, in https://code.djangoproject.com/ticket/23406 migration file discovery was changed to use `pkgutil. iter_modules ()`, instead of direct filesystem access.  `pkgutil. iter_modules()` uses the package's `__path__` list, which exists on implicit namespace packages.
     5However, in #23406 migration file discovery was changed to use `pkgutil.iter_modules ()`, instead of direct filesystem access. `pkgutil. iter_modules()` uses the package's `__path__` list, which exists on implicit namespace packages.
    66
    77As a result, the `__file__` check is no longer needed, and in fact prevents `migrate` from working on namespace packages (implicit or otherwise).
    88
    9 
    10 Related work: https://code.djangoproject.com/ticket/29091
     9Related work: #29091
Back to Top