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

Support loading config from module #799

Merged
merged 1 commit into from Jun 20, 2014
Merged

Conversation

graingert
Copy link
Contributor

No description provided.

@graingert
Copy link
Contributor Author

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
Copy link
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
Copy link
Contributor Author

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

@@ -6,6 +6,7 @@
import os
import sys
import traceback
import importlib
Copy link
Owner

Choose a reason for hiding this comment

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

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

@benoitc
Copy link
Owner

benoitc commented Jun 19, 2014

@graingert OK I see. And just commented ;)

@graingert
Copy link
Contributor Author

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

@berkerpeksag
Copy link
Collaborator

@graingert
Copy link
Contributor Author

@benoitc
Copy link
Owner

benoitc commented Jun 19, 2014

+1 for the change.

@graingert
Copy link
Contributor Author

Added documentation

@berkerpeksag
Copy link
Collaborator

LGTM.

benoitc added a commit that referenced this pull request Jun 20, 2014
#799 Support loading config from module

Thanks!
@benoitc benoitc merged commit d3832df into benoitc:master Jun 20, 2014
@graingert graingert deleted the patch-3 branch June 20, 2014 09:55
@tilgovi
Copy link
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
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants