Support loading config from module #799

Merged
merged 1 commit into from Jun 20, 2014

Projects

None yet

4 participants

@graingert
Contributor

No description provided.

@graingert
Contributor

This allows configuration with gunicorn -c project.gunicorn_config rather than

gunicorn -c `python -c "print(__import__('project.gunicorn_config').__file__)"`

This is useful as in general all python code should be deployed using setuptools/distutils packages to gain the advantages of eggs, zips and wheels. Unfortunately this results in the indeterminate location of python files.

I'd like to move to deprecate loading from files to greatly simplify the code.

@benoitc
Owner
benoitc commented Jun 19, 2014

Thanks for the patch :)

Although it looks like a duplicate from #789 did you actually tested the latest master? Is something missing?

@graingert
Contributor

@benoitc this is different from #789 in that here we load a module rather than a path to a py or pyc file.

@benoitc benoitc commented on an outdated diff Jun 19, 2014
gunicorn/app/base.py
@@ -6,6 +6,7 @@
import os
import sys
import traceback
+import importlib
@benoitc
benoitc Jun 19, 2014 Owner

rather than importing import_lib, it should use the import_module function in gunicorn.util to make it compatible with old versions.

@benoitc
Owner
benoitc commented Jun 19, 2014

@graingert OK I see. And just commented ;)

@graingert
Contributor

I will add documentation if this patch adds desired behaviour :)

@benoitc
Owner
benoitc commented Jun 19, 2014

+1 for the change.

@graingert
Contributor

Added documentation

@berkerpeksag
Collaborator

LGTM.

@benoitc benoitc merged commit d3832df into benoitc:master Jun 20, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@graingert graingert deleted the graingert:patch-3 branch Jun 20, 2014
@tilgovi
Collaborator
tilgovi commented Jun 20, 2014

Good patch, but does it make sense to try filename before modules instead of the other way around? That would be more consistent with the normal importer (local relative then global modules), no?

@benoitc
Owner
benoitc commented Jun 22, 2014

@tilgovi +1 we should switch the order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment