crcmod-plus 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crcmod-plus-2.0.0/LICENSE.txt +22 -0
- crcmod-plus-2.0.0/PKG-INFO +156 -0
- crcmod-plus-2.0.0/README.md +99 -0
- crcmod-plus-2.0.0/lib/_crcfunext.c +608 -0
- crcmod-plus-2.0.0/pyproject.toml +76 -0
- crcmod-plus-2.0.0/setup.cfg +4 -0
- crcmod-plus-2.0.0/setup.py +38 -0
- crcmod-plus-2.0.0/src/crcmod/__init__.py +19 -0
- crcmod-plus-2.0.0/src/crcmod/_crcfunpy.py +116 -0
- crcmod-plus-2.0.0/src/crcmod/_version.py +2 -0
- crcmod-plus-2.0.0/src/crcmod/crcmod.py +463 -0
- crcmod-plus-2.0.0/src/crcmod/predefined.py +182 -0
- crcmod-plus-2.0.0/src/crcmod_plus.egg-info/PKG-INFO +156 -0
- crcmod-plus-2.0.0/src/crcmod_plus.egg-info/SOURCES.txt +16 -0
- crcmod-plus-2.0.0/src/crcmod_plus.egg-info/dependency_links.txt +1 -0
- crcmod-plus-2.0.0/src/crcmod_plus.egg-info/requires.txt +3 -0
- crcmod-plus-2.0.0/src/crcmod_plus.egg-info/top_level.txt +1 -0
- crcmod-plus-2.0.0/tests/test_crcmod.py +699 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
----------------------------------------------------------------------------
|
|
2
|
+
Copyright (c) 2010 Raymond L. Buvel
|
|
3
|
+
Copyright (c) 2010 Craig McQueen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
----------------------------------------------------------------------------
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: crcmod-plus
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: CRC generator - modernized
|
|
5
|
+
Author-email: Ray Buvel <rlbuvel@gmail.com>
|
|
6
|
+
Maintainer-email: Tamas Nepusz <tamas@sxd.hu>
|
|
7
|
+
License: ----------------------------------------------------------------------------
|
|
8
|
+
Copyright (c) 2010 Raymond L. Buvel
|
|
9
|
+
Copyright (c) 2010 Craig McQueen
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
|
19
|
+
all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
----------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
Project-URL: Repository, https://github.com/ntamas/crcmod-plus
|
|
31
|
+
Project-URL: Changelog, https://github.com/ntamas/crcmod-plus/blob/main/CHANGELOG.md
|
|
32
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Intended Audience :: Education
|
|
35
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
36
|
+
Classifier: Intended Audience :: Information Technology
|
|
37
|
+
Classifier: Intended Audience :: Science/Research
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Programming Language :: C
|
|
41
|
+
Classifier: Programming Language :: C++
|
|
42
|
+
Classifier: Programming Language :: Python
|
|
43
|
+
Classifier: Programming Language :: Python :: 3
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
47
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
48
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
49
|
+
Classifier: Topic :: Communications
|
|
50
|
+
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
51
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
52
|
+
Classifier: Topic :: Utilities
|
|
53
|
+
Requires-Python: >=3.7
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
Provides-Extra: dev
|
|
56
|
+
License-File: LICENSE.txt
|
|
57
|
+
|
|
58
|
+
[](https://github.com/ntamas/crcmod-plus/actions/workflows/build.yml)
|
|
59
|
+
|
|
60
|
+
# `crcmod` for calculating CRCs
|
|
61
|
+
|
|
62
|
+
The software in this repository is a modernised version of the `crcmod` Python
|
|
63
|
+
package, originally written by Ray Buvel. I took the original source code of
|
|
64
|
+
`crcmod` 1.7, dropped support for Python 2, reformatted the source files with
|
|
65
|
+
`black`, ran it through `ruff`, and added a modern build pipeline around it
|
|
66
|
+
based on `setuptools`, `pytest`, `tox` and `cibuildwheel` so I can create
|
|
67
|
+
pre-compiled wheels for the package using Github Actions.
|
|
68
|
+
|
|
69
|
+
Version 2.0.0 of this package is a drop-in replacement for `crcmod` 1.7 if
|
|
70
|
+
you are running Python 3.7 or later.
|
|
71
|
+
|
|
72
|
+
The contents of the original README file follows from here, with minor
|
|
73
|
+
alterations to the building and testing instructions to describe how it is done
|
|
74
|
+
now with the new setup.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
The software in this package is a Python module for generating objects that
|
|
79
|
+
compute the Cyclic Redundancy Check (CRC). There is no attempt in this package
|
|
80
|
+
to explain how the CRC works. There are a number of resources on the web that
|
|
81
|
+
give a good explanation of the algorithms. Just do a Google search for "crc
|
|
82
|
+
calculation" and browse till you find what you need. Another resource can be
|
|
83
|
+
found in chapter 20 of the book "Numerical Recipes in C" by Press et. al.
|
|
84
|
+
|
|
85
|
+
This package allows the use of any 8, 16, 24, 32, or 64 bit CRC. You can
|
|
86
|
+
generate a Python function for the selected polynomial or an instance of the
|
|
87
|
+
Crc class which provides the same interface as the `md5` and `sha` modules
|
|
88
|
+
from the Python standard library. A `Crc` class instance can also generate
|
|
89
|
+
C/C++ source code that can be used in another application.
|
|
90
|
+
|
|
91
|
+
## Guidelines
|
|
92
|
+
|
|
93
|
+
Documentation is available from the doc strings. It is up to you to decide
|
|
94
|
+
what polynomials to use in your application. If someone has not specified the
|
|
95
|
+
polynomials to use, you will need to do some research to find one suitable for
|
|
96
|
+
your application. Examples are available in the unit tests in the `tests`
|
|
97
|
+
folder. You may also use the `predefined` module to select one of the standard
|
|
98
|
+
polynomials.
|
|
99
|
+
|
|
100
|
+
If you need to generate code for another language, I suggest you subclass the
|
|
101
|
+
`Crc` class and replace the method `generateCode`. Use `generateCode` as
|
|
102
|
+
a model for the new version.
|
|
103
|
+
|
|
104
|
+
## Dependencies
|
|
105
|
+
|
|
106
|
+
### Python version
|
|
107
|
+
|
|
108
|
+
This package supports Python 3.7 and newer.
|
|
109
|
+
|
|
110
|
+
### Building C extension
|
|
111
|
+
|
|
112
|
+
To build the C extension, the appropriate compiler tools for your platform must
|
|
113
|
+
be installed. Refer to the Python documentation for building C extensions for
|
|
114
|
+
details. If you have a C compiler and all the usual Python development tools,
|
|
115
|
+
including the `build` frontend, then running `python -m build` should build the
|
|
116
|
+
package.
|
|
117
|
+
|
|
118
|
+
## Installation
|
|
119
|
+
|
|
120
|
+
The `crcmod-plus` package is installed from PyPI using `pip`. Run the following
|
|
121
|
+
command:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
$ pip install crcmod-plus
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Unit testing
|
|
128
|
+
|
|
129
|
+
`crcmod-plus` uses `pytest` as the testing environment. You can run the unit
|
|
130
|
+
tests with:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
$ pytest tests
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Code generation
|
|
137
|
+
|
|
138
|
+
The `crcmod` package is capable of generating C functions that can be compiled
|
|
139
|
+
with a C or C++ compiler. In the `tests` directory, there is an `examples.py`
|
|
140
|
+
script that demonstrates how to use the code generator. The result of this is
|
|
141
|
+
written out to the file `examples.c`. The generated code was checked to make
|
|
142
|
+
sure it compiles with the GCC compiler.
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
The `crcmod-plus` package is released under the MIT license. See the `LICENSE`
|
|
147
|
+
file for details.
|
|
148
|
+
|
|
149
|
+
## Authors
|
|
150
|
+
|
|
151
|
+
* Ray Buvel (the original `crcmod` package)
|
|
152
|
+
|
|
153
|
+
## Contributors
|
|
154
|
+
|
|
155
|
+
* Craig McQueen (contributor of the original `crcmod` package)
|
|
156
|
+
* Tamas Nepusz (modernisation into `crcmod-plus`)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
[](https://github.com/ntamas/crcmod-plus/actions/workflows/build.yml)
|
|
2
|
+
|
|
3
|
+
# `crcmod` for calculating CRCs
|
|
4
|
+
|
|
5
|
+
The software in this repository is a modernised version of the `crcmod` Python
|
|
6
|
+
package, originally written by Ray Buvel. I took the original source code of
|
|
7
|
+
`crcmod` 1.7, dropped support for Python 2, reformatted the source files with
|
|
8
|
+
`black`, ran it through `ruff`, and added a modern build pipeline around it
|
|
9
|
+
based on `setuptools`, `pytest`, `tox` and `cibuildwheel` so I can create
|
|
10
|
+
pre-compiled wheels for the package using Github Actions.
|
|
11
|
+
|
|
12
|
+
Version 2.0.0 of this package is a drop-in replacement for `crcmod` 1.7 if
|
|
13
|
+
you are running Python 3.7 or later.
|
|
14
|
+
|
|
15
|
+
The contents of the original README file follows from here, with minor
|
|
16
|
+
alterations to the building and testing instructions to describe how it is done
|
|
17
|
+
now with the new setup.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
The software in this package is a Python module for generating objects that
|
|
22
|
+
compute the Cyclic Redundancy Check (CRC). There is no attempt in this package
|
|
23
|
+
to explain how the CRC works. There are a number of resources on the web that
|
|
24
|
+
give a good explanation of the algorithms. Just do a Google search for "crc
|
|
25
|
+
calculation" and browse till you find what you need. Another resource can be
|
|
26
|
+
found in chapter 20 of the book "Numerical Recipes in C" by Press et. al.
|
|
27
|
+
|
|
28
|
+
This package allows the use of any 8, 16, 24, 32, or 64 bit CRC. You can
|
|
29
|
+
generate a Python function for the selected polynomial or an instance of the
|
|
30
|
+
Crc class which provides the same interface as the `md5` and `sha` modules
|
|
31
|
+
from the Python standard library. A `Crc` class instance can also generate
|
|
32
|
+
C/C++ source code that can be used in another application.
|
|
33
|
+
|
|
34
|
+
## Guidelines
|
|
35
|
+
|
|
36
|
+
Documentation is available from the doc strings. It is up to you to decide
|
|
37
|
+
what polynomials to use in your application. If someone has not specified the
|
|
38
|
+
polynomials to use, you will need to do some research to find one suitable for
|
|
39
|
+
your application. Examples are available in the unit tests in the `tests`
|
|
40
|
+
folder. You may also use the `predefined` module to select one of the standard
|
|
41
|
+
polynomials.
|
|
42
|
+
|
|
43
|
+
If you need to generate code for another language, I suggest you subclass the
|
|
44
|
+
`Crc` class and replace the method `generateCode`. Use `generateCode` as
|
|
45
|
+
a model for the new version.
|
|
46
|
+
|
|
47
|
+
## Dependencies
|
|
48
|
+
|
|
49
|
+
### Python version
|
|
50
|
+
|
|
51
|
+
This package supports Python 3.7 and newer.
|
|
52
|
+
|
|
53
|
+
### Building C extension
|
|
54
|
+
|
|
55
|
+
To build the C extension, the appropriate compiler tools for your platform must
|
|
56
|
+
be installed. Refer to the Python documentation for building C extensions for
|
|
57
|
+
details. If you have a C compiler and all the usual Python development tools,
|
|
58
|
+
including the `build` frontend, then running `python -m build` should build the
|
|
59
|
+
package.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
The `crcmod-plus` package is installed from PyPI using `pip`. Run the following
|
|
64
|
+
command:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
$ pip install crcmod-plus
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Unit testing
|
|
71
|
+
|
|
72
|
+
`crcmod-plus` uses `pytest` as the testing environment. You can run the unit
|
|
73
|
+
tests with:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
$ pytest tests
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Code generation
|
|
80
|
+
|
|
81
|
+
The `crcmod` package is capable of generating C functions that can be compiled
|
|
82
|
+
with a C or C++ compiler. In the `tests` directory, there is an `examples.py`
|
|
83
|
+
script that demonstrates how to use the code generator. The result of this is
|
|
84
|
+
written out to the file `examples.c`. The generated code was checked to make
|
|
85
|
+
sure it compiles with the GCC compiler.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
The `crcmod-plus` package is released under the MIT license. See the `LICENSE`
|
|
90
|
+
file for details.
|
|
91
|
+
|
|
92
|
+
## Authors
|
|
93
|
+
|
|
94
|
+
* Ray Buvel (the original `crcmod` package)
|
|
95
|
+
|
|
96
|
+
## Contributors
|
|
97
|
+
|
|
98
|
+
* Craig McQueen (contributor of the original `crcmod` package)
|
|
99
|
+
* Tamas Nepusz (modernisation into `crcmod-plus`)
|