-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Simplify/Refactor buildutils.py #1012
Conversation
eea1427
to
44e2d29
Compare
758a928
to
ca7133a
Compare
🎉 ... as I mentioned elsewhere, this is not necessarily my strength. From what I can tell, this is largely to improve formatting, with a couple of more substantial changes. Big 👍 for |
Thanks @ischoegl!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objections from my side - the CI appears to be happy, so I am happy (I don't have enough insights to go beyond).
PS: Regarding my comment about os.path
- I noticed a couple of new imports for the 'un'preferred library, hence my comment. ... overall I second your preference for pathlib
, but it appears the transition will come later, correct? From personal experience, replacing paths is laborious, and the diff is already quite busy because of the formatting changes. So leaving it for later is likely preferable.
Thanks @ischoegl If there are any places where you see possible improvements in the Python, I'd be happy to know them!
Yes, that's my plan 😄 I started here by limiting the imports that I should also say that I'm trying to keep exact feature parity as I make these changes, including exactly the same output as before. So far, I've been successful 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright 😉 ... I looked over buildutils.py
and have a couple of minor points. Can give it a closer look later on.
Understood about from xyz import *
... linters really don't like it.
218be8a
to
c118b33
Compare
fefe212
to
dcb04c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I believe the Python code overall looks good, some of the docstrings could use improvements. Also, you started applying PEP 484, but didn't follow through with all signatures. While I know that some don't like the appearance, I find those annotations tremendously helpful even when looking at code that I wrote myself (especially once short-term memory no longer kicks in).
285abdd
to
6edf040
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryanwweber ... feel free to consider all of my comments as resolved. I'll leave a final approval to those with more intricate knowledge of the internal workings of scons
(myself, I'd have to rely on GH Actions passing). Apart from that, I am pretty happy that I can make more sense of buildutils.py
after the refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of my in-line comments are fairly minor.
The one slightly larger concern I have is that I don't really see the benefit to using the logging
module here. I don't think it's possible to use any of this except when run as a script by SCons, so there's not really a case where this would need to interact with other logging activities, which is where the more complex logging machinery makes sense. This takes a chunk of additional setup in build_utils.py
, plus has several end-use points where you are forced to do convoluted things like logger.info(__doc__, extra={"print_level": False})
instead of the simple print(__doc__)
.
@speth I considered a few things in choosing the
Now, the counterarguments (which you've noted, and which I also thought of in working on this and balanced in favor of
So, those are the thoughts that I had. I did consider a couple of other options for terminal output as well... One was, if you look at the commit history, I'm pretty sure it's still there where I started with two I similarly thought about using a Let me know what you think! Like I said, I'm not totally sold on using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think I'm satisfied with the direction this has gone. There were just two minor suggested changes below.
I agree that there's some benefit to using logging.info("...")
instead of print("INFO: ...")
, and the print_level
argument is not that bad for the handful of cases where we want to print something without a prefix.
Regarding a few of the comments, I'm not convinced that trying to reduce the verbosity of the build system would be productive. There are just too many cases where the details of the build log are the only thing that helps identify a problem. But this PR doesn't actually move in that direction, so this is kind of a moot point.
Exit immediately if Python 2 is running SCons Going forward, we want to use Python 3 syntax features, which cause SConstruct to raise a SyntaxError during parsing in Python 2 and no code is executed. As such, it is not possible to use the standard exception flow to raise a useful error message unless we force SConstruct to use only Python 2 compatible syntax. Therefore, this change introduces an "f"-string that will raise a SyntaxError in Python 2 with a message about running SCons with Python 3.
- Use an enum to represent the test state. - Use the loggers to produce terminal output
Remove unused functions
Do not use pathlib.glob because SCons Glob is able to glob through Nodes that may not be actual files on the disk.
Set up a filter and output formatter so that there is only a single instance of a logger class. Whether or not the level name is printed with the message is determined by the print_level key in the extra dictionary argument. This change clarifies the purpose of the previous two logger instances. The output of error level and higher is sent to the stderr stream, all lower levels are sent to stdout.
Each SConscript module imports what it needs from the stdlib.
* Bintray is sunsetting, so download Boost from Sourceforge * Use Miniforge in the Sundials builds, since Sundials comes from conda-forge anyways
This simplifies using the logger functions.
f9d8d68
to
3016f36
Compare
In Cantera#1012, normapth was no longer exported from buildutils, but I missed adding that import in the builder for python_minimal. In addition, Dict is only available while type checking in buildutils, so it should be quoted as a forward reference.
In #1012, normapth was no longer exported from buildutils, but I missed adding that import in the builder for python_minimal. In addition, Dict is only available while type checking in buildutils, so it should be quoted as a forward reference.
Changes proposed in this pull request
site_scons/buildutils.py
file. As mentioned in the discussion post, this is going to be a long-running project. I'm planning to do the scripts/files in batches, sobuildutils.py
was the first.Checklist
scons build
&scons test
) and unit tests address code coverage