Skip to content

site-packages\django\contrib\sites has managment.py file which is conflicting with managment directory and causing a issue in tree get issue in _pyi_pkgutil_iter_modules as dirretory name and file are same  #8191

Closed

Description

@eshopblr

When I execute a generated exe from pyinstaller, it is failing as django.contrib.sites has mangment.py file which is conflicting with package which by default will have management as directory.

as technically there is no management folder but when find_commands whose iterator is override by _pyi_pkgutil_iter_modules id expecting a tree node with dict but it has a file with managment.py so it is failing as str error.

If any app has management folder and also managment.py it will yield in to this issue. We can rename custom apps to avoid the file name duplication with management folder but how to deal with standard dajngo apps like django.contrib.sites

here is the stack trace

-> for pkg_name_part in pkg_prefix.parts:
(Pdb) pkg_prefix.parts
('django', 'contrib', 'sites', 'management', 'commands') ====> management here is expected a dict , as dict is not there it will be there in toc but as a file is there. it finds the file as str instead of dict and so is the assert.
(Pdb) c
Traceback (most recent call last):
File "manage.py", line 19, in
execute_from_command_line(sys.argv)
File "django\core\management_init_.py", line 442, in execute_from_command_line
File "django\core\management_init_.py", line 424, in execute
File "django\core\management_init_.py", line 222, in main_help_text
File "django\core\management_init_.py", line 78, in get_commands
File "django\core\management_init_.py", line 35, in find_commands
File "django\core\management_init_.py", line 35, in
File "C:\PythonWebCode\testone\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py", line 102, in _pyi_pkgutil_iter_modules
for pkg_name_part in pkg_prefix.parts:
AttributeError: 'str' object has no attribute 'get'

How can we address this issue ?

Activity

  1. added and removed
    triagePlease triage and relabel this issue
    on Dec 30, 2023
  2. rokm commented on Dec 30, 2023

    @rokm
    Member

    The following check


    should be changed into

    if not isinstance(tree_node, dict):

    This way, we handle both the case when the path does not exist (None) and the case when the path corresponds to a module (in PYZ) instead of a package (str).

  3. eshopblr commented on Dec 30, 2023

    @eshopblr
    Author

    have used path exists or not to differentiate . But the above option is good and cleaner.

    Aren't considering the key with management as a file and management as directory. As both are possible on OS. one of them overrides and looses the key as a dict or a file. In general similar file name and directory name.

  4. locked as resolved and limited conversation to collaborators on Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions