scope3track 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.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: scope3track
3
+ Version: 1.0.0
4
+ Summary: Carbon and Scope 3 emissions tracking for SMBs — GHG Protocol compliant calculations, supplier tracking, CSRD-ready reporting
5
+ Home-page: https://github.com/scope3track-py/scope3track
6
+ Author:
7
+ Keywords: scope 3 emissions,carbon tracking python,GHG protocol,CSRD compliance,carbon footprint calculator,scope3 reporting,sustainability reporting,carbon accounting SMB,emission factor calculation,supply chain emissions tracking
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Intended Audience :: Developers
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: pydantic>=2.0
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: keywords
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # scope3track
31
+
32
+ **Carbon and Scope 3 emissions tracking for SMBs and enterprise supply chains** — GHG Protocol-compliant calculations, supplier-level tracking, CSRD-ready reporting.
33
+
34
+ Enterprise carbon tools cost $30K–$150K/year. `scope3track` brings the same capability to Python developers for free.
35
+
36
+ [![PyPI version](https://badge.fury.io/py/scope3track.svg)](https://pypi.org/project/scope3track/)
37
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/)
38
+
39
+ ## The Problem
40
+
41
+ EU CSRD enforcement + enterprise Scope 3 requirements are now cascading to SMB suppliers. Companies are required to report their full value-chain emissions. Enterprise tools cost $30K–$150K/year — nothing exists at the $99–$499/mo SMB price point.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install scope3track
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from scope3track import EmissionCalculator, EmissionScope, Scope3Category
53
+ from datetime import datetime
54
+
55
+ calc = EmissionCalculator()
56
+
57
+ # Calculate Scope 3 Category 4: upstream transport
58
+ transport_entry = calc.calculate(
59
+ entry_id="ENT-001",
60
+ scope=EmissionScope.SCOPE3,
61
+ category=Scope3Category.UPSTREAM_TRANSPORT,
62
+ source="Freight — Shanghai to LA",
63
+ activity_amount=5000, # kg of freight
64
+ activity_unit="kg",
65
+ factor_key="km_road_freight_hgv",
66
+ period_start=datetime(2025, 1, 1),
67
+ period_end=datetime(2025, 3, 31),
68
+ supplier_id="SUPPLIER-CN-01",
69
+ )
70
+
71
+ print(f"{transport_entry.emissions_kg_co2e:.2f} kg CO2e")
72
+ ```
73
+
74
+ ## Build a Full Report
75
+
76
+ ```python
77
+ entries = [
78
+ calc.calculate("e1", EmissionScope.SCOPE1, "Natural gas heating", 10000, "kwh", "kwh_natural_gas", period_start=..., period_end=...),
79
+ calc.calculate("e2", EmissionScope.SCOPE2, "Office electricity", 50000, "kwh", "kwh_electricity_us", period_start=..., period_end=...),
80
+ calc.calculate("e3", EmissionScope.SCOPE3, "Employee commuting", 200000, "km", "km_passenger_car", category=Scope3Category.EMPLOYEE_COMMUTING, period_start=..., period_end=...),
81
+ ]
82
+
83
+ report = calc.build_report(
84
+ company_id="ACME-INC",
85
+ reporting_year=2025,
86
+ entries=entries,
87
+ )
88
+
89
+ print(report.summary())
90
+ # {'company_id': 'ACME-INC', 'scope1_t_co2e': 2.02, 'scope2_t_co2e': 19.3, 'scope3_t_co2e': 34.2, 'total_t_co2e': 55.52, ...}
91
+ ```
92
+
93
+ ## Built-in Emission Factors
94
+
95
+ `scope3track` ships with GHG Protocol default factors for:
96
+
97
+ - **Energy**: electricity (US/EU grid), natural gas
98
+ - **Transport**: road freight, air freight, sea freight, passenger car, business flights
99
+ - **Materials**: steel, aluminium, plastic, paper, concrete
100
+ - **Waste**: landfill, recycled, composted
101
+
102
+ Register custom factors:
103
+
104
+ ```python
105
+ from scope3track import default_registry
106
+
107
+ default_registry.register("kwh_solar_ppa", 0.012)
108
+ ```
109
+
110
+ ## Scope 3 Categories Supported
111
+
112
+ All 15 GHG Protocol Scope 3 categories (upstream + downstream):
113
+
114
+ `purchased_goods_services`, `capital_goods`, `fuel_and_energy_activities`, `upstream_transportation_distribution`, `waste_generated_in_operations`, `business_travel`, `employee_commuting`, `upstream_leased_assets`, `downstream_transportation_distribution`, `processing_of_sold_products`, `use_of_sold_products`, `end_of_life_treatment`, `downstream_leased_assets`, `franchises`, `investments`
115
+
116
+ ## Advanced Features
117
+
118
+ ### Pipeline
119
+
120
+ ```python
121
+ from scope3track import EmissionPipeline
122
+
123
+ pipeline = (
124
+ EmissionPipeline()
125
+ .filter(lambda e: e.scope == EmissionScope.SCOPE3, name="scope3_only")
126
+ .map(lambda entries: sorted(entries, key=lambda e: -e.emissions_kg_co2e), name="sort_by_impact")
127
+ .with_retry(count=2)
128
+ )
129
+
130
+ scope3_sorted = pipeline.run(entries)
131
+ ```
132
+
133
+ ### Caching
134
+
135
+ ```python
136
+ from scope3track import EmissionCache
137
+
138
+ cache = EmissionCache(max_size=1000, ttl_seconds=3600)
139
+
140
+ @cache.memoize
141
+ def get_supplier_emissions(supplier_id):
142
+ ...
143
+
144
+ cache.save("emissions_cache.pkl")
145
+ cache.load("emissions_cache.pkl")
146
+ print(cache.stats())
147
+ ```
148
+
149
+ ### Export Reports
150
+
151
+ ```python
152
+ from scope3track import EmissionReportExporter
153
+
154
+ print(EmissionReportExporter.to_json(report))
155
+ print(EmissionReportExporter.to_csv(report))
156
+ print(EmissionReportExporter.to_markdown(report))
157
+ ```
158
+
159
+ ### Drift Detection
160
+
161
+ ```python
162
+ from scope3track import EmissionDriftDetector
163
+
164
+ detector = EmissionDriftDetector(threshold=0.15)
165
+ for period_total in quarterly_totals:
166
+ detector.record(period_total)
167
+
168
+ if detector.is_drifted():
169
+ print(f"Emission drift detected: {detector.drift_ratio():.1%}")
170
+ ```
171
+
172
+ ### Diff Between Periods
173
+
174
+ ```python
175
+ from scope3track import diff_entries
176
+
177
+ diff = diff_entries(q1_entries, q2_entries)
178
+ print(diff.summary()) # {'added': 2, 'removed': 0, 'modified': 3}
179
+ print(diff.to_json())
180
+ ```
181
+
182
+ ### Async Batch
183
+
184
+ ```python
185
+ from scope3track import abatch_calculate, CancellationToken
186
+
187
+ token = CancellationToken()
188
+ entries = await abatch_calculate(raw_data, calc_fn, max_concurrency=8, token=token)
189
+ ```
190
+
191
+ ### Streaming NDJSON
192
+
193
+ ```python
194
+ from scope3track import entries_to_ndjson
195
+
196
+ for line in entries_to_ndjson(entries):
197
+ output_stream.write(line)
198
+ ```
199
+
200
+ ## Frameworks Supported
201
+
202
+ - GHG Protocol Corporate Standard
203
+ - EU CSRD / ESRS E1
204
+ - ISO 14064-1
205
+
206
+ ## License
207
+
208
+ MIT
@@ -0,0 +1,179 @@
1
+ # scope3track
2
+
3
+ **Carbon and Scope 3 emissions tracking for SMBs and enterprise supply chains** — GHG Protocol-compliant calculations, supplier-level tracking, CSRD-ready reporting.
4
+
5
+ Enterprise carbon tools cost $30K–$150K/year. `scope3track` brings the same capability to Python developers for free.
6
+
7
+ [![PyPI version](https://badge.fury.io/py/scope3track.svg)](https://pypi.org/project/scope3track/)
8
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/)
9
+
10
+ ## The Problem
11
+
12
+ EU CSRD enforcement + enterprise Scope 3 requirements are now cascading to SMB suppliers. Companies are required to report their full value-chain emissions. Enterprise tools cost $30K–$150K/year — nothing exists at the $99–$499/mo SMB price point.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install scope3track
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```python
23
+ from scope3track import EmissionCalculator, EmissionScope, Scope3Category
24
+ from datetime import datetime
25
+
26
+ calc = EmissionCalculator()
27
+
28
+ # Calculate Scope 3 Category 4: upstream transport
29
+ transport_entry = calc.calculate(
30
+ entry_id="ENT-001",
31
+ scope=EmissionScope.SCOPE3,
32
+ category=Scope3Category.UPSTREAM_TRANSPORT,
33
+ source="Freight — Shanghai to LA",
34
+ activity_amount=5000, # kg of freight
35
+ activity_unit="kg",
36
+ factor_key="km_road_freight_hgv",
37
+ period_start=datetime(2025, 1, 1),
38
+ period_end=datetime(2025, 3, 31),
39
+ supplier_id="SUPPLIER-CN-01",
40
+ )
41
+
42
+ print(f"{transport_entry.emissions_kg_co2e:.2f} kg CO2e")
43
+ ```
44
+
45
+ ## Build a Full Report
46
+
47
+ ```python
48
+ entries = [
49
+ calc.calculate("e1", EmissionScope.SCOPE1, "Natural gas heating", 10000, "kwh", "kwh_natural_gas", period_start=..., period_end=...),
50
+ calc.calculate("e2", EmissionScope.SCOPE2, "Office electricity", 50000, "kwh", "kwh_electricity_us", period_start=..., period_end=...),
51
+ calc.calculate("e3", EmissionScope.SCOPE3, "Employee commuting", 200000, "km", "km_passenger_car", category=Scope3Category.EMPLOYEE_COMMUTING, period_start=..., period_end=...),
52
+ ]
53
+
54
+ report = calc.build_report(
55
+ company_id="ACME-INC",
56
+ reporting_year=2025,
57
+ entries=entries,
58
+ )
59
+
60
+ print(report.summary())
61
+ # {'company_id': 'ACME-INC', 'scope1_t_co2e': 2.02, 'scope2_t_co2e': 19.3, 'scope3_t_co2e': 34.2, 'total_t_co2e': 55.52, ...}
62
+ ```
63
+
64
+ ## Built-in Emission Factors
65
+
66
+ `scope3track` ships with GHG Protocol default factors for:
67
+
68
+ - **Energy**: electricity (US/EU grid), natural gas
69
+ - **Transport**: road freight, air freight, sea freight, passenger car, business flights
70
+ - **Materials**: steel, aluminium, plastic, paper, concrete
71
+ - **Waste**: landfill, recycled, composted
72
+
73
+ Register custom factors:
74
+
75
+ ```python
76
+ from scope3track import default_registry
77
+
78
+ default_registry.register("kwh_solar_ppa", 0.012)
79
+ ```
80
+
81
+ ## Scope 3 Categories Supported
82
+
83
+ All 15 GHG Protocol Scope 3 categories (upstream + downstream):
84
+
85
+ `purchased_goods_services`, `capital_goods`, `fuel_and_energy_activities`, `upstream_transportation_distribution`, `waste_generated_in_operations`, `business_travel`, `employee_commuting`, `upstream_leased_assets`, `downstream_transportation_distribution`, `processing_of_sold_products`, `use_of_sold_products`, `end_of_life_treatment`, `downstream_leased_assets`, `franchises`, `investments`
86
+
87
+ ## Advanced Features
88
+
89
+ ### Pipeline
90
+
91
+ ```python
92
+ from scope3track import EmissionPipeline
93
+
94
+ pipeline = (
95
+ EmissionPipeline()
96
+ .filter(lambda e: e.scope == EmissionScope.SCOPE3, name="scope3_only")
97
+ .map(lambda entries: sorted(entries, key=lambda e: -e.emissions_kg_co2e), name="sort_by_impact")
98
+ .with_retry(count=2)
99
+ )
100
+
101
+ scope3_sorted = pipeline.run(entries)
102
+ ```
103
+
104
+ ### Caching
105
+
106
+ ```python
107
+ from scope3track import EmissionCache
108
+
109
+ cache = EmissionCache(max_size=1000, ttl_seconds=3600)
110
+
111
+ @cache.memoize
112
+ def get_supplier_emissions(supplier_id):
113
+ ...
114
+
115
+ cache.save("emissions_cache.pkl")
116
+ cache.load("emissions_cache.pkl")
117
+ print(cache.stats())
118
+ ```
119
+
120
+ ### Export Reports
121
+
122
+ ```python
123
+ from scope3track import EmissionReportExporter
124
+
125
+ print(EmissionReportExporter.to_json(report))
126
+ print(EmissionReportExporter.to_csv(report))
127
+ print(EmissionReportExporter.to_markdown(report))
128
+ ```
129
+
130
+ ### Drift Detection
131
+
132
+ ```python
133
+ from scope3track import EmissionDriftDetector
134
+
135
+ detector = EmissionDriftDetector(threshold=0.15)
136
+ for period_total in quarterly_totals:
137
+ detector.record(period_total)
138
+
139
+ if detector.is_drifted():
140
+ print(f"Emission drift detected: {detector.drift_ratio():.1%}")
141
+ ```
142
+
143
+ ### Diff Between Periods
144
+
145
+ ```python
146
+ from scope3track import diff_entries
147
+
148
+ diff = diff_entries(q1_entries, q2_entries)
149
+ print(diff.summary()) # {'added': 2, 'removed': 0, 'modified': 3}
150
+ print(diff.to_json())
151
+ ```
152
+
153
+ ### Async Batch
154
+
155
+ ```python
156
+ from scope3track import abatch_calculate, CancellationToken
157
+
158
+ token = CancellationToken()
159
+ entries = await abatch_calculate(raw_data, calc_fn, max_concurrency=8, token=token)
160
+ ```
161
+
162
+ ### Streaming NDJSON
163
+
164
+ ```python
165
+ from scope3track import entries_to_ndjson
166
+
167
+ for line in entries_to_ndjson(entries):
168
+ output_stream.write(line)
169
+ ```
170
+
171
+ ## Frameworks Supported
172
+
173
+ - GHG Protocol Corporate Standard
174
+ - EU CSRD / ESRS E1
175
+ - ISO 14064-1
176
+
177
+ ## License
178
+
179
+ MIT
@@ -0,0 +1,76 @@
1
+ """scope3track — Carbon and Scope 3 emissions tracking for SMBs and enterprise supply chains."""
2
+ from scope3track.models import (
3
+ EmissionEntry,
4
+ EmissionReport,
5
+ EmissionScope,
6
+ EmissionUnit,
7
+ Scope3Category,
8
+ SupplierEmissions,
9
+ )
10
+ from scope3track.calculator import (
11
+ EmissionCalculator,
12
+ EmissionFactorRegistry,
13
+ default_registry,
14
+ )
15
+ from scope3track.exceptions import (
16
+ CalculationError,
17
+ ReportError,
18
+ Scope3TrackError,
19
+ ValidationError,
20
+ )
21
+ from scope3track.advanced import (
22
+ AuditLog,
23
+ CancellationToken,
24
+ EmissionCache,
25
+ EmissionDiff,
26
+ EmissionDriftDetector,
27
+ EmissionPipeline,
28
+ EmissionProfiler,
29
+ EmissionReportExporter,
30
+ EmissionRule,
31
+ EmissionValidator,
32
+ PIIScrubber,
33
+ RateLimiter,
34
+ abatch_calculate,
35
+ batch_calculate,
36
+ diff_entries,
37
+ entries_to_ndjson,
38
+ stream_entries,
39
+ )
40
+
41
+ __version__ = "1.0.0"
42
+ __all__ = [
43
+ # Core
44
+ "EmissionCalculator",
45
+ "EmissionFactorRegistry",
46
+ "default_registry",
47
+ "EmissionEntry",
48
+ "EmissionReport",
49
+ "EmissionScope",
50
+ "EmissionUnit",
51
+ "Scope3Category",
52
+ "SupplierEmissions",
53
+ # Exceptions
54
+ "Scope3TrackError",
55
+ "CalculationError",
56
+ "ValidationError",
57
+ "ReportError",
58
+ # Advanced
59
+ "EmissionCache",
60
+ "EmissionPipeline",
61
+ "EmissionValidator",
62
+ "EmissionRule",
63
+ "RateLimiter",
64
+ "CancellationToken",
65
+ "batch_calculate",
66
+ "abatch_calculate",
67
+ "EmissionProfiler",
68
+ "EmissionDriftDetector",
69
+ "EmissionReportExporter",
70
+ "stream_entries",
71
+ "entries_to_ndjson",
72
+ "EmissionDiff",
73
+ "diff_entries",
74
+ "AuditLog",
75
+ "PIIScrubber",
76
+ ]