2.0 Stable Restructuring Changes
As part of defining a stable API for #155 (closed) and renaming a bunch of stuff for #149 (closed), I've been planning on restructuring some of the more poorly structured parts of portmod's code.
TODO:
-
(from !215 (merged)) portmod/repo/deps.py
should be broken up into multiple files, since it's quite large. Some of the functions are also quite large (e.g.weigh_clauses
), and should be broken up into multiple clauses to avoid problems associated with the reuse of identifiers and to make the code more concise and clear in purpose. It seems to make sense to split out the soft clause information inweigh_clauses
into its own file. -
The repo
submodule should be flattened out. Originally it was supposed to be the code for handling information stored in the repo, (as opposed to the code for handling installation, querying, CLI stuff etc.) however this distinction is no longer clear. Perhaps it could be re-created using only the parts which match this criterion.
Proposed new structure (incomplete):
portmod:
main.py: # Where everything comes together. A lot of code can probably be broken up, but the root parser
# should still be defined here.
deps:
__init__.py: # Definitions of root functions (primarily resolve) whose contents
# should be broken up into functions stored in other files in the module
# to avoid putting too much implementation details here."
weights.py: # Aforementioned functions created from `weigh_clauses`.
formula.py: # Definition of the formula and clause types
...
repo: # Stuff actually related to the repo? If there isn't enough to merit it, this should be removed
# and they should be included in the root module.
loader.py: # Functions for loading pybuilds. Note that the cache is not part of repo metadata and cache
# functions should be moved to their own file.
# Stack inspection utility functions should also be moved into their own file.
metadata.py: # No changes necessary here as far as I can tell.
atom.py:
usestr.py:
...
cache.py: # Functions for loading and creating pybuild cache files.
# Cache cleaning code from main.py might be able to be moved here too.
inspect.py: # Stack inspection code (is_module_scope and get_enclosing_filename, currently in loader.py).
...
Edited by Benjamin Winger