Make htmlreport installable single package#6335
Make htmlreport installable single package#6335firewave merged 31 commits intocppcheck-opensource:mainfrom
Conversation
|
Thanks for your contribution. It is has been quite a while since I did a Python package so I am not sure how well I can comment on that. So just some generic observations. Would this work as intended? We rarely touch this but this would decouple the script from the binary. So usually the versions would be in sync but now you have be running different versions and that might lead to issues in the future. We definitely do not intend to have some sort of backwards compatibility being maintained in the script. And on a non-rolling distro without something brew/universe/AUR the cppcheck version is usually lacking way behind whereas the version in PyPi would be the latest. I am not sure we actually want to publish that. Please make sure you properly rename We also need to make sure that it will still work for existing users/installations so we possibly need some kind of compatibility layer/link. That might get in the way of renaming the file though. You also removed the executable flag from |
98c1b17 to
ea9713d
Compare
|
@firewave, thank you for the prompt reply!
That was Windows removing this flag for some reason. Should be fixed now.
Should be fixed, thank you for pointing out!
With those changes I can install the cppcheck\htmlreport $ pip install .
Processing d:\projects\python\cppcheck\htmlreport
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: Pygments in d:\projects\python\cppcheck\venv\lib\site-packages (from cppcheck-htmlreport==0.0.0) (2.17.2)
Building wheels for collected packages: cppcheck-htmlreport
Building wheel for cppcheck-htmlreport (pyproject.toml) ... done
Created wheel for cppcheck-htmlreport: filename=cppcheck_htmlreport-0.0.0-py3-none-any.whl size=11757 sha256=b167955971dbe4e7031402012fe2c9dcd5c06d83c0189daa4fe5dccd963c5b02
Stored in directory: C:\Users\vladi\AppData\Local\Temp\pip-ephem-wheel-cache-nq44u7vz\wheels\42\5c\77\bd3ae971d3662d84cd1ec450ecf4d5bb4dca8e679d08ee5b6c
Successfully built cppcheck-htmlreport
Installing collected packages: cppcheck-htmlreport
Successfully installed cppcheck-htmlreport-0.0.0
# ===========================================================================
cppcheck\htmlreport $ gcm cppcheck-htmlreport
CommandType Name Version Source
----------- ---- ------- ------
Application cppcheck-htmlreport.exe 0.0.0.0 D:\Projects\python\cppcheck\venv\Scripts\cppcheck-htmlreport.exe
# ===========================================================================
cppcheck\htmlreport $ cppcheck-htmlreport --help
Usage: cppcheck-htmlreport [options]
Options:
-h, --help show this help message and exit
--title=TITLE The title of the project.
--file=FILE The cppcheck xml output file to read defects from. You can combine results from several xml reports i.e. "--file file1.xml --file file2.xml ..". Default is reading from stdin.
--report-dir=REPORT_DIR
The directory where the HTML report content is written.
--source-dir=SOURCE_DIR
Base directory where source code files can be found.
--add-author-information=ADD_AUTHOR_INFORMATION
Blame information to include. Adds specified author information. Specify as comma-separated list of either "name", "email", "date" or "n","e","d". Default: "n,e,d"
--source-encoding=SOURCE_ENCODING
Encoding of source code.
--blame-options=BLAME_OPTIONS
[-w, -M] blame options which you can use to get author and author mail -w --> not including white spaces and returns original author of the line -M --> not including moving
of lines and returns original author of the lineI am not sure what you mean by
One of the options I see to preserve backward compatibility: Would you tell if that makes sense for you? |
That seems like an oversight. Please file a ticket about that.
But those should have a fixed dependency on the So if you pull it from PyPi you might get the latest script but have an outdated binary. Although many distros now discourage pulling from PyPi and ask you to install the We should also add a test to the CI to make sure that it works and doesn't break in the future. That should be possible by using a virtualenv and would go into |
PyPI provides package's version support. If you release It may be benefitial to provide a way to install report generation tool only. For example, we may have a device that runs analysis processes and publish XML reports as artifacts. A QA engineer may want to create a report from that artifacts, so it seems reasonable that they may want to install only HTML generation tool instead of full-featured CppCheck environment they will not use.
Sure, will update that. |
10b6f2d to
8feaad5
Compare
…ow Python 3.7 support
|
Thanks @vpetrigo and @firewave
that is a very good observation that I did not think about directly. So as far as I see we can make pretty drastic changes to cppcheck binary without affecting the compatibility with cppcheck-htmlreport. We can rename every command line flag for instance. But changing the xml file format would break compatibility with cppcheck-htmlreport. |
Yeah - I totally blanked on it just depending on the XML output and not the CLI. I have actually never used it (or at least not for many, many, many years) but only adjusted tests for it. |
Current changes take the version from the Git. So, if a user installs $ pip install "git+https://github.com/vpetrigo/cppcheck@feature/installable_htmlreport#subdirectory=htmlreport"
$ pip list
Package Version
------------------- ---------------------
cppcheck-htmlreport 0.1.dev28213+ga111c84
pip 24.0
Pygments 2.17.2And it provides an understanding that the current |
danmar
left a comment
There was a problem hiding this comment.
lgtm.. I know nothing about python packaging though.
|
If it is required, let me know if you want to change |
|
@firewave do you think I can merge? |
|
Will take a proper look this weekend. |
| **/*.egg-info/ | ||
|
|
||
| # cppcheck-htmlreport auto files | ||
| htmlreport/cppcheck_htmlreport/run.py |
There was a problem hiding this comment.
Should this be fixates on the root i.e. start with a slash?
There was a problem hiding this comment.
Yes, that should be updated!
| "cppcheck-htmlreport", | ||
| ], | ||
| install_requires=['Pygments'] | ||
| author="Henrik Nilsson", |
There was a problem hiding this comment.
yes.. could we change author to "Cppcheck team" perhaps?
| }, | ||
| test_suite="tests", | ||
| install_requires=["Pygments"], | ||
| setup_requires=["setuptools>=60", "setuptools-scm>=7.0"], |
There was a problem hiding this comment.
Why do we need those specific versions? Please add a small comment.
There was a problem hiding this comment.
Sure, will add a comment. That is the requirement of the stable version of the setuptool-scm package that allows getting package version from a source control.
| @@ -1,12 +1,15 @@ | |||
| [tox] | |||
| envlist=py26,py27,py32,pypy | |||
| envlist = py26,py27,py32,pypy,pip | |||
There was a problem hiding this comment.
I guess we no longer need the py26 stuff. Also Python 2.7 needs to be officially deprecated (I filed https://trac.cppcheck.net/ticket/12682 about that).
There was a problem hiding this comment.
Sure, I can remove that. I have not found any usage of tox though in the CI scripts you have. Would you confirm if it is still in use?
There was a problem hiding this comment.
I have do not even have an idea what tox is...
If this is unused we should just remove it.
There was a problem hiding this comment.
If we keep the file please make sure it was moved within git. Currently it shows up as deleted/added.
There was a problem hiding this comment.
BTW Python 2.7 is deprecated now and the leftovers will be removed after the next release.
There was a problem hiding this comment.
I have encountered this before. It seems to be a bug or at least some quirk within git/GitHub - and a bad one. Fortunately it only occurred with unimportant files so far.
There was a problem hiding this comment.
It is a known GitHub issue: https://github.com/orgs/community/discussions/43177
And it explains why we have only seen it with "unimportant( i.e. small files). It was kind of my assumption that it happens if there were "too many" changes in a moved file.
|
Sorry for being so pedantic about things (I wouldn't call it thorough) but we have so much cruft in our codebase so it makes sense to to take of that while at it. Also often external submissions are one-shots and we should get those as proper as possible because applying them otherwise there are further pieces to pick up later on. Possibly by somebody else...and possibly not for years... |
80f9c06 to
4a3cdb2
Compare
| htmlreport/test_htmlreport.py | ||
| test/tools/htmlreport/test_htmlreport.py | ||
| cd htmlreport | ||
| ./check.sh |
There was a problem hiding this comment.
This still needs to be moved to test/tools/htmlreport
| [testenv:pip] | ||
| setenv = PIP_PACKAGE_TEST=1 | ||
|
|
||
| [testenv:py26] |
There was a problem hiding this comment.
This can probably be removed as we no longer specify it above.
But I really think we can just drop the whole file as it is about automated testing and we never used in the repo. If somebody external depends on it they will raise this issue and we can then re-add it and also implement it in our CI.
It was added in 97119b8 and the referenced page in that commit doesn't even exist anymore.
There was a problem hiding this comment.
tox.ini removed from the repository.
| PYTHON=python | ||
| fi | ||
|
|
||
| PROJECT_ROOT_DIR=$(git rev-parse --show-toplevel) |
There was a problem hiding this comment.
This won't work if you are running this from a source package without a repo.
In other scripts we use DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" to get the script dir. And then traverse back from that.
There was a problem hiding this comment.
Should be fixed now.
| ERRORLIST_XML="$REPORT_DIR/errorlist.xml" | ||
| UNMATCHEDSUPPR_XML="$REPORT_DIR/unmatchedSuppr.xml" | ||
|
|
||
| $PYTHON cppcheck-htmlreport --file ../gui/test/data/xmlfiles/xmlreport_v2.xml --title "xml2 test" --report-dir "$REPORT_DIR" --source-dir ../test/ |
There was a problem hiding this comment.
Should this be also removed from the script?
There was a problem hiding this comment.
No - that is totally fine.
I was just commenting how that is a good thing that we got rid of the relative paths.
Switch from git project root to POSIX project root getter
firewave
left a comment
There was a problem hiding this comment.
LGTM. If CI passes we can merge this.
Update test cases where Python expects cppcheck-htmlreport script to be in the same directory
Update test cases where Python expects cppcheck-htmlreport script to be in the same directory
|
Thanks a lot for your contribution. And especially your patience. |

Hello!
I would like to propose a set of changes to make
cppcheck-htmlreportinstallable. That would allow to easliy install that module viapip,pipx, etc.For example, with
pipxyou can installcppcheck-htmlreportexecutable as follow:That also allows populating
Pygmentsinto user's environment automatically. No need to switch to thehtmlreportand executepip install .or something.After that the user is able to use
cppcheck-htmlreportwithout installation of DEB/RPM packages. Moreover, on Windows it allows usage of this utility withot necessity to execute it like that, because shebans are not supported there:That changes can be used for publishing the package to the PyPI if needed.
Let me know if you would like me to update/change something in this PR.
Thank you!