build system modules: decorators are now free-standing (and renamed)#2860
Conversation
|
Is it still possible to convert: @AutotoolsPackage.run_after('install')to: @run_after('install')? |
|
@adamjstewart It's another thing on my |
|
Any reason to keep the old names? |
|
Also, +1 on converting. I'm still thinking post_ and pre_ methods would be nice for users, but that can wait. |
@tgamblin If they are really sanity checks or precondition checks? But that's really a super minor point, so I wouldn't mind if we decide to delete them. |
|
I don't mind keeping the old ones. Sometimes they really are for preconditions and sanity checks. But I also wouldn't be opposed to removing them. KISS principle always wins. I'll let someone else decide. |
|
I have an inconsistent argument. I think we should get rid of the old names so there's one way to do this. I also think we should add pre_ and post_ methods so we have one more (easier) way to do it. Or, we could just use pre_ and post_ methods so that user-contributed packages are clearer... Homebrew has pre/post methods FWIW. I worry that things will get hard to read when we start stacking I'm not particularly passionate about this, though so if you just want to convert and leave one way to do it for now that's fine with me. |
|
I agree with @tgamblin on adding |
|
KISS. Use the new ones. |
On the other hand with a decorator you can separate different actions into different functions and execute them after or before the same phase. This helps maintaining the code clean. |
|
It'll also help new people read packages and contribute-- one less thing to learn. |
Maybe writing them (and not in this specific case). Using them should be a piece of cake if they are written correctly 😄 |
|
Ok, so I'll try to make them "free-standing" decorators and remove the old names. I'll ping people when done. |
|
I know you would have liked to keep the old names, but I think: @sanity_check('install')
def sanity_check_prefix:is just as explanatory as: @run_after('install')
def sanity_check_prefix:You can always make it sound like a sanity check in the function name. |
|
Right, so I think for now let's go with one name for simple decorators and plan to add pre and post. Sound good? |
|
@tgamblin How do you feel about:
What I have in mind is that: @run_after('install')
def foo(self):
...should be equivalent to: def foo_post_install(self):
...I don't think it requires a lot more code to do that. |
|
I was thinking just:
For simplicity. Only challenge: maintain execution order == declaration order if these are mixed with decorators. |
That could be difficult without the The contract I was thinking was weaker: no relative order ensured for functions in the same pool (e.g. the ones that execute before a given phase). After all if you need to execute |
to have less things to remember, i would remove old names completely. Even if it's a sanity check, it still reads fine with p.s. apparently, the same point is already raised by @adamjstewart above #2860 (comment) 😄 |
|
Fair enough. We do guarantee that |
from a python noob's perspective, i don't know how decorators work, but it's enough to see a single example to adapt it to ones needs. Personally, i would not bother with |
|
@davydden You came late to the party 😆 Old names already removed, and decorators are not tied to base classes anymore. So: @run_before('install')
def foo(self):
...is the new @AutotoolsPackage.precondition('install')
def foo(self):
... |
adamjstewart
left a comment
There was a problem hiding this comment.
I think this is a really good start! We can argue about pre_ and post_ methods in another issue. Everything looks good to me as long as there are no packages that still reference precondition and sanity_check.
|
@tgamblin @adamjstewart Let me know if you want me to proceed further here or in another PR. I am not in a rush to get this in, so any solution is fine with me. BTW, does the metaclass code look cleaner? I tried to make it less complicated while I was at it. |
38865ec to
6b64146
Compare
|
@adamjstewart you may want to have a look at 6b64146. That's what I intended yesterday when I said in #2869 that I wanted to push the driver function for tests up in the hierarchy |
…an alias of `sanity_check`
6b64146 to
0bb03dd
Compare
|
ping |
|
@alalazo: thanks! If you want to continue in another PR that is fine, but I don't think there is a rush. |
…ack#2860) * PackageMeta: `run_before` is an alias of `precondition`, `run_after` an alias of `sanity_check` * PackageMeta: removed `precondition` and `sanity_check` * PackageMeta: decorators are now free-standing * package: modified/added docstrings. Fixed the semantics of `on_package_attributes`. * package: added unit test assertion as side effects of install * build_systems: factored build-time test running into base class * r: updated decorators in package.py * docs: updated decorator names
) * PackageMeta: `run_before` is an alias of `precondition`, `run_after` an alias of `sanity_check` * PackageMeta: removed `precondition` and `sanity_check` * PackageMeta: decorators are now free-standing * package: modified/added docstrings. Fixed the semantics of `on_package_attributes`. * package: added unit test assertion as side effects of install * build_systems: factored build-time test running into base class * r: updated decorators in package.py * docs: updated decorator names
…ack#2860) * PackageMeta: `run_before` is an alias of `precondition`, `run_after` an alias of `sanity_check` * PackageMeta: removed `precondition` and `sanity_check` * PackageMeta: decorators are now free-standing * package: modified/added docstrings. Fixed the semantics of `on_package_attributes`. * package: added unit test assertion as side effects of install * build_systems: factored build-time test running into base class * r: updated decorators in package.py * docs: updated decorator names
Modifications
@run_beforeis the substitute for@*.precondition@run_afteris the substitute for@*.sanity_check@on_package_attributesis the substitute for@*.on_package_attributes