pycugrep 0.1.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.
- pycugrep-0.1.0/LICENSE +208 -0
- pycugrep-0.1.0/PKG-INFO +85 -0
- pycugrep-0.1.0/README.md +62 -0
- pycugrep-0.1.0/pycugrep/__init__.py +0 -0
- pycugrep-0.1.0/pycugrep/bin/cugrep +0 -0
- pycugrep-0.1.0/pycugrep/cli.py +75 -0
- pycugrep-0.1.0/pycugrep.egg-info/PKG-INFO +85 -0
- pycugrep-0.1.0/pycugrep.egg-info/SOURCES.txt +14 -0
- pycugrep-0.1.0/pycugrep.egg-info/dependency_links.txt +1 -0
- pycugrep-0.1.0/pycugrep.egg-info/entry_points.txt +2 -0
- pycugrep-0.1.0/pycugrep.egg-info/not-zip-safe +1 -0
- pycugrep-0.1.0/pycugrep.egg-info/requires.txt +4 -0
- pycugrep-0.1.0/pycugrep.egg-info/top_level.txt +1 -0
- pycugrep-0.1.0/pyproject.toml +4 -0
- pycugrep-0.1.0/setup.cfg +4 -0
- pycugrep-0.1.0/setup.py +35 -0
pycugrep-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the Work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License.
|
|
68
|
+
|
|
69
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
70
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
71
|
+
royalty-free, irrevocable copyright license to reproduce, prepare
|
|
72
|
+
Derivative Works of, publicly display, publicly perform, sublicense,
|
|
73
|
+
and distribute the Work and such Derivative Works in Source or Object
|
|
74
|
+
form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License.
|
|
77
|
+
|
|
78
|
+
Subject to the terms and conditions of this License, each Contributor
|
|
79
|
+
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
|
80
|
+
royalty-free, irrevocable (except as stated in this section) patent
|
|
81
|
+
license to make, have made, use, offer to sell, sell, import, and
|
|
82
|
+
otherwise transfer the Work, where such license applies only to those
|
|
83
|
+
patent claims licensed by such Contributor that are necessarily
|
|
84
|
+
infringed by their Contribution(s) alone or by combination of their
|
|
85
|
+
Contribution(s) with the Work to which such Contribution(s) was
|
|
86
|
+
submitted. If You institute patent litigation against any entity
|
|
87
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
|
88
|
+
Work or a Contribution incorporated within the Work constitutes direct
|
|
89
|
+
or contributory patent infringement, then any patent licenses granted
|
|
90
|
+
to You under this License for that Work shall terminate as of the date
|
|
91
|
+
such litigation is filed.
|
|
92
|
+
|
|
93
|
+
4. Redistribution.
|
|
94
|
+
|
|
95
|
+
You may reproduce and distribute copies of the Work or Derivative Works
|
|
96
|
+
thereof in any medium, with or without modifications, and in Source or
|
|
97
|
+
Object form, provided that You meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
100
|
+
a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
103
|
+
that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
|
106
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
107
|
+
notices from the Source form of the Work, excluding those notices that
|
|
108
|
+
do not pertain to any part of the Derivative Works; and
|
|
109
|
+
|
|
110
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
111
|
+
distribution, then any Derivative Works that You distribute must
|
|
112
|
+
include a readable copy of the attribution notices contained
|
|
113
|
+
within such NOTICE file, excluding those notices that do not pertain
|
|
114
|
+
to any part of the Derivative Works, in at least one of the following
|
|
115
|
+
places: within a NOTICE text file distributed as part of the
|
|
116
|
+
Derivative Works; within the Source form or documentation, if
|
|
117
|
+
provided along with the Derivative Works; or, within a display
|
|
118
|
+
generated by the Derivative Works, if and where such third-party
|
|
119
|
+
notices normally appear. The contents of the NOTICE file are
|
|
120
|
+
for informational purposes only and do not modify the License.
|
|
121
|
+
You may add Your own attribution notices within Derivative Works
|
|
122
|
+
that You distribute, alongside or as an addendum to the NOTICE
|
|
123
|
+
text from the Work, provided that such additional attribution
|
|
124
|
+
notices cannot be construed as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and may
|
|
127
|
+
provide additional or different license terms and conditions for use,
|
|
128
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
129
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
130
|
+
distribution of the Work otherwise complies with the conditions stated in
|
|
131
|
+
this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions.
|
|
134
|
+
|
|
135
|
+
Unless You explicitly state otherwise, any Contribution intentionally
|
|
136
|
+
submitted for inclusion in the Work by You to the Licensor shall be
|
|
137
|
+
under the terms and conditions of this License, without any additional
|
|
138
|
+
terms or conditions. Notwithstanding the above, nothing herein shall
|
|
139
|
+
supercede or modify the terms of any separate license agreement you may
|
|
140
|
+
have executed with Licensor regarding such Contributions.
|
|
141
|
+
|
|
142
|
+
6. Trademarks.
|
|
143
|
+
|
|
144
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
145
|
+
service marks, or product names of the Licensor, except as required for
|
|
146
|
+
reasonable and customary use in describing the origin of the Work and
|
|
147
|
+
reproducing the content of the NOTICE file.
|
|
148
|
+
|
|
149
|
+
7. Disclaimer of Warranty.
|
|
150
|
+
|
|
151
|
+
Unless required by applicable law or agreed to in writing, Licensor
|
|
152
|
+
provides the Work (and each Contributor provides its Contributions) on an
|
|
153
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
154
|
+
express or implied, including, without limitation, any warranties or
|
|
155
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
156
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
157
|
+
appropriateness of using or redistributing the Work and assume any
|
|
158
|
+
risks associated with Your exercise of permissions under this License.
|
|
159
|
+
|
|
160
|
+
8. Limitation of Liability.
|
|
161
|
+
|
|
162
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
163
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
164
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
165
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
166
|
+
or consequential damages of any character arising as a result of this License
|
|
167
|
+
or out of the use or inability to use the Work (including but not limited to damages
|
|
168
|
+
for loss of goodwill, work stoppage, computer failure or malfunction, or any
|
|
169
|
+
and all other commercial damages or losses), even if such Contributor has been
|
|
170
|
+
advised of the possibility of such damages.
|
|
171
|
+
|
|
172
|
+
9. Accepting Warranty or Additional Liability.
|
|
173
|
+
|
|
174
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
175
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
176
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
177
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
178
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
179
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
180
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
181
|
+
accepting any such warranty or additional liability.
|
|
182
|
+
|
|
183
|
+
END OF TERMS AND CONDITIONS
|
|
184
|
+
|
|
185
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
186
|
+
|
|
187
|
+
To apply the Apache License to your work, attach the following
|
|
188
|
+
boilerplate notice, with the fields enclosed by brackets "[]" replaced
|
|
189
|
+
with your own identifying information. (Don't include the brackets!)
|
|
190
|
+
The text should be enclosed in the appropriate comment syntax for the file
|
|
191
|
+
format. We also recommend that you include a file named NOTICE within
|
|
192
|
+
the root of your source distribution and modify it to include the Apache
|
|
193
|
+
License text and any other notices that you consider important for your
|
|
194
|
+
work.
|
|
195
|
+
|
|
196
|
+
Copyright [yyyy] [name of copyright owner]
|
|
197
|
+
|
|
198
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
199
|
+
you may not use this file except in compliance with the License.
|
|
200
|
+
You may obtain a copy of the License at
|
|
201
|
+
|
|
202
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
203
|
+
|
|
204
|
+
Unless required by applicable law or agreed to in writing, software
|
|
205
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
206
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
207
|
+
See the License for the specific language governing permissions and
|
|
208
|
+
limitations under the License.
|
pycugrep-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycugrep
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A GPU-accelerated grep tool built with cuDF.
|
|
5
|
+
Home-page: https://github.com/your-repo/pycugrep
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Topic :: Utilities
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: importlib_resources; python_version < "3.9"
|
|
14
|
+
Requires-Dist: rapids-logger
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# PyCuGrep
|
|
26
|
+
|
|
27
|
+
PyCuGrep is a Python package that provides a GPU-accelerated `grep` utility, leveraging the power of NVIDIA GPUs and the cuDF library from RAPIDS. It's designed for rapidly searching large text files or datasets by offloading the pattern matching to the GPU, significantly speeding up operations compared to traditional CPU-based `grep` for suitable workloads.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **GPU Accelerated**: Utilizes cuDF for high-performance string matching on NVIDIA GPUs.
|
|
32
|
+
- **Regex Support**: Supports standard regular expressions for flexible pattern matching.
|
|
33
|
+
- **Case Insensitive Search**: Option to perform case-insensitive searches.
|
|
34
|
+
- **Invert Match**: Find lines that *do not* match the pattern.
|
|
35
|
+
- **Line Numbers**: Display line numbers for matched (or non-matched) lines.
|
|
36
|
+
- **Count Only**: Only output the count of matching lines.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
To install `pycugrep`, you'll need a system with an NVIDIA GPU and CUDA installed. It's recommended to install via pip:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install pycugrep
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
PyCuGrep can be used directly from the command line after installation:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cugrep [OPTIONS] PATTERN FILE...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Example: Basic search**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cugrep "error" /path/to/logfile.txt
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Example: Case-insensitive search across multiple files**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cugrep -i "warning" file1.txt file2.txt
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Example: Count only, inverted match**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cugrep -c -v "success" all_logs.txt
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For more details on available options, run `cugrep --help`.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
For local development, after cloning the repository, navigate to the `python/` directory and install in editable mode:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd cugrep/python
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
PyCuGrep is licensed under the Apache 2.0 License. See the `LICENSE` file for more details.
|
pycugrep-0.1.0/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
# PyCuGrep
|
|
3
|
+
|
|
4
|
+
PyCuGrep is a Python package that provides a GPU-accelerated `grep` utility, leveraging the power of NVIDIA GPUs and the cuDF library from RAPIDS. It's designed for rapidly searching large text files or datasets by offloading the pattern matching to the GPU, significantly speeding up operations compared to traditional CPU-based `grep` for suitable workloads.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **GPU Accelerated**: Utilizes cuDF for high-performance string matching on NVIDIA GPUs.
|
|
9
|
+
- **Regex Support**: Supports standard regular expressions for flexible pattern matching.
|
|
10
|
+
- **Case Insensitive Search**: Option to perform case-insensitive searches.
|
|
11
|
+
- **Invert Match**: Find lines that *do not* match the pattern.
|
|
12
|
+
- **Line Numbers**: Display line numbers for matched (or non-matched) lines.
|
|
13
|
+
- **Count Only**: Only output the count of matching lines.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To install `pycugrep`, you'll need a system with an NVIDIA GPU and CUDA installed. It's recommended to install via pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install pycugrep
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
PyCuGrep can be used directly from the command line after installation:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cugrep [OPTIONS] PATTERN FILE...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Example: Basic search**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cugrep "error" /path/to/logfile.txt
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Example: Case-insensitive search across multiple files**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cugrep -i "warning" file1.txt file2.txt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Example: Count only, inverted match**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cugrep -c -v "success" all_logs.txt
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For more details on available options, run `cugrep --help`.
|
|
50
|
+
|
|
51
|
+
## Development
|
|
52
|
+
|
|
53
|
+
For local development, after cloning the repository, navigate to the `python/` directory and install in editable mode:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cd cugrep/python
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
PyCuGrep is licensed under the Apache 2.0 License. See the `LICENSE` file for more details.
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
import argparse
|
|
3
|
+
import subprocess
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
from importlib.resources import files as importlib_files
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
description="A GPU-accelerated grep tool."
|
|
11
|
+
)
|
|
12
|
+
parser.add_argument("pattern", help="The regex pattern to search for.")
|
|
13
|
+
parser.add_argument("files", nargs='+', help="Files to search in.")
|
|
14
|
+
parser.add_argument("-i", "--ignore-case", action="store_true",
|
|
15
|
+
help="Ignore case distinctions.")
|
|
16
|
+
parser.add_argument("-c", "--count-only", action="store_true",
|
|
17
|
+
help="Count matching lines only.")
|
|
18
|
+
parser.add_argument("-v", "--invert-match", action="store_true",
|
|
19
|
+
help="Invert match (show non-matching lines).")
|
|
20
|
+
parser.add_argument("-n", "--show-line-nums", action="store_true",
|
|
21
|
+
help="Show line numbers (default: on).")
|
|
22
|
+
args = parser.parse_args()
|
|
23
|
+
|
|
24
|
+
# Dynamically locate the cugrep binary using importlib.resources
|
|
25
|
+
try:
|
|
26
|
+
cugrep_path_obj = importlib_files('pycugrep').joinpath('bin', 'cugrep')
|
|
27
|
+
cugrep_executable = str(cugrep_path_obj)
|
|
28
|
+
if not os.path.exists(cugrep_executable):
|
|
29
|
+
raise FileNotFoundError(f"cugrep executable not found at {cugrep_executable}")
|
|
30
|
+
except Exception as e:
|
|
31
|
+
print(f"Error locating cugrep executable: {e}", file=sys.stderr)
|
|
32
|
+
print("Please ensure 'pycugrep' is correctly installed and the binary exists.", file=sys.stderr)
|
|
33
|
+
sys.exit(1)
|
|
34
|
+
|
|
35
|
+
cugrep_command = [cugrep_executable]
|
|
36
|
+
if args.ignore_case: cugrep_command.append("-i")
|
|
37
|
+
if args.count_only: cugrep_command.append("-c")
|
|
38
|
+
if args.invert_match: cugrep_command.append("-v")
|
|
39
|
+
if args.show_line_nums: cugrep_command.append("-n") # This is default for cugrep, but good to pass explicitly
|
|
40
|
+
|
|
41
|
+
cugrep_command.append(args.pattern)
|
|
42
|
+
cugrep_command.extend(args.files)
|
|
43
|
+
|
|
44
|
+
# Set LD_LIBRARY_PATH dynamically if it's not already set, or append
|
|
45
|
+
# This assumes libkvikio might be needed at runtime by the C++ executable
|
|
46
|
+
# and its path could be in a specific Python package location.
|
|
47
|
+
# This part might need further refinement based on the exact deployment of libkvikio.
|
|
48
|
+
env = os.environ.copy()
|
|
49
|
+
try:
|
|
50
|
+
kvikio_lib_path_candidate = str(importlib_files('libkvikio').joinpath('lib64'))
|
|
51
|
+
if os.path.exists(kvikio_lib_path_candidate):
|
|
52
|
+
current_ld_library_path = env.get('LD_LIBRARY_PATH', '')
|
|
53
|
+
if kvikio_lib_path_candidate not in current_ld_library_path:
|
|
54
|
+
env['LD_LIBRARY_PATH'] = f"{kvikio_lib_path_candidate}:{current_ld_library_path}"
|
|
55
|
+
# print(f"cli.py: Set LD_LIBRARY_PATH to: {env['LD_LIBRARY_PATH']}", file=sys.stderr) # Debug print
|
|
56
|
+
except Exception:
|
|
57
|
+
# print(f"cli.py: Warning: libkvikio path could not be determined.", file=sys.stderr) # Debug print
|
|
58
|
+
pass # libkvikio might not be installed, proceed without setting LD_LIBRARY_PATH for it.
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
# print(f"cli.py: Executing C++ cugrep: {cugrep_command}", file=sys.stderr) # Debug print
|
|
62
|
+
result = subprocess.run(cugrep_command, capture_output=True, text=True, check=True, env=env)
|
|
63
|
+
print(result.stdout, end="")
|
|
64
|
+
sys.exit(0) # Explicitly exit 0 on success
|
|
65
|
+
except subprocess.CalledProcessError as e:
|
|
66
|
+
# print(f"cli.py: Caught CalledProcessError. C++ cugrep exit code: {e.returncode}", file=sys.stderr) # Debug print
|
|
67
|
+
print(f"Error executing cugrep: {e}", file=sys.stderr)
|
|
68
|
+
print(e.stderr, file=sys.stderr)
|
|
69
|
+
sys.exit(e.returncode)
|
|
70
|
+
except FileNotFoundError as e:
|
|
71
|
+
print(f"Error: cugrep executable not found or path issue: {e}", file=sys.stderr)
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
main()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycugrep
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A GPU-accelerated grep tool built with cuDF.
|
|
5
|
+
Home-page: https://github.com/your-repo/pycugrep
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Topic :: Utilities
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: importlib_resources; python_version < "3.9"
|
|
14
|
+
Requires-Dist: rapids-logger
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# PyCuGrep
|
|
26
|
+
|
|
27
|
+
PyCuGrep is a Python package that provides a GPU-accelerated `grep` utility, leveraging the power of NVIDIA GPUs and the cuDF library from RAPIDS. It's designed for rapidly searching large text files or datasets by offloading the pattern matching to the GPU, significantly speeding up operations compared to traditional CPU-based `grep` for suitable workloads.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **GPU Accelerated**: Utilizes cuDF for high-performance string matching on NVIDIA GPUs.
|
|
32
|
+
- **Regex Support**: Supports standard regular expressions for flexible pattern matching.
|
|
33
|
+
- **Case Insensitive Search**: Option to perform case-insensitive searches.
|
|
34
|
+
- **Invert Match**: Find lines that *do not* match the pattern.
|
|
35
|
+
- **Line Numbers**: Display line numbers for matched (or non-matched) lines.
|
|
36
|
+
- **Count Only**: Only output the count of matching lines.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
To install `pycugrep`, you'll need a system with an NVIDIA GPU and CUDA installed. It's recommended to install via pip:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install pycugrep
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
PyCuGrep can be used directly from the command line after installation:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cugrep [OPTIONS] PATTERN FILE...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Example: Basic search**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cugrep "error" /path/to/logfile.txt
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Example: Case-insensitive search across multiple files**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cugrep -i "warning" file1.txt file2.txt
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Example: Count only, inverted match**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cugrep -c -v "success" all_logs.txt
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For more details on available options, run `cugrep --help`.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
For local development, after cloning the repository, navigate to the `python/` directory and install in editable mode:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd cugrep/python
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
PyCuGrep is licensed under the Apache 2.0 License. See the `LICENSE` file for more details.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
pycugrep/__init__.py
|
|
6
|
+
pycugrep/cli.py
|
|
7
|
+
pycugrep.egg-info/PKG-INFO
|
|
8
|
+
pycugrep.egg-info/SOURCES.txt
|
|
9
|
+
pycugrep.egg-info/dependency_links.txt
|
|
10
|
+
pycugrep.egg-info/entry_points.txt
|
|
11
|
+
pycugrep.egg-info/not-zip-safe
|
|
12
|
+
pycugrep.egg-info/requires.txt
|
|
13
|
+
pycugrep.egg-info/top_level.txt
|
|
14
|
+
pycugrep/bin/cugrep
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pycugrep
|
pycugrep-0.1.0/setup.cfg
ADDED
pycugrep-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
import os # Added import os
|
|
4
|
+
|
|
5
|
+
setup(
|
|
6
|
+
name='pycugrep',
|
|
7
|
+
version='0.1.0',
|
|
8
|
+
packages=['pycugrep'],
|
|
9
|
+
package_dir={'pycugrep': 'pycugrep'},
|
|
10
|
+
entry_points={
|
|
11
|
+
'console_scripts': [
|
|
12
|
+
'cugrep = pycugrep.cli:main',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
package_data={
|
|
16
|
+
'pycugrep': ['bin/cugrep'],
|
|
17
|
+
},
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
zip_safe=False, # Required for packages with binary data
|
|
20
|
+
python_requires='>=3.8',
|
|
21
|
+
install_requires=[
|
|
22
|
+
'importlib_resources; python_version<"3.9"',
|
|
23
|
+
'rapids-logger'
|
|
24
|
+
],
|
|
25
|
+
description='A GPU-accelerated grep tool built with cuDF.',
|
|
26
|
+
long_description=open('README.md').read() if os.path.exists('README.md') else '',
|
|
27
|
+
long_description_content_type='text/markdown',
|
|
28
|
+
url='https://github.com/your-repo/pycugrep', # Replace with your project URL
|
|
29
|
+
classifiers=[
|
|
30
|
+
'Programming Language :: Python :: 3',
|
|
31
|
+
'License :: OSI Approved :: Apache Software License',
|
|
32
|
+
'Operating System :: POSIX :: Linux',
|
|
33
|
+
'Topic :: Utilities',
|
|
34
|
+
],
|
|
35
|
+
)
|