pycrosscheck 1.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.
- pycrosscheck-1.0.0/LICENSE +24 -0
- pycrosscheck-1.0.0/MANIFEST.in +20 -0
- pycrosscheck-1.0.0/PKG-INFO +333 -0
- pycrosscheck-1.0.0/README.md +290 -0
- pycrosscheck-1.0.0/compatibility_rules/__init__.py +156 -0
- pycrosscheck-1.0.0/compatibility_rules/advanced_rules.py +644 -0
- pycrosscheck-1.0.0/compatibility_rules/base.py +78 -0
- pycrosscheck-1.0.0/compatibility_rules/device_ops.py +46 -0
- pycrosscheck-1.0.0/compatibility_rules/encoding_and_io.py +237 -0
- pycrosscheck-1.0.0/compatibility_rules/file_system.py +117 -0
- pycrosscheck-1.0.0/compatibility_rules/ipc.py +37 -0
- pycrosscheck-1.0.0/compatibility_rules/library_dependencies.py +148 -0
- pycrosscheck-1.0.0/compatibility_rules/network_permissions.py +156 -0
- pycrosscheck-1.0.0/compatibility_rules/os_functions.py +109 -0
- pycrosscheck-1.0.0/compatibility_rules/platform_detection.py +121 -0
- pycrosscheck-1.0.0/compatibility_rules/priority.py +37 -0
- pycrosscheck-1.0.0/compatibility_rules/process_management.py +144 -0
- pycrosscheck-1.0.0/compatibility_rules/signals.py +55 -0
- pycrosscheck-1.0.0/compatibility_rules/system_info.py +46 -0
- pycrosscheck-1.0.0/compatibility_rules/terminal.py +19 -0
- pycrosscheck-1.0.0/compatibility_rules/user_management.py +109 -0
- pycrosscheck-1.0.0/my_bandit_plugin/__init__.py +0 -0
- pycrosscheck-1.0.0/my_bandit_plugin/my_bandit_plugin.py +32 -0
- pycrosscheck-1.0.0/platform_compatibility/__init__.py +8 -0
- pycrosscheck-1.0.0/platform_compatibility/main.py +507 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/PKG-INFO +333 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/SOURCES.txt +33 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/dependency_links.txt +1 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/entry_points.txt +6 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/requires.txt +9 -0
- pycrosscheck-1.0.0/pycrosscheck.egg-info/top_level.txt +3 -0
- pycrosscheck-1.0.0/pyproject.toml +86 -0
- pycrosscheck-1.0.0/requirements.txt +13 -0
- pycrosscheck-1.0.0/setup.cfg +4 -0
- pycrosscheck-1.0.0/setup.py +38 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Software Analysis and Testing (SWAT) Research Group at NCSU
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Include documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include requirements.txt
|
|
5
|
+
|
|
6
|
+
# Include all Python packages
|
|
7
|
+
recursive-include compatibility_rules *.py
|
|
8
|
+
recursive-include my_bandit_plugin *.py
|
|
9
|
+
recursive-include platform_compatibility *.py
|
|
10
|
+
|
|
11
|
+
# Exclude unnecessary files
|
|
12
|
+
global-exclude *.pyc
|
|
13
|
+
global-exclude __pycache__
|
|
14
|
+
global-exclude *.so
|
|
15
|
+
global-exclude .DS_Store
|
|
16
|
+
exclude .gitignore
|
|
17
|
+
recursive-exclude tests *
|
|
18
|
+
recursive-exclude env *
|
|
19
|
+
recursive-exclude real_cases *
|
|
20
|
+
recursive-exclude ruff_fixer *
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycrosscheck
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A cross-platform compatibility checker for Python code - detects Windows/Linux/macOS incompatibilities
|
|
5
|
+
Author: Platform Compatibility Team
|
|
6
|
+
Author-email: Denini Gabriel <denini.gabriel@gmail.com>
|
|
7
|
+
Maintainer-email: Denini Gabriel <denini.gabriel@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/denini08/pycrosscheck
|
|
10
|
+
Project-URL: Bug Reports, https://github.com/denini08/pycrosscheck/issues
|
|
11
|
+
Project-URL: Source, https://github.com/denini08/pycrosscheck
|
|
12
|
+
Project-URL: Documentation, https://github.com/denini08/pycrosscheck#readme
|
|
13
|
+
Keywords: compatibility,cross-platform,windows,linux,macos,static-analysis,linting,code-quality
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
27
|
+
Classifier: Topic :: Software Development :: Testing
|
|
28
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
|
+
Requires-Python: >=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: bandit>=1.7.0
|
|
33
|
+
Requires-Dist: astor>=0.8.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
Dynamic: requires-python
|
|
43
|
+
|
|
44
|
+
# PyCrossCheck
|
|
45
|
+
|
|
46
|
+
🔍 **A cross-platform compatibility checker for Python code**
|
|
47
|
+
|
|
48
|
+
PyCrossCheck automatically detects platform-specific code that may cause issues on Windows, Linux, or macOS, and provides intelligent suggestions for cross-platform alternatives.
|
|
49
|
+
|
|
50
|
+
## 🚀 Features
|
|
51
|
+
|
|
52
|
+
- **Cross-Platform Detection**: Identifies Windows, Linux, and macOS-specific code that may break on other platforms
|
|
53
|
+
- **Smart Suggestions**: Provides clear, actionable recommendations with cross-platform alternatives
|
|
54
|
+
- **Comprehensive Analysis**: 56+ rules organized in 10 categories covering file system, process management, user operations, and more
|
|
55
|
+
- **Easy Integration**: Simple CLI interface and JSON output for CI/CD pipelines
|
|
56
|
+
- **Bandit Plugin**: Extends Bandit static analysis with platform compatibility checks
|
|
57
|
+
|
|
58
|
+
## 📦 Installation
|
|
59
|
+
|
|
60
|
+
### From PyPI (Recommended)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install pycrosscheck
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### From Source
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Clone the repository
|
|
70
|
+
git clone https://github.com/yourusername/pycrosscheck.git
|
|
71
|
+
cd pycrosscheck
|
|
72
|
+
|
|
73
|
+
# Install in development mode
|
|
74
|
+
pip install -e .
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 🛠️ Quick Start
|
|
78
|
+
|
|
79
|
+
### Basic Usage
|
|
80
|
+
|
|
81
|
+
After installation, you can use the `pycrosscheck` or `pycc` command:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Check a single file
|
|
85
|
+
pycrosscheck detect myfile.py
|
|
86
|
+
|
|
87
|
+
# Check an entire project recursively
|
|
88
|
+
pycrosscheck detect -r myproject/
|
|
89
|
+
|
|
90
|
+
# Check with different output formats
|
|
91
|
+
pycrosscheck detect --format json myfile.py
|
|
92
|
+
pycrosscheck detect --format csv myfile.py
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### View All Rules
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Display all available compatibility rules
|
|
99
|
+
pycrosscheck rules
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 📖 Usage Examples
|
|
103
|
+
|
|
104
|
+
### Example 1: Check a Python File
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pycrosscheck detect script.py
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Sample output:**
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
🔍 Detecting Windows compatibility issues...
|
|
114
|
+
💡 This tool will provide suggestions for cross-platform alternatives.
|
|
115
|
+
|
|
116
|
+
Test results:
|
|
117
|
+
>> Issue: [PTB001:os_windows_incompatible_functions] Windows-incompatible function: os.getuid()
|
|
118
|
+
Severity: Medium Confidence: High
|
|
119
|
+
Location: script.py:15
|
|
120
|
+
More Info: https://bandit.readthedocs.io/en/latest/
|
|
121
|
+
💡 Suggestion: Replace with getpass.getuser() - Works on Windows, Linux, and macOS.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Example 2: Check Entire Project
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pycc detect -r ./myproject
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Example 3: CI/CD Integration
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Generate JSON report for automated processing
|
|
134
|
+
pycrosscheck detect -r . --format json > compatibility_report.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Example 4: Using with Bandit Directly
|
|
138
|
+
|
|
139
|
+
Since PyCrossCheck is a Bandit plugin, you can also use it with Bandit:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
bandit -r myproject/ -t PTB001
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 📋 Compatibility Rules Categories
|
|
146
|
+
|
|
147
|
+
PyCrossCheck includes 56+ rules organized into 10 categories:
|
|
148
|
+
|
|
149
|
+
| Category | Description | Rules |
|
|
150
|
+
| -------- | --------------------------- | -------- |
|
|
151
|
+
| **02** | Process Management | 14 rules |
|
|
152
|
+
| **03** | User and Group Management | 11 rules |
|
|
153
|
+
| **04** | File System Operations | 11 rules |
|
|
154
|
+
| **05** | Signal Handling | 5 rules |
|
|
155
|
+
| **06** | Inter-Process Communication | 3 rules |
|
|
156
|
+
| **07** | System Information | 4 rules |
|
|
157
|
+
| **08** | Terminal Control | 1 rule |
|
|
158
|
+
| **09** | Device-Specific Operations | 4 rules |
|
|
159
|
+
| **10** | Priority and Scheduling | 3 rules |
|
|
160
|
+
|
|
161
|
+
## 🔍 Examples of Detected Issues
|
|
162
|
+
|
|
163
|
+
### ❌ User Management Functions
|
|
164
|
+
|
|
165
|
+
**Problematic code:**
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import os
|
|
169
|
+
|
|
170
|
+
# Will fail on Windows
|
|
171
|
+
user_id = os.getuid()
|
|
172
|
+
effective_user = os.geteuid()
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**✅ PyCrossCheck suggestion:**
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
💡 Replace with getpass.getuser() - Works on Windows, Linux, and macOS.
|
|
179
|
+
Import: 'import getpass'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Fixed code:**
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
import getpass
|
|
186
|
+
|
|
187
|
+
# Cross-platform solution
|
|
188
|
+
username = getpass.getuser()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### ❌ System Information
|
|
192
|
+
|
|
193
|
+
**Problematic code:**
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
import os
|
|
197
|
+
|
|
198
|
+
# Will fail on Windows
|
|
199
|
+
system_info = os.uname()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**✅ PyCrossCheck suggestion:**
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
💡 Replace with platform.uname() for cross-platform system information.
|
|
206
|
+
Import: 'import platform'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Fixed code:**
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
import platform
|
|
213
|
+
|
|
214
|
+
# Cross-platform solution
|
|
215
|
+
system_info = platform.uname()
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### ❌ Process Management
|
|
219
|
+
|
|
220
|
+
**Problematic code:**
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
import os
|
|
224
|
+
|
|
225
|
+
# Will fail on Windows
|
|
226
|
+
pid = os.fork()
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**✅ PyCrossCheck suggestion:**
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
💡 Replace with multiprocessing.Process() for cross-platform process creation.
|
|
233
|
+
Import: 'from multiprocessing import Process'
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Fixed code:**
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
from multiprocessing import Process
|
|
240
|
+
|
|
241
|
+
def worker():
|
|
242
|
+
# Your code here
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
# Cross-platform solution
|
|
246
|
+
process = Process(target=worker)
|
|
247
|
+
process.start()
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 🚀 Publishing & Distribution
|
|
251
|
+
|
|
252
|
+
### Prepare for PyPI Upload
|
|
253
|
+
|
|
254
|
+
1. **Update version** in `pyproject.toml`
|
|
255
|
+
2. **Build the package:**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
pip install build twine
|
|
259
|
+
python -m build
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
3. **Upload to Test PyPI (optional):**
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
twine upload --repository testpypi dist/*
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
4. **Upload to PyPI:**
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
twine upload dist/*
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 🛡️ CI/CD Integration
|
|
275
|
+
|
|
276
|
+
### GitHub Actions Example
|
|
277
|
+
|
|
278
|
+
```yaml
|
|
279
|
+
name: Compatibility Check
|
|
280
|
+
|
|
281
|
+
on: [push, pull_request]
|
|
282
|
+
|
|
283
|
+
jobs:
|
|
284
|
+
check:
|
|
285
|
+
runs-on: ubuntu-latest
|
|
286
|
+
steps:
|
|
287
|
+
- uses: actions/checkout@v2
|
|
288
|
+
- name: Set up Python
|
|
289
|
+
uses: actions/setup-python@v2
|
|
290
|
+
with:
|
|
291
|
+
python-version: "3.9"
|
|
292
|
+
- name: Install PyCrossCheck
|
|
293
|
+
run: pip install pycrosscheck
|
|
294
|
+
- name: Run compatibility check
|
|
295
|
+
run: pycrosscheck detect -r . --format json
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Pre-commit Hook
|
|
299
|
+
|
|
300
|
+
Add to `.pre-commit-config.yaml`:
|
|
301
|
+
|
|
302
|
+
```yaml
|
|
303
|
+
repos:
|
|
304
|
+
- repo: local
|
|
305
|
+
hooks:
|
|
306
|
+
- id: pycrosscheck
|
|
307
|
+
name: PyCrossCheck
|
|
308
|
+
entry: pycrosscheck detect
|
|
309
|
+
language: system
|
|
310
|
+
types: [python]
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 🤝 Contributing
|
|
314
|
+
|
|
315
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
316
|
+
|
|
317
|
+
## 📄 License
|
|
318
|
+
|
|
319
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
320
|
+
|
|
321
|
+
## 🙏 Acknowledgments
|
|
322
|
+
|
|
323
|
+
- Built on top of [Bandit](https://github.com/PyCQA/bandit) security analysis tool
|
|
324
|
+
- Inspired by the need for better cross-platform Python code
|
|
325
|
+
|
|
326
|
+
## 📞 Support
|
|
327
|
+
|
|
328
|
+
- **Issues**: [GitHub Issues](https://github.com/yourusername/pycrosscheck/issues)
|
|
329
|
+
- **Documentation**: [GitHub README](https://github.com/yourusername/pycrosscheck#readme)
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
Made with ❤️ for the Python community
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# PyCrossCheck
|
|
2
|
+
|
|
3
|
+
🔍 **A cross-platform compatibility checker for Python code**
|
|
4
|
+
|
|
5
|
+
PyCrossCheck automatically detects platform-specific code that may cause issues on Windows, Linux, or macOS, and provides intelligent suggestions for cross-platform alternatives.
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
- **Cross-Platform Detection**: Identifies Windows, Linux, and macOS-specific code that may break on other platforms
|
|
10
|
+
- **Smart Suggestions**: Provides clear, actionable recommendations with cross-platform alternatives
|
|
11
|
+
- **Comprehensive Analysis**: 56+ rules organized in 10 categories covering file system, process management, user operations, and more
|
|
12
|
+
- **Easy Integration**: Simple CLI interface and JSON output for CI/CD pipelines
|
|
13
|
+
- **Bandit Plugin**: Extends Bandit static analysis with platform compatibility checks
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
### From PyPI (Recommended)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install pycrosscheck
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### From Source
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Clone the repository
|
|
27
|
+
git clone https://github.com/yourusername/pycrosscheck.git
|
|
28
|
+
cd pycrosscheck
|
|
29
|
+
|
|
30
|
+
# Install in development mode
|
|
31
|
+
pip install -e .
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🛠️ Quick Start
|
|
35
|
+
|
|
36
|
+
### Basic Usage
|
|
37
|
+
|
|
38
|
+
After installation, you can use the `pycrosscheck` or `pycc` command:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Check a single file
|
|
42
|
+
pycrosscheck detect myfile.py
|
|
43
|
+
|
|
44
|
+
# Check an entire project recursively
|
|
45
|
+
pycrosscheck detect -r myproject/
|
|
46
|
+
|
|
47
|
+
# Check with different output formats
|
|
48
|
+
pycrosscheck detect --format json myfile.py
|
|
49
|
+
pycrosscheck detect --format csv myfile.py
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### View All Rules
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Display all available compatibility rules
|
|
56
|
+
pycrosscheck rules
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 📖 Usage Examples
|
|
60
|
+
|
|
61
|
+
### Example 1: Check a Python File
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pycrosscheck detect script.py
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Sample output:**
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
🔍 Detecting Windows compatibility issues...
|
|
71
|
+
💡 This tool will provide suggestions for cross-platform alternatives.
|
|
72
|
+
|
|
73
|
+
Test results:
|
|
74
|
+
>> Issue: [PTB001:os_windows_incompatible_functions] Windows-incompatible function: os.getuid()
|
|
75
|
+
Severity: Medium Confidence: High
|
|
76
|
+
Location: script.py:15
|
|
77
|
+
More Info: https://bandit.readthedocs.io/en/latest/
|
|
78
|
+
💡 Suggestion: Replace with getpass.getuser() - Works on Windows, Linux, and macOS.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Example 2: Check Entire Project
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pycc detect -r ./myproject
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Example 3: CI/CD Integration
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Generate JSON report for automated processing
|
|
91
|
+
pycrosscheck detect -r . --format json > compatibility_report.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Example 4: Using with Bandit Directly
|
|
95
|
+
|
|
96
|
+
Since PyCrossCheck is a Bandit plugin, you can also use it with Bandit:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bandit -r myproject/ -t PTB001
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 📋 Compatibility Rules Categories
|
|
103
|
+
|
|
104
|
+
PyCrossCheck includes 56+ rules organized into 10 categories:
|
|
105
|
+
|
|
106
|
+
| Category | Description | Rules |
|
|
107
|
+
| -------- | --------------------------- | -------- |
|
|
108
|
+
| **02** | Process Management | 14 rules |
|
|
109
|
+
| **03** | User and Group Management | 11 rules |
|
|
110
|
+
| **04** | File System Operations | 11 rules |
|
|
111
|
+
| **05** | Signal Handling | 5 rules |
|
|
112
|
+
| **06** | Inter-Process Communication | 3 rules |
|
|
113
|
+
| **07** | System Information | 4 rules |
|
|
114
|
+
| **08** | Terminal Control | 1 rule |
|
|
115
|
+
| **09** | Device-Specific Operations | 4 rules |
|
|
116
|
+
| **10** | Priority and Scheduling | 3 rules |
|
|
117
|
+
|
|
118
|
+
## 🔍 Examples of Detected Issues
|
|
119
|
+
|
|
120
|
+
### ❌ User Management Functions
|
|
121
|
+
|
|
122
|
+
**Problematic code:**
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
import os
|
|
126
|
+
|
|
127
|
+
# Will fail on Windows
|
|
128
|
+
user_id = os.getuid()
|
|
129
|
+
effective_user = os.geteuid()
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**✅ PyCrossCheck suggestion:**
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
💡 Replace with getpass.getuser() - Works on Windows, Linux, and macOS.
|
|
136
|
+
Import: 'import getpass'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Fixed code:**
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import getpass
|
|
143
|
+
|
|
144
|
+
# Cross-platform solution
|
|
145
|
+
username = getpass.getuser()
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### ❌ System Information
|
|
149
|
+
|
|
150
|
+
**Problematic code:**
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import os
|
|
154
|
+
|
|
155
|
+
# Will fail on Windows
|
|
156
|
+
system_info = os.uname()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**✅ PyCrossCheck suggestion:**
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
💡 Replace with platform.uname() for cross-platform system information.
|
|
163
|
+
Import: 'import platform'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Fixed code:**
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
import platform
|
|
170
|
+
|
|
171
|
+
# Cross-platform solution
|
|
172
|
+
system_info = platform.uname()
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### ❌ Process Management
|
|
176
|
+
|
|
177
|
+
**Problematic code:**
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
import os
|
|
181
|
+
|
|
182
|
+
# Will fail on Windows
|
|
183
|
+
pid = os.fork()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**✅ PyCrossCheck suggestion:**
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
💡 Replace with multiprocessing.Process() for cross-platform process creation.
|
|
190
|
+
Import: 'from multiprocessing import Process'
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Fixed code:**
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from multiprocessing import Process
|
|
197
|
+
|
|
198
|
+
def worker():
|
|
199
|
+
# Your code here
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
# Cross-platform solution
|
|
203
|
+
process = Process(target=worker)
|
|
204
|
+
process.start()
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 🚀 Publishing & Distribution
|
|
208
|
+
|
|
209
|
+
### Prepare for PyPI Upload
|
|
210
|
+
|
|
211
|
+
1. **Update version** in `pyproject.toml`
|
|
212
|
+
2. **Build the package:**
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install build twine
|
|
216
|
+
python -m build
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
3. **Upload to Test PyPI (optional):**
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
twine upload --repository testpypi dist/*
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
4. **Upload to PyPI:**
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
twine upload dist/*
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## 🛡️ CI/CD Integration
|
|
232
|
+
|
|
233
|
+
### GitHub Actions Example
|
|
234
|
+
|
|
235
|
+
```yaml
|
|
236
|
+
name: Compatibility Check
|
|
237
|
+
|
|
238
|
+
on: [push, pull_request]
|
|
239
|
+
|
|
240
|
+
jobs:
|
|
241
|
+
check:
|
|
242
|
+
runs-on: ubuntu-latest
|
|
243
|
+
steps:
|
|
244
|
+
- uses: actions/checkout@v2
|
|
245
|
+
- name: Set up Python
|
|
246
|
+
uses: actions/setup-python@v2
|
|
247
|
+
with:
|
|
248
|
+
python-version: "3.9"
|
|
249
|
+
- name: Install PyCrossCheck
|
|
250
|
+
run: pip install pycrosscheck
|
|
251
|
+
- name: Run compatibility check
|
|
252
|
+
run: pycrosscheck detect -r . --format json
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Pre-commit Hook
|
|
256
|
+
|
|
257
|
+
Add to `.pre-commit-config.yaml`:
|
|
258
|
+
|
|
259
|
+
```yaml
|
|
260
|
+
repos:
|
|
261
|
+
- repo: local
|
|
262
|
+
hooks:
|
|
263
|
+
- id: pycrosscheck
|
|
264
|
+
name: PyCrossCheck
|
|
265
|
+
entry: pycrosscheck detect
|
|
266
|
+
language: system
|
|
267
|
+
types: [python]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 🤝 Contributing
|
|
271
|
+
|
|
272
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
273
|
+
|
|
274
|
+
## 📄 License
|
|
275
|
+
|
|
276
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
277
|
+
|
|
278
|
+
## 🙏 Acknowledgments
|
|
279
|
+
|
|
280
|
+
- Built on top of [Bandit](https://github.com/PyCQA/bandit) security analysis tool
|
|
281
|
+
- Inspired by the need for better cross-platform Python code
|
|
282
|
+
|
|
283
|
+
## 📞 Support
|
|
284
|
+
|
|
285
|
+
- **Issues**: [GitHub Issues](https://github.com/yourusername/pycrosscheck/issues)
|
|
286
|
+
- **Documentation**: [GitHub README](https://github.com/yourusername/pycrosscheck#readme)
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
Made with ❤️ for the Python community
|