Skip to content
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

Port to Python 3 #23

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3af427a
Fix analyses/derivative.py
nlschn Feb 28, 2023
6013696
Fix analyses/discipline.py and minor things in analyses/derivative.py
nlschn Feb 28, 2023
55c81f8
Fix analyses/featurelocation
nlschn Feb 28, 2023
70884b1
Fix analyses/general.py
nlschn Feb 28, 2023
da347fe
Fix analyses/generalvalues.py
nlschn Feb 28, 2023
8a7fd76
Fix analyses/interaction.py
nlschn Feb 28, 2023
9280f3d
Make results of reduce a list or set
nlschn Feb 28, 2023
c6d1805
Fix cppstats/analysis.py
nlschn Feb 28, 2023
8e5aba4
Fix cppstats/cli.py
nlschn Feb 28, 2023
9037c93
Fix cppstats/cppstats.py
nlschn Feb 28, 2023
1744ccb
Fix cppstats/preparation.py
nlschn Feb 28, 2023
217a861
Fix lib/cpplib.py
nlschn Feb 28, 2023
7dd39da
Fix preparations/deleteIncludeGuards.py
nlschn Mar 8, 2023
696c2f9
Fix preparations/rewriteIfdefs.py
nlschn Mar 8, 2023
e66c4f2
Fix preparations/rewriteMultilineMacros.py
nlschn Mar 8, 2023
b9d8670
Fix scripts/ascope.py
nlschn Mar 8, 2023
3adaa72
Fix scripts/ifdefendifratio.py
nlschn Mar 8, 2023
10ad595
Fix scripts/partial_preprocessor.py
nlschn Mar 8, 2023
f333c66
Fix scripts/reversecpp.py and add missing dependency to setup.py
nlschn Mar 8, 2023
3200fad
Fix access to keys without casting to list
nlschn Mar 22, 2023
c628ee9
debug
nlschn Mar 22, 2023
bdcec44
Debug discipline
nlschn Apr 4, 2023
6645515
Fix operatorPrecedence being renamed in several files
nlschn Apr 4, 2023
8ad7215
Cast filter, map and zip objects to lists in generalvalues.py
nlschn Apr 4, 2023
cf98945
Replace has_key with in in derivative
nlschn Apr 4, 2023
cfd2f7d
Debug derivative
nlschn Apr 4, 2023
a67229a
Debug interaction
nlschn Apr 18, 2023
81fa27a
Debug
nlschn Apr 26, 2023
a01e716
Add documentation
nlschn May 2, 2023
8088918
Debug
nlschn Jun 28, 2023
f86a0ec
Make imports more relative than before
nlschn Jul 5, 2023
cd738ab
Fix more imports
nlschn Jul 5, 2023
5b7cbb7
Fix more imports
nlschn Jul 5, 2023
391616f
Fix more imports
nlschn Jul 5, 2023
d7a5359
Fix more imports
nlschn Jul 5, 2023
f61bcba
Fix more imports
nlschn Jul 5, 2023
71f5eed
Fix more imports
nlschn Jul 5, 2023
f224707
Fix more imports
nlschn Jul 5, 2023
7593373
Fix more imports
nlschn Jul 5, 2023
bc1813e
Fix more imports
nlschn Jul 5, 2023
8d16ce3
Fix more imports
nlschn Jul 5, 2023
24bb49a
Fix more imports
nlschn Jul 5, 2023
c64ad72
Fix more imports
nlschn Jul 5, 2023
fefdc2f
Fix more imports
nlschn Jul 5, 2023
fcb558a
Fix more imports
nlschn Jul 5, 2023
e3f8a37
Fix more imports
nlschn Jul 5, 2023
6c10bfc
Fix more imports
nlschn Jul 5, 2023
1762471
Fix more imports
nlschn Jul 5, 2023
bddf5c9
Fix more imports
nlschn Jul 5, 2023
4fd7e20
Fix more imports
nlschn Jul 5, 2023
d94a884
Fix more imports
nlschn Jul 5, 2023
eab13ff
Debug
nlschn Jul 19, 2023
d0ee1dd
Debug
nlschn Jul 19, 2023
52c202c
Debug
nlschn Jul 19, 2023
e89e540
Debug
nlschn Jul 19, 2023
c642c0e
Debug
nlschn Jul 19, 2023
a243858
Debug
nlschn Jul 19, 2023
505c73c
Debug
nlschn Jul 19, 2023
955d3bf
Debug
nlschn Jul 19, 2023
7d23d27
Debug
nlschn Jul 19, 2023
027fd8d
Debug
nlschn Jul 19, 2023
0ffa4f4
Debug
nlschn Jul 19, 2023
7ce9a59
Debug
nlschn Jul 19, 2023
8857d1e
Debug
nlschn Jul 19, 2023
0022dff
Debug
nlschn Jul 19, 2023
7556e28
Debug
nlschn Jul 19, 2023
85ea613
Debug
nlschn Jul 19, 2023
53a881a
Debug
nlschn Jul 19, 2023
3e80e8e
Debug
nlschn Jul 19, 2023
8300ed4
Debug
nlschn Jul 19, 2023
c2df95c
Debug
nlschn Jul 19, 2023
8669dac
Debug
nlschn Jul 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tmp/
projects/
## virtual environment
virtualenv/

