Debian Codegraph @

docs/contribution.rst

raw
1 .. _contributor_guide:
2
3 :tocdepth: 2
4
5 *****************
6 Contributor guide
7 *****************
8
9 Development environment
10 =======================
11
12 If you’re reading this, you’re probably interested in contributing to inflate64.
13 Thank you very much! The purpose of this guide is to get you to the point
14 where you can make improvements to the Infalte64 and share them with the rest of the team.
15
16
17 Setup Python and C compiler
18 ---------------------------
19
20 The Inflate64 is written in the Python and C languages bound with C Foreign
21 Function Interface, and CPython C/C++ API.
22
23 Python installation for various platforms with various ways.
24 You need to install Python environment which support `pip` command.
25 Venv/Virtualenv is recommended for development.
26
27 Get Early Feedback
28 ------------------
29
30 If you are contributing, do not feel the need to sit on your contribution
31 until it is perfectly polished and complete. It helps everyone involved
32 for you to seek feedback as early as you possibly can.
33 Submitting an early, unfinished version of your contribution
34 for feedback in no way prejudices your chances of getting that contribution accepted,
35 and can save you from putting a lot of work into a contribution that is not suitable for the project.
36
37
38 Code Contribution
39 =================
40
41 Steps submitting code
42 ---------------------
43
44 When contributing code, you’ll want to follow this checklist:
45
46 1. Fork the repository on GitHub.
47
48 2. Run the tox tests to confirm they all pass on your system. If they don’t, you’ll need
49 to investigate why they fail. If you’re unable to diagnose this yourself,
50 raise it as a bug report.
51
52 3. Write tests that demonstrate your bug or feature. Ensure that they fail.
53
54 4. Make your change.
55
56 5. Run the entire test suite again using tox, confirming that all tests pass
57 including the ones you just added.
58
59 6. Send a GitHub Pull Request to the main repository’s master branch.
60 GitHub Pull Requests are the expected method of code collaboration on this project.
61
62 Code review
63 -----------
64
65 Contribution will not be merged until they have been code reviewed. There are limited
66 reviewer in the team, reviews from other contributors are also welcome.
67 You should implemented a review feedback unless you strongly object to it.
68
69
70 Code style
71 ----------
72
73 The inflate64 uses the PEP8/Black code style. In addition to the standard PEP8,
74 we have an extended guidelines.
75
76 * line length should not exceed 125 characters.
77 * Black format prettier is enforced.
78 * It also use MyPy static type check enforcement.
79
80
81 Test cases
82 ----------
83
84 There is three types of tests and we measures coverages;
85
86 * Unit tests for encode and decode, single data, and multiple data.
87 * Integration test with CSV file which size is larger than buffer size.
88 * Hypothesis fuzzing test.
89
90 All tests should be passed before merging.
91
92
93 C bindings development
94 ======================
95
96 Debugging bindings has always been itchy task for developers.
97 Even proprietary modern IDEs, such as PyCharm Professional/CLion, does not provide
98 a cross debugging feature.
99 Ref: https://youtrack.jetbrains.com/issue/CPP-5797
100
101 CMake
102 -----
103
104 The project has a `CMakeLists.txt` file to run cross-debugging,
105 CMake is a cross-platform builder meta tool for C/C++ projects.
106
107 Jetbrains CLion
108 ---------------
109
110 CLion is an IDE tool for C/C++ development that support CMake for build configuration.
111
112 Dependency
113 ----------
114
115 - Python > 3.9
116 - python development files (for example python3.8-dev package)
117 - venv
118 - GCC or CLang C/C++ compiler
119 - CMake 3.19 or later
120
121 When you want to change target python variation and version, please edit CMakeLists.txt#L8-L9
122
123 .. code-block:: cmake
124
125 set(PY_VERSION 3.13)
126 set(Python_FIND_IMPLEMENTATIONS PyPy)
127
128
129 Manual build and run
130 --------------------
131
132 TL;DR
133
134 .. code-block:: console
135
136 mkdir cmake-build
137 cd cmake-build
138 cmake ..
139 make pytest_runner
140 gdb ./pytest_runner ../tests
141
142
143 pytest_runner is a generated program that help you run pytest under C/C++ debugger.
144 You may want to run it on IDE environment.
145
146 You can also run pytest with tox
147
148 .. code-block:: console
149
150 tox -e py313
151
152
153 Library build
154 -------------
155
156 .. code-block:: console
157
158 cd cmake-build
159 make generate_ext
160
161
162 CMake targets and files
163 -----------------------
164
165 THere are several targets you can build.
166
167 pytest_runner:
168 A C++ program that launch python and pytest. The source code is generated by CMake
169 configuration onto cmake build directory (cmake-build in above example).
170
171 generate_ext:
172 A virtual target to produce C extension for CPython.
173
174 venv.stamp:
175 interim target to produce virtualenv environment for pytest_runner