wemake-services / wemake-services/django-split-settings
Support loading of `.pyc` files
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 73
- Avg merge
- 6h 3m
- Merged PRs (30d)
- 3
Description
Currently the process for loading the file run the file through compile and then exec.
This works perfectly for .py files (thanks for the project, by the way, it is really awesome).
I have a project where the files are precompiled into .pyc during building the production version, and all .py files are deleted from the codebase.
This causes two issues:
- The names in the
includecall are no longer present. They've been deleted in a previous build step. - Even if I use a workaround for issue 1, the
.pycfiles do not work with thecompile+execapproach.
I would like to request the ability to load .pyc files by addressing both of these points.
-
Allowing scripts to have a fallback, that is only loaded if the file is not found. Maybe that can be built into the
optionalimplementation.include( optional("abc.py", "abc.pyc"), # ... ) -
Allowing
.pycfiles to be loaded. I've done it locally using this.import marshal import types with open(included_file, 'rb') as to_compile: to_compile.seek(16) compiled_code = marshal.load(to_compile) if isinstance(compiled_code, types.CodeType): exec(compiled_code, scope)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in split_settings/tools.py at the linked loading code and then trace the existing optional implementation. Determine how the include API should express a fallback and how the loader should handle the .pyc format; done means both fallback includes and precompiled files load successfully without their source files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100