Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove archaic monkey patches #15338

Merged
merged 1 commit into from
Aug 29, 2024
Merged

Conversation

AlanCoding
Copy link
Member

SUMMARY

I am about 95% sure that we don't need any of these for any reason anymore.

Some are fairly obvious, like, if it modifies awx-manage runserver behavior, then we should be good, because that's outrageously unsupported in every sense of the word.

However, find_commands is the most likely to have fallout here. I believe this was written for a time when the source was not distributed along with the compiled files, which is an issue resolved by going open source. I find it incredibly unlikely that someone is distributing AWX without the source files, and if they are, I would ask them to stop.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API

for opt in ('ENGINE', 'NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'): # pragma: no cover
if os.environ.get('AWX_TEST_DATABASE_%s' % opt, None):
settings.DATABASES['default'][opt] = os.environ['AWX_TEST_DATABASE_%s' % opt]
# Disable capturing all SQL queries in memory when in DEBUG mode.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the exact opposite of what I would ever want...

@AlanCoding
Copy link
Member Author

In Django itself find_commands has evolved significantly.

https://github.com/django/django/blob/f302343380c77e1eb5dab3b64dd70895a95926ca/django/core/management/__init__.py#L29

It now defers to pkgutil.iter_modules output, which gives ModuleInfo where ispkg determines if it is included or not.

https://docs.python.org/3/library/pkgutil.html#pkgutil.ModuleInfo

Exactly where that gets its stuff from is more complex, but appears to resolve to sys.path_hooks, which has 4 by default, but FileFinder is probably the one we care about, and probably handles .pyc files, and does it much better than our old hack.

@@ -106,46 +89,13 @@ def prepare_env():

if not settings.DEBUG: # pragma: no cover
warnings.simplefilter('ignore', DeprecationWarning)
# Monkeypatch Django find_commands to also work with .pyc files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surely a relic of closed source tower shipping without source .py files

Copy link

sonarcloud bot commented Aug 23, 2024

@AlanCoding
Copy link
Member Author

Initial ("yolo") test run is looking good!

@AlanCoding AlanCoding merged commit 50db801 into ansible:devel Aug 29, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants