src2purl 1.3.2__py3-none-any.whl

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.
@@ -0,0 +1,279 @@
1
+ Metadata-Version: 2.4
2
+ Name: src2purl
3
+ Version: 1.3.2
4
+ Summary: Source to PURL - Identify package coordinates and PURLs from source code using UPMEX and multiple discovery strategies
5
+ Author-email: "Oscar Valenzuela B." <oscar.valenzuela.b@gmail.com>
6
+ License: AGPL-3.0
7
+ Project-URL: Homepage, https://github.com/oscarvalenzuelab/src2purl
8
+ Project-URL: Bug Tracker, https://github.com/oscarvalenzuelab/src2purl/issues
9
+ Project-URL: Source Code, https://github.com/oscarvalenzuelab/src2purl
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Software Development :: Version Control
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: aiohttp>=3.9.0
24
+ Requires-Dist: click>=8.1.0
25
+ Requires-Dist: rich>=13.0.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: tabulate>=0.9.0
28
+ Requires-Dist: upmex>=1.6.7
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
31
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
33
+ Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
34
+ Requires-Dist: black>=23.0.0; extra == "dev"
35
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.5.0; extra == "dev"
37
+ Requires-Dist: pre-commit>=3.4.0; extra == "dev"
38
+ Provides-Extra: swhid
39
+ Requires-Dist: miniswhid>=0.1.0; extra == "swhid"
40
+ Requires-Dist: swh.model>=6.0.0; extra == "swhid"
41
+ Requires-Dist: swh.web>=1.0.0; extra == "swhid"
42
+ Provides-Extra: enhanced
43
+ Requires-Dist: semantic-copycat-oslili>=1.3.3; extra == "enhanced"
44
+ Dynamic: license-file
45
+
46
+ # SRC2PURL - Source Code to Package URL
47
+
48
+ A Python tool that identifies package coordinates (name, version, license, PURL) from source code directories using an hybrid discovery strategy with manifest parsing, code fingerprinting, repository search, and Software Heritage archive.
49
+
50
+ ## Overview
51
+
52
+ src2purl uses a **progressive 2-phase discovery strategy** to identify packages:
53
+
54
+ ### **Phase 1: Hash-based Package Discovery** (5-15 seconds)
55
+ **Primary identification using content fingerprinting and repository search:**
56
+
57
+ 1. **Directory & Content Scanning** - Generate SWHIDs for directories and files
58
+ - ✅ **Complete file tree analysis** with configurable depth
59
+ - ✅ **SWHID generation** for precise content identification
60
+ - ✅ **Smart filtering** of binary files and hidden directories
61
+
62
+ 2. **Software Heritage Archive** (Optional) - Deep provenance discovery
63
+ - ✅ **Most comprehensive** - finds exact source code matches
64
+ - ✅ **Historical accuracy** - can identify older versions
65
+ - ⚠️ **Requires opt-in** with `--use-swh` due to longer processing time
66
+
67
+ 3. **Keyword Search** (Fallback) - Multi-platform repository discovery
68
+ - **GitHub API Search** - Repository identification by keywords
69
+ - **SCANOSS Fingerprinting** - Code similarity detection via file fingerprints
70
+ - ✅ **Universal coverage** - finds repositories for any project
71
+ - ✅ **Fast execution** (~10 seconds total)
72
+
73
+ ### **Phase 2: Manifest-based Validation & Enhancement** (1-3 seconds)
74
+ **Authoritative package metadata extraction and result enhancement:**
75
+
76
+ 4. **UPMEX Manifest Parsing** - Universal Package Metadata Extractor
77
+ - ✅ **Perfect metadata extraction** from package files (package.json, setup.py, pom.xml, go.mod, Cargo.toml, etc.)
78
+ - ✅ **Multi-ecosystem support** (PyPI, NPM, Maven, Go, Ruby Gems, PHP, .NET)
79
+ - ✅ **Complete package info** (name, version, license, PURL)
80
+ - ✅ **Cross-validation** with Phase 1 results for enhanced accuracy
81
+
82
+ ## Features
83
+
84
+ ### **Core Capabilities**
85
+ - **2-Phase Discovery Strategy**: Hash-based identification enhanced by manifest parsing
86
+ - **Multi-Ecosystem Support**: PyPI, NPM, Maven, Go, Ruby Gems, PHP, .NET, and more
87
+ - **Cross-Phase Validation**: UPMEX manifest data validates and enhances hash-based findings
88
+ - **Confidence Scoring**: Multi-factor scoring (85-100% for exact matches)
89
+ - **Package Coordinate Extraction**: Complete metadata (name, version, license, PURL)
90
+
91
+ ### **Performance & Reliability**
92
+ - **Fast by Default**: 5-15 seconds for typical projects (vs 90+ seconds with SWH)
93
+ - **No API Keys Required**: Works well without authentication (SCANOSS, GitHub search)
94
+ - **Optional API Keys**: Enhanced rate limits and accuracy with GitHub/SCANOSS tokens
95
+ - **Persistent Caching**: File-based cache with smart TTL to avoid API rate limits
96
+ - **Rate Limit Handling**: Automatic backoff and retry logic
97
+
98
+ ### **Discovery Methods**
99
+ - **UPMEX Manifest Parsing**: Universal Package Metadata Extractor for all major package ecosystems
100
+ - **SCANOSS Fingerprinting**: 100% accuracy code similarity with detailed license detection
101
+ - **GitHub Repository Search**: Universal coverage repository identification
102
+ - **Software Heritage Archive**: Comprehensive source inventory (opt-in with `--use-swh`)
103
+
104
+ ### **Output & Integration**
105
+ - **Multiple Output Formats**: JSON and table output formats
106
+ - **PURL Generation**: Standard Package URLs for identified packages
107
+ - **Enhanced License Detection**: Integration with oslili for improved license detection
108
+ - **Subcomponent Detection**: Identifies multiple packages within monorepos and complex projects
109
+
110
+ ## Installation
111
+
112
+ ### From Source
113
+
114
+ ```bash
115
+ git clone https://github.com/oscarvalenzuelab/src2purl.git
116
+ cd src2purl
117
+ pip install -e .
118
+ ```
119
+
120
+
121
+ ## Usage
122
+
123
+ ### Basic Usage
124
+
125
+ ```bash
126
+ # Fast discovery (default) - Uses manifest parsing + SCANOSS + GitHub (5-15 seconds)
127
+ src2purl /path/to/source/code
128
+
129
+ # Comprehensive discovery - Includes Software Heritage archive (90+ seconds)
130
+ src2purl /path/to/source --use-swh
131
+
132
+ # High confidence matches only
133
+ src2purl /path/to/source --confidence-threshold 0.85
134
+
135
+ # JSON output format for integration
136
+ src2purl /path/to/source --output-format json
137
+
138
+ # Detect subcomponents in monorepos
139
+ src2purl /path/to/source --detect-subcomponents
140
+
141
+ # Skip license detection (faster)
142
+ src2purl /path/to/source --no-license-detection
143
+
144
+ # Verbose output for debugging
145
+ src2purl /path/to/source --verbose
146
+
147
+ # Clear cache and exit
148
+ src2purl --clear-cache
149
+ ```
150
+
151
+ ### Discovery Strategy Examples
152
+
153
+ ```bash
154
+ # Default: 2-Phase hybrid approach (5-15 seconds)
155
+ # Phase 1: Hash-based discovery + Phase 2: UPMEX manifest parsing
156
+ # Good for: Most use cases, balanced speed and accuracy
157
+ src2purl /path/to/project
158
+
159
+ # Comprehensive: Include Software Heritage archive (90+ seconds)
160
+ # Phase 1 includes deep provenance discovery + Phase 2: UPMEX enhancement
161
+ # Good for: Security audits, research, historical analysis
162
+ export SWH_API_TOKEN=your_token # Optional but recommended
163
+ src2purl /path/to/project --use-swh
164
+
165
+ # High confidence: Only report confident matches
166
+ # Filters results to highest confidence findings from both phases
167
+ src2purl /path/to/project --confidence-threshold 0.85
168
+ ```
169
+
170
+ ### API Authentication
171
+
172
+ **⚠️ No API keys required!** The tool works with the free public APIs. API keys only provide enhanced rate limits and additional features.
173
+
174
+ #### Recommended API Keys (Optional)
175
+
176
+ **1. GitHub API** - **Most Valuable** (Free, 2 minutes to setup)
177
+ ```bash
178
+ export GITHUB_TOKEN=your_github_personal_access_token
179
+ ```
180
+ - **Get token**: https://github.com/settings/tokens (no special permissions needed)
181
+ - **Benefits**:
182
+ - ✅ **Rate limit**: 10 → 5000 requests/hour
183
+ - ✅ **Better search**: More accurate repository identification
184
+ - ✅ **No cost**: Completely free
185
+ - **Impact**: Significant improvement for repository discovery
186
+
187
+ **2. SCANOSS API** - **Nice to Have** (Free, optional)
188
+ ```bash
189
+ export SCANOSS_API_KEY=your_scanoss_key
190
+ ```
191
+ - **Get token**: Register at https://www.scanoss.com
192
+ - **Benefits**:
193
+ - ✅ **No cost**: Free tier available
194
+ - ✅ **Enhanced rate limits**: Premium API endpoint
195
+ - ✅ **Additional features**: Possible extra metadata
196
+ - **Impact**: Minor improvement (SCANOSS works great without key)
197
+
198
+ **3. Software Heritage API** - **For Heavy Usage** (Free, only if using `--use-swh`)
199
+ ```bash
200
+ export SWH_API_TOKEN=your_swh_token
201
+ ```
202
+ - **Get token**: Register at https://archive.softwareheritage.org/api/
203
+ - **Benefits**:
204
+ - ✅ **Bypass rate limits**: No 60-second waits
205
+ - ✅ **Faster comprehensive scans**: When using `--use-swh`
206
+ - **Impact**: Essential for `--use-swh` flag, not needed for default fast mode
207
+
208
+ #### Performance Comparison
209
+
210
+ | Configuration | Typical Time | API Calls | Best For |
211
+ |---------------|-------------|-----------|----------|
212
+ | **No API keys** | 5-15 seconds | Minimal | Most users |
213
+ | **+ GitHub token** | 5-15 seconds | Enhanced | Recommended setup |
214
+ | **+ All tokens** | 5-15 seconds | Premium | Production use |
215
+ | **+ SWH mode** | 90+ seconds | Heavy | Security audits |
216
+
217
+ **Recommendation**: Start with **GitHub token only** - it's free, fast to setup, and provides the biggest improvement.
218
+
219
+ ### SWHID Validation
220
+
221
+ ```bash
222
+ # Generate and validate SWHID for a directory
223
+ src2purl-validate /path/to/directory
224
+
225
+ # Compare against expected SWHID
226
+ src2purl-validate /path/to/directory --expected-swhid swh:1:dir:abc123...
227
+
228
+ # Use fallback implementation
229
+ src2purl-validate /path/to/directory --use-fallback --verbose
230
+ ```
231
+
232
+ ### Command Line Options
233
+
234
+ #### **Core Options**
235
+ - `path`: Directory path to analyze (required)
236
+ - `--confidence-threshold`: Minimum confidence to report matches (default: 0.3)
237
+ - `--output-format`: Output format: 'json' or 'table' (default: table)
238
+ - `--verbose`: Verbose output for debugging
239
+
240
+ #### **Discovery Control**
241
+ - `--use-swh`: Include Software Heritage archive checking (optional, adds 90+ seconds)
242
+ - `--no-license-detection`: Skip automatic license detection from local source (faster)
243
+ - `--detect-subcomponents`: Detect and identify subcomponents in monorepos
244
+ - `--max-depth`: Maximum directory depth to scan (default: 2)
245
+
246
+ #### **Performance & Caching**
247
+ - `--no-cache`: Disable API response caching
248
+ - `--clear-cache`: Clear all cached API responses and exit
249
+
250
+ #### **Authentication**
251
+ - `--api-token`: Software Heritage API token (only used with --use-swh)
252
+ - Environment variables: `GITHUB_TOKEN`, `SCANOSS_API_KEY`, `SWH_API_TOKEN`
253
+
254
+ #### **Discovery Method Breakdown**
255
+ ```bash
256
+ # Default: 2-Phase Discovery (Hash-based + UPMEX manifest parsing)
257
+ src2purl /path/to/project
258
+
259
+ # Phase 1: SWHID generation → GitHub/SCANOSS search
260
+ # Phase 2: UPMEX manifest extraction → Cross-validation & enhancement
261
+
262
+ # Add Software Heritage for comprehensive provenance discovery
263
+ src2purl /path/to/project --use-swh
264
+
265
+ # Phase 1: SWHID generation → Software Heritage archive → Fallback search
266
+ # Phase 2: UPMEX manifest extraction → Cross-validation & enhancement
267
+
268
+ # Performance optimization options
269
+ src2purl /path/to/project --no-license-detection # Skip license enhancement
270
+ src2purl /path/to/project --use-swh --verbose # Full discovery with details
271
+ ```
272
+
273
+ ## License
274
+
275
+ This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.
276
+
277
+ ## Status
278
+
279
+ This project is currently in active development. See the [Issues](https://github.com/oscarvalenzuelab/src2purl/issues) page for planned features and known issues.
@@ -0,0 +1,33 @@
1
+ src2id/__init__.py,sha256=Lk4-IDpjHo1p9NFwekUINOH1mFawlOODdfNx1mofRJk,430
2
+ src2id/cli/__init__.py,sha256=g0986HeNuuFGC8qpz2RLOaL9CMJtnrQwFAehm5E1jes,38
3
+ src2id/cli/main.py,sha256=hC73YoabVK__v0-6qOsZFXQSlFddmqg2CEPNEZMYMws,10762
4
+ src2id/cli/validate.py,sha256=iH8rQZj0OyJfFhCXeMjUBtzx14RLVH8erVASV7yeOJc,2779
5
+ src2id/core/__init__.py,sha256=XIsMG1hgFhDbpbC2erJE9_yNPw8gTw2K6NAO3rkQf2M,51
6
+ src2id/core/cache.py,sha256=WkFCeWrcnN1rutS6oIdRpiN-zMY7-Bjx84n1V67MXwQ,5663
7
+ src2id/core/client.py,sha256=VBseOsBsupvSXc80zvn3PKuX0bHwfGHWHqyBe6NmD6Y,14306
8
+ src2id/core/config.py,sha256=wlv0Q90OJmn_VsBG6mZvhFat4Wa1ww-tOEVfOURBENo,1501
9
+ src2id/core/extractor.py,sha256=GykVOC4PD1qFJKIs6R7YHCLkfNw7k8y7RUd_tTaxsR0,10626
10
+ src2id/core/models.py,sha256=0u6obkTJg5SSmyewYwNj6KlYkZMBHpaeOouxWjI-OtY,2260
11
+ src2id/core/orchestrator.py,sha256=3Sf8fWMPd2kGXnGzQHIWeHZKpphXbMTq9tIm3zA00Nk,35803
12
+ src2id/core/package_identifier.py,sha256=-rjRl8xDpDAMLyYdZKXKjGaWIOKrRT_d_qIQRNzNNgY,5165
13
+ src2id/core/purl.py,sha256=wJKOSgOhMyAUUuC-rstULNJud76dlKOLNHYmipbKPx4,8572
14
+ src2id/core/scanner.py,sha256=8KtfRH4Wn5tLw4bhhvpn0nh5Hkm2WwK-i1EeSol_8zc,13214
15
+ src2id/core/scorer.py,sha256=JDoLnr9ekQ-udot_ElHLYYp0IuqgNOwvbiIPtss4Bl4,6536
16
+ src2id/core/subcomponent_detector.py,sha256=-fRn8IDUJgnuo5LtblHOr6aTGM5TrPqzN67KfhczpZM,11790
17
+ src2id/core/swhid.py,sha256=0mH4N6Egz8xSNkpDJb7zzeKNh5CGxFc4mpCi0aQoJm0,10655
18
+ src2id/integrations/__init__.py,sha256=uWB0Yt4jEMvb7AfSnukmfHtof1It87mhQAFPFsJz3_M,38
19
+ src2id/integrations/manifest_parser.py,sha256=k-A9GHb9A-bVWH6F378J1BJTdkzPyHxzcltwOS-2AnE,24456
20
+ src2id/integrations/oslili.py,sha256=PfI2m3Fki7hx9lT_efTUtQdYI5bqOOlwbyNMdw825L4,8699
21
+ src2id/integrations/upmex.py,sha256=KTAs23tVaONL-_8-wN7HgywOdsxiLhPFqun0XeQ9fCU,10568
22
+ src2id/search/__init__.py,sha256=aLYwN91rPT0mamAfDPAxe-pQPED65laH_XdYJKp3wLs,679
23
+ src2id/search/hash_search.py,sha256=21-JN9Of6jW17bHgGE8OMzcX5E0oNCDvewtKjvnbQEw,6828
24
+ src2id/search/providers.py,sha256=ByMfzLQafOdw9YIMvjZDVNfHh1YWXx4SqPZMyp921hY,10307
25
+ src2id/search/strategies.py,sha256=tjC8hTvcVhCa_T_0vK4KcnSQ57rdw7pktZp1YLz9hDs,14630
26
+ src2id/utils/__init__.py,sha256=6NJk-vSc2VWBeyA9vWgAcxK9MYfW7lg7Pn2oB9px3bQ,34
27
+ src2id/utils/datetime_utils.py,sha256=QuRYPwQ8IthRuLh9tVW_GTDH0Yz_beTQdLN-hMaPkcc,1219
28
+ src2purl-1.3.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
29
+ src2purl-1.3.2.dist-info/METADATA,sha256=e1L3fFHcvcMsoPsGkS0OeOIP-rckD5tgFcg75uEz8ys,11397
30
+ src2purl-1.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ src2purl-1.3.2.dist-info/entry_points.txt,sha256=CY5y8YJhEGb3gbYDZH16NQw3uStpqAhbJtfzLCjqOVs,105
32
+ src2purl-1.3.2.dist-info/top_level.txt,sha256=suxCFOWz7p9RHoRT4cXO8YiH_Ylx6_ol_cg1TdEHb-w,7
33
+ src2purl-1.3.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ src2purl = src2id.cli.main:main
3
+ src2purl-validate = src2id.cli.validate:validate_swhid