venv/

### cppstats temporary files
## sample cppstats list-input
Expand Down
93 changes: 93 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Critical changes from porting to Python 3

### General
- Dependencies were updated.
- The dependency to `statlib` has been removed and replaced with `numpy`.

### Interaction Analysis
- The results have been wrong in the Python 2.7.x version of cppstats because duplicate combinations have not been removed
when counting the combinations with three or more variables. This is fixed in the Python 3 release.

### Testing
- Added a test script that can be used to compare the output of the Python 2 version with the output of the Python 3 version.

To run the test script you need to prepare various things:
1. Clone a project you would like to run the analyses on.
2. Inside the project folder, create a folder named "source" and move everything into there.
This should look something like this:

*Before:*
```
my_project
|- folder1
| |- file1.cpp
|- file1.cpp
|- file2.cpp
```

*After:*
```
my_project
|- source
| |- folder1
| | |- file1.cpp
| |- file1.cpp
| |- file2.cpp
```

3. Clone the `cppstats` repository.
4. Inside the `cppstats` project folder, create a Python 2 virtual environment and a Python 3 one (called `venv2` and `venv3` respectively).
Of course, both Python 2 and Python 3 need to be installed on your system.
```shell
python -m venv venv3
virtualenv --python=python2.7 venv2
```

5. Test that the virtual environments are indeed running the correct version. From your `cppstats` folder, run
```shell
source venv2/bin/activate
python --version
deactivate
```
which should yield some Python 2.7.x version. Similarly, try out
```shell
source venv3/bin/activate
python --version
deactivate
```
which should yield some Python 3 (ideally, at least Python 3.10) version.

6. Install all necessary dependencies in both virtual environments (see `setup.py` and `README.md`)

7. Clone the `statlib` repository into the `cppstats` folder. At this point the `cppstats` folder should look something like this:
```
cppstats
|- analyses
|- cppstats
|- lib
|- preparations
|- scripts
|- statlib
|- venv2
|- venv3
|- cppstats.sh
...
```

8. You should now be ready to run the test script. Refer to the command line parameter `--help` for detailed descriptions of
the other parameters and options.

The script will automatically pull the latest versions of `cppstats` for both Python 2 and 3 and also run the specified
analyses for both versions by using the correct virtual environments.
There is also no need for to change the `cppstats_input.txt` or to run `cppstats.sh` manually.

### Results
The results are collected and compared. An output can be seen on the command line (with varying degrees of details) and the
original result files can be found in the `results` folder that is created besides this script.

**Please note** that results for the interaction analysis are not going to match, i.e. this test **will fail**.
This is caused by the fact that a bug was fixed in the Python 3 version that causes the analysis to not double count particular
combinations of variables (see `CHANGELOG.md`).



5 changes: 1 addition & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ Current tested version of srcML:
1. checkout repo

```bash
git clone https://github.com/clhunsen/cppstats.git
git clone https://github.com/se-sic/cppstats.git
```

2. install needed libraries (+ all dependencies)

```bash
sudo apt-get install astyle # artistic style (code formatter)
sudo apt-get install xsltproc # XSLT 1.0 command line processor
sudo apt-get install libxml2 libxml2-dev # library for processing XML
sudo apt-get install gcc # GNU compiler collection
Expand Down Expand Up @@ -118,8 +117,6 @@ CYGWIN
libxslt-devel (1.1.27-2)
zlib (1.2.8-3)
zlib-devel (1.2.8-3)
- All/Utils/
astyle (2.03-1)
- All/Devel/
gcc (4.7.3-1)
+ all dependencies you are prompted for
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Details of the latest version can be found on the cppstats project site at GitHu
## System Requirements

* srcML (http://www.srcml.org/)
* astyle (http://astyle.sourceforge.net/)
* libxml2 (http://www.xmlsoft.org/)
* xsltproc (http://xmlsoft.org/XSLT/xsltproc2.html)
* gcc (https://gcc.gnu.org/)
Expand All @@ -61,10 +60,8 @@ system.

In detail, cppstats was successfully tested under:

* Ubuntu 12.04, Python 2.7.*, and
* Cygwin, Python 2.7.*.

Right now, Python 3.x is **NOT** supported.
* Ubuntu 12.04, Python >= 3.10, and
* Cygwin, Python >= 3.10.


## Quick Start
Expand Down
1 change: 1 addition & 0 deletions analyses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
#
# Contributors:
# Claus Hunsen <hunsen@fim.uni-passau.de>