pyforker 2.1.0__tar.gz → 2.3.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.
- {pyforker-2.1.0 → pyforker-2.3.0}/PKG-INFO +59 -43
- pyforker-2.3.0/README.md +128 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.egg-info/PKG-INFO +59 -43
- {pyforker-2.1.0 → pyforker-2.3.0}/pyproject.toml +1 -1
- {pyforker-2.1.0 → pyforker-2.3.0}/setup.py +1 -1
- pyforker-2.1.0/README.md +0 -112
- {pyforker-2.1.0 → pyforker-2.3.0}/LICENSE.md +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.egg-info/SOURCES.txt +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.egg-info/dependency_links.txt +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.egg-info/entry_points.txt +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.egg-info/top_level.txt +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/pyforker.py +0 -0
- {pyforker-2.1.0 → pyforker-2.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyforker
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Zero-dependency toolkit for selectively extracting sub-modules, inspecting ASTs, and operating remote library mirror servers.
|
|
5
5
|
Author: Sundaram Gupta
|
|
6
6
|
License: MIT
|
|
@@ -24,13 +24,10 @@ Dynamic: requires-python
|
|
|
24
24
|
|
|
25
25
|
# pyforker
|
|
26
26
|
|
|
27
|
-
<p align="center">
|
|
28
|
-
<img src="https://github.com/powerofaisinstudy-debug/pyforker/blob/main/logo2.png" alt="pyforker logo" width="600"/>
|
|
29
27
|
</p>
|
|
30
28
|
|
|
31
29
|
**Production-Grade Single-File Python Library Extractor & Server Engine**
|
|
32
30
|
|
|
33
|
-
|
|
34
31
|
[](https://www.python.org/)
|
|
35
32
|
[](https://opensource.org/licenses/MIT)
|
|
36
33
|
[](#)
|
|
@@ -38,8 +35,6 @@ Dynamic: requires-python
|
|
|
38
35
|
|
|
39
36
|
`pyforker` is a lightweight, zero-dependency engine designed to selectively extract sub-modules from massive Python codebases or remote Git repositories. It automatically rewrites AST import graphs, resolves vendor dependencies, tracks upstream sync ledgers, and runs multi-threaded HTTP server daemons to mirror code snippets across networks.
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
38
|
---
|
|
44
39
|
|
|
45
40
|
## Key Features
|
|
@@ -62,14 +57,14 @@ Dynamic: requires-python
|
|
|
62
57
|
| (pyforker take / deps / sync / serve) |
|
|
63
58
|
+-----------------------+-------------------------+
|
|
64
59
|
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
+---------------+---------------+
|
|
61
|
+
| |
|
|
62
|
+
+-------------v-----------+ +-------------v-----------+
|
|
63
|
+
| Git Engine | | Multi-Threaded |
|
|
64
|
+
| (Local Cache/Clones) | | HTTP Daemon Server |
|
|
65
|
+
+-------------+-----------+ +-------------+-----------+
|
|
66
|
+
| |
|
|
67
|
+
+---------------+---------------+
|
|
73
68
|
|
|
|
74
69
|
+-------------v-------------+
|
|
75
70
|
| AST Rewriter & Analyzer |
|
|
@@ -77,32 +72,71 @@ Dynamic: requires-python
|
|
|
77
72
|
+-------------+-------------+
|
|
78
73
|
|
|
|
79
74
|
+-------------v-------------+
|
|
80
|
-
|
|
|
75
|
+
| Storage & File Locks |
|
|
81
76
|
| (pyforker.json Manifest) |
|
|
82
77
|
+---------------------------+
|
|
83
|
-
|
|
78
|
+
Installation
|
|
79
|
+
From Source (Editable Mode)
|
|
80
|
+
Clone your repository and install the binary link locally:
|
|
81
|
+
|
|
82
|
+
Bash
|
|
83
|
+
git clone [https://github.com/powerofaisinstudy-debug/pyforker.git](https://github.com/powerofaisinstudy-debug/pyforker.git)
|
|
84
84
|
cd pyforker
|
|
85
85
|
pip install -e .
|
|
86
|
-
Direct Pip
|
|
87
|
-
|
|
86
|
+
Direct Pip Installation
|
|
87
|
+
Bash
|
|
88
|
+
pip install .
|
|
89
|
+
CLI Reference & Usage
|
|
90
|
+
1. Extracting a Sub-Module (take)
|
|
91
|
+
Pull a single sub-folder out of a target repository, rewrite its namespace imports, and store it locally:
|
|
92
|
+
|
|
93
|
+
Bash
|
|
94
|
+
pyforker take [https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git) \
|
|
88
95
|
--sub-path tools/testing/kunit \
|
|
89
96
|
--out ./vendor/kunit \
|
|
90
97
|
--rewrite-from kunit \
|
|
91
98
|
--rewrite-to my_app.vendor.kunit
|
|
92
|
-
2. Discovering Third-Party Dependencies (deps)
|
|
93
|
-
|
|
99
|
+
2. Discovering Third-Party Dependencies (deps)
|
|
100
|
+
Scan an extracted module to discover external PyPI packages required to run it:
|
|
101
|
+
|
|
102
|
+
Bash
|
|
103
|
+
pyforker deps ./vendor/kunit
|
|
104
|
+
Output Example:
|
|
105
|
+
|
|
106
|
+
Plaintext
|
|
107
|
+
--- Discovered Third-Party Dependencies ---
|
|
94
108
|
- requests
|
|
95
109
|
- typing_extensions
|
|
96
110
|
-------------------------------------------
|
|
97
|
-
3. Syncing Extracted Code Upstream (sync)
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
3. Syncing Extracted Code Upstream (sync)
|
|
112
|
+
Check local pyforker.json manifests and update extracted modules against upstream Git repositories:
|
|
113
|
+
|
|
114
|
+
Bash
|
|
115
|
+
pyforker sync ./vendor/kunit
|
|
116
|
+
4. Running the Remote Mirror Server (serve)
|
|
117
|
+
Start a multi-threaded HTTP server on a remote server or local machine:
|
|
118
|
+
|
|
119
|
+
Bash
|
|
120
|
+
pyforker serve --host 0.0.0.0 --port 8080
|
|
121
|
+
5. Managing Remote Server Aliases (server-add / server-list)
|
|
122
|
+
Save and query remote server endpoints inside ~/.pyforker_config.json:
|
|
123
|
+
|
|
124
|
+
Bash
|
|
125
|
+
# Add server alias
|
|
100
126
|
pyforker server-add prod-mirror [http://192.168.1.100:8080](http://192.168.1.100:8080)
|
|
101
127
|
|
|
102
128
|
# List saved servers
|
|
103
129
|
pyforker server-list
|
|
104
|
-
6. Executing System Diagnostics (self-test)
|
|
105
|
-
|
|
130
|
+
6. Executing System Diagnostics (self-test)
|
|
131
|
+
Validate local environment, AST transformation hooks, file locks, and configuration storage:
|
|
132
|
+
|
|
133
|
+
Bash
|
|
134
|
+
pyforker self-test
|
|
135
|
+
Manifest Specification (pyforker.json)
|
|
136
|
+
When pyforker take completes an extraction, it generates or updates a local pyforker.json ledger:
|
|
137
|
+
|
|
138
|
+
JSON
|
|
139
|
+
{
|
|
106
140
|
"./vendor/kunit": {
|
|
107
141
|
"source_repo": "[https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git)",
|
|
108
142
|
"sub_path": "tools/testing/kunit",
|
|
@@ -116,21 +150,3 @@ Manifest Specification (pyforker.json)When pyforker take completes an extraction
|
|
|
116
150
|
]
|
|
117
151
|
}
|
|
118
152
|
}
|
|
119
|
-
Programmatic Python APIYou can import pyforker as an internal module inside your Python pipelines:Pythonfrom pyforker import ASTAnalyzer, GitEngine, FileLock
|
|
120
|
-
|
|
121
|
-
# Clone or update a repository into local cache
|
|
122
|
-
repo_path = GitEngine.clone_or_update(
|
|
123
|
-
"[https://github.com/example/repo.git](https://github.com/example/repo.git)",
|
|
124
|
-
"~/.pyforker_cache"
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
# Rewrite AST imports programmatically
|
|
128
|
-
detected_deps = ASTAnalyzer.process_file(
|
|
129
|
-
source_file="path/to/source.py",
|
|
130
|
-
target_file="path/to/output.py",
|
|
131
|
-
old_pkg="original_pkg",
|
|
132
|
-
new_pkg="my_app.vendor"
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
print(f"Discovered dependencies: {detected_deps}")
|
|
136
|
-
HTTP REST API SpecificationWhen running pyforker serve, the server exposes the following endpoints:EndpointMethodParameters / BodyDescription/healthGETNoneReturns engine status and uptime./manifestGETNoneReturns history ledger stored in host configuration./takePOST{"repo_url": "...", "sub_path": "..."}Triggers background clone and path verification.Running Unit TestsRun the integrated self-test suite directly:Bashpython3 pyforker.py self-test
|
pyforker-2.3.0/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# pyforker
|
|
2
|
+
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
**Production-Grade Single-File Python Library Extractor & Server Engine**
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](#)
|
|
10
|
+
[](#)
|
|
11
|
+
|
|
12
|
+
`pyforker` is a lightweight, zero-dependency engine designed to selectively extract sub-modules from massive Python codebases or remote Git repositories. It automatically rewrites AST import graphs, resolves vendor dependencies, tracks upstream sync ledgers, and runs multi-threaded HTTP server daemons to mirror code snippets across networks.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Key Features
|
|
17
|
+
|
|
18
|
+
* **Zero External Dependencies:** Built entirely on standard Python modules (`ast`, `urllib`, `subprocess`, `concurrent.futures`, `http.server`).
|
|
19
|
+
* **Sub-Module Slicing (`take`):** Extract specific folders from remote Git repositories without pulling unnecessary weight into your project.
|
|
20
|
+
* **AST Import Rewriting:** Dynamically rewrites import statements during extraction so isolated sub-modules map directly into your local package tree.
|
|
21
|
+
* **Dependency Discovery (`deps`):** AST-level scanning detects third-party PyPI requirements versus Python standard library imports.
|
|
22
|
+
* **Upstream Synchronization (`sync`):** Keeps track of commit SHAs in local `pyforker.json` manifests to pull updates from upstream sources seamlessly.
|
|
23
|
+
* **Multi-Threaded Server Engine (`serve`):** Built-in daemon allows remote extraction and repository mirroring over network endpoints.
|
|
24
|
+
* **Transactional File Safety:** Uses OS-level file locking (`O_CREAT | O_EXCL`) to ensure multi-threaded and concurrent CLI ops avoid race conditions.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Architecture Overview
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
+-------------------------------------------------+
|
|
32
|
+
| CLI Entry |
|
|
33
|
+
| (pyforker take / deps / sync / serve) |
|
|
34
|
+
+-----------------------+-------------------------+
|
|
35
|
+
|
|
|
36
|
+
+---------------+---------------+
|
|
37
|
+
| |
|
|
38
|
+
+-------------v-----------+ +-------------v-----------+
|
|
39
|
+
| Git Engine | | Multi-Threaded |
|
|
40
|
+
| (Local Cache/Clones) | | HTTP Daemon Server |
|
|
41
|
+
+-------------+-----------+ +-------------+-----------+
|
|
42
|
+
| |
|
|
43
|
+
+---------------+---------------+
|
|
44
|
+
|
|
|
45
|
+
+-------------v-------------+
|
|
46
|
+
| AST Rewriter & Analyzer |
|
|
47
|
+
| (Dependency Scanning) |
|
|
48
|
+
+-------------+-------------+
|
|
49
|
+
|
|
|
50
|
+
+-------------v-------------+
|
|
51
|
+
| Storage & File Locks |
|
|
52
|
+
| (pyforker.json Manifest) |
|
|
53
|
+
+---------------------------+
|
|
54
|
+
Installation
|
|
55
|
+
From Source (Editable Mode)
|
|
56
|
+
Clone your repository and install the binary link locally:
|
|
57
|
+
|
|
58
|
+
Bash
|
|
59
|
+
git clone [https://github.com/powerofaisinstudy-debug/pyforker.git](https://github.com/powerofaisinstudy-debug/pyforker.git)
|
|
60
|
+
cd pyforker
|
|
61
|
+
pip install -e .
|
|
62
|
+
Direct Pip Installation
|
|
63
|
+
Bash
|
|
64
|
+
pip install .
|
|
65
|
+
CLI Reference & Usage
|
|
66
|
+
1. Extracting a Sub-Module (take)
|
|
67
|
+
Pull a single sub-folder out of a target repository, rewrite its namespace imports, and store it locally:
|
|
68
|
+
|
|
69
|
+
Bash
|
|
70
|
+
pyforker take [https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git) \
|
|
71
|
+
--sub-path tools/testing/kunit \
|
|
72
|
+
--out ./vendor/kunit \
|
|
73
|
+
--rewrite-from kunit \
|
|
74
|
+
--rewrite-to my_app.vendor.kunit
|
|
75
|
+
2. Discovering Third-Party Dependencies (deps)
|
|
76
|
+
Scan an extracted module to discover external PyPI packages required to run it:
|
|
77
|
+
|
|
78
|
+
Bash
|
|
79
|
+
pyforker deps ./vendor/kunit
|
|
80
|
+
Output Example:
|
|
81
|
+
|
|
82
|
+
Plaintext
|
|
83
|
+
--- Discovered Third-Party Dependencies ---
|
|
84
|
+
- requests
|
|
85
|
+
- typing_extensions
|
|
86
|
+
-------------------------------------------
|
|
87
|
+
3. Syncing Extracted Code Upstream (sync)
|
|
88
|
+
Check local pyforker.json manifests and update extracted modules against upstream Git repositories:
|
|
89
|
+
|
|
90
|
+
Bash
|
|
91
|
+
pyforker sync ./vendor/kunit
|
|
92
|
+
4. Running the Remote Mirror Server (serve)
|
|
93
|
+
Start a multi-threaded HTTP server on a remote server or local machine:
|
|
94
|
+
|
|
95
|
+
Bash
|
|
96
|
+
pyforker serve --host 0.0.0.0 --port 8080
|
|
97
|
+
5. Managing Remote Server Aliases (server-add / server-list)
|
|
98
|
+
Save and query remote server endpoints inside ~/.pyforker_config.json:
|
|
99
|
+
|
|
100
|
+
Bash
|
|
101
|
+
# Add server alias
|
|
102
|
+
pyforker server-add prod-mirror [http://192.168.1.100:8080](http://192.168.1.100:8080)
|
|
103
|
+
|
|
104
|
+
# List saved servers
|
|
105
|
+
pyforker server-list
|
|
106
|
+
6. Executing System Diagnostics (self-test)
|
|
107
|
+
Validate local environment, AST transformation hooks, file locks, and configuration storage:
|
|
108
|
+
|
|
109
|
+
Bash
|
|
110
|
+
pyforker self-test
|
|
111
|
+
Manifest Specification (pyforker.json)
|
|
112
|
+
When pyforker take completes an extraction, it generates or updates a local pyforker.json ledger:
|
|
113
|
+
|
|
114
|
+
JSON
|
|
115
|
+
{
|
|
116
|
+
"./vendor/kunit": {
|
|
117
|
+
"source_repo": "[https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git)",
|
|
118
|
+
"sub_path": "tools/testing/kunit",
|
|
119
|
+
"commit": "a1b2c3d4e5f67890",
|
|
120
|
+
"files_extracted": 14,
|
|
121
|
+
"extracted_at": 1773724800.0,
|
|
122
|
+
"detected_imports": [
|
|
123
|
+
"sys",
|
|
124
|
+
"os",
|
|
125
|
+
"requests"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyforker
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Zero-dependency toolkit for selectively extracting sub-modules, inspecting ASTs, and operating remote library mirror servers.
|
|
5
5
|
Author: Sundaram Gupta
|
|
6
6
|
License: MIT
|
|
@@ -24,13 +24,10 @@ Dynamic: requires-python
|
|
|
24
24
|
|
|
25
25
|
# pyforker
|
|
26
26
|
|
|
27
|
-
<p align="center">
|
|
28
|
-
<img src="https://github.com/powerofaisinstudy-debug/pyforker/blob/main/logo2.png" alt="pyforker logo" width="600"/>
|
|
29
27
|
</p>
|
|
30
28
|
|
|
31
29
|
**Production-Grade Single-File Python Library Extractor & Server Engine**
|
|
32
30
|
|
|
33
|
-
|
|
34
31
|
[](https://www.python.org/)
|
|
35
32
|
[](https://opensource.org/licenses/MIT)
|
|
36
33
|
[](#)
|
|
@@ -38,8 +35,6 @@ Dynamic: requires-python
|
|
|
38
35
|
|
|
39
36
|
`pyforker` is a lightweight, zero-dependency engine designed to selectively extract sub-modules from massive Python codebases or remote Git repositories. It automatically rewrites AST import graphs, resolves vendor dependencies, tracks upstream sync ledgers, and runs multi-threaded HTTP server daemons to mirror code snippets across networks.
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
38
|
---
|
|
44
39
|
|
|
45
40
|
## Key Features
|
|
@@ -62,14 +57,14 @@ Dynamic: requires-python
|
|
|
62
57
|
| (pyforker take / deps / sync / serve) |
|
|
63
58
|
+-----------------------+-------------------------+
|
|
64
59
|
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
+---------------+---------------+
|
|
61
|
+
| |
|
|
62
|
+
+-------------v-----------+ +-------------v-----------+
|
|
63
|
+
| Git Engine | | Multi-Threaded |
|
|
64
|
+
| (Local Cache/Clones) | | HTTP Daemon Server |
|
|
65
|
+
+-------------+-----------+ +-------------+-----------+
|
|
66
|
+
| |
|
|
67
|
+
+---------------+---------------+
|
|
73
68
|
|
|
|
74
69
|
+-------------v-------------+
|
|
75
70
|
| AST Rewriter & Analyzer |
|
|
@@ -77,32 +72,71 @@ Dynamic: requires-python
|
|
|
77
72
|
+-------------+-------------+
|
|
78
73
|
|
|
|
79
74
|
+-------------v-------------+
|
|
80
|
-
|
|
|
75
|
+
| Storage & File Locks |
|
|
81
76
|
| (pyforker.json Manifest) |
|
|
82
77
|
+---------------------------+
|
|
83
|
-
|
|
78
|
+
Installation
|
|
79
|
+
From Source (Editable Mode)
|
|
80
|
+
Clone your repository and install the binary link locally:
|
|
81
|
+
|
|
82
|
+
Bash
|
|
83
|
+
git clone [https://github.com/powerofaisinstudy-debug/pyforker.git](https://github.com/powerofaisinstudy-debug/pyforker.git)
|
|
84
84
|
cd pyforker
|
|
85
85
|
pip install -e .
|
|
86
|
-
Direct Pip
|
|
87
|
-
|
|
86
|
+
Direct Pip Installation
|
|
87
|
+
Bash
|
|
88
|
+
pip install .
|
|
89
|
+
CLI Reference & Usage
|
|
90
|
+
1. Extracting a Sub-Module (take)
|
|
91
|
+
Pull a single sub-folder out of a target repository, rewrite its namespace imports, and store it locally:
|
|
92
|
+
|
|
93
|
+
Bash
|
|
94
|
+
pyforker take [https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git) \
|
|
88
95
|
--sub-path tools/testing/kunit \
|
|
89
96
|
--out ./vendor/kunit \
|
|
90
97
|
--rewrite-from kunit \
|
|
91
98
|
--rewrite-to my_app.vendor.kunit
|
|
92
|
-
2. Discovering Third-Party Dependencies (deps)
|
|
93
|
-
|
|
99
|
+
2. Discovering Third-Party Dependencies (deps)
|
|
100
|
+
Scan an extracted module to discover external PyPI packages required to run it:
|
|
101
|
+
|
|
102
|
+
Bash
|
|
103
|
+
pyforker deps ./vendor/kunit
|
|
104
|
+
Output Example:
|
|
105
|
+
|
|
106
|
+
Plaintext
|
|
107
|
+
--- Discovered Third-Party Dependencies ---
|
|
94
108
|
- requests
|
|
95
109
|
- typing_extensions
|
|
96
110
|
-------------------------------------------
|
|
97
|
-
3. Syncing Extracted Code Upstream (sync)
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
3. Syncing Extracted Code Upstream (sync)
|
|
112
|
+
Check local pyforker.json manifests and update extracted modules against upstream Git repositories:
|
|
113
|
+
|
|
114
|
+
Bash
|
|
115
|
+
pyforker sync ./vendor/kunit
|
|
116
|
+
4. Running the Remote Mirror Server (serve)
|
|
117
|
+
Start a multi-threaded HTTP server on a remote server or local machine:
|
|
118
|
+
|
|
119
|
+
Bash
|
|
120
|
+
pyforker serve --host 0.0.0.0 --port 8080
|
|
121
|
+
5. Managing Remote Server Aliases (server-add / server-list)
|
|
122
|
+
Save and query remote server endpoints inside ~/.pyforker_config.json:
|
|
123
|
+
|
|
124
|
+
Bash
|
|
125
|
+
# Add server alias
|
|
100
126
|
pyforker server-add prod-mirror [http://192.168.1.100:8080](http://192.168.1.100:8080)
|
|
101
127
|
|
|
102
128
|
# List saved servers
|
|
103
129
|
pyforker server-list
|
|
104
|
-
6. Executing System Diagnostics (self-test)
|
|
105
|
-
|
|
130
|
+
6. Executing System Diagnostics (self-test)
|
|
131
|
+
Validate local environment, AST transformation hooks, file locks, and configuration storage:
|
|
132
|
+
|
|
133
|
+
Bash
|
|
134
|
+
pyforker self-test
|
|
135
|
+
Manifest Specification (pyforker.json)
|
|
136
|
+
When pyforker take completes an extraction, it generates or updates a local pyforker.json ledger:
|
|
137
|
+
|
|
138
|
+
JSON
|
|
139
|
+
{
|
|
106
140
|
"./vendor/kunit": {
|
|
107
141
|
"source_repo": "[https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git)",
|
|
108
142
|
"sub_path": "tools/testing/kunit",
|
|
@@ -116,21 +150,3 @@ Manifest Specification (pyforker.json)When pyforker take completes an extraction
|
|
|
116
150
|
]
|
|
117
151
|
}
|
|
118
152
|
}
|
|
119
|
-
Programmatic Python APIYou can import pyforker as an internal module inside your Python pipelines:Pythonfrom pyforker import ASTAnalyzer, GitEngine, FileLock
|
|
120
|
-
|
|
121
|
-
# Clone or update a repository into local cache
|
|
122
|
-
repo_path = GitEngine.clone_or_update(
|
|
123
|
-
"[https://github.com/example/repo.git](https://github.com/example/repo.git)",
|
|
124
|
-
"~/.pyforker_cache"
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
# Rewrite AST imports programmatically
|
|
128
|
-
detected_deps = ASTAnalyzer.process_file(
|
|
129
|
-
source_file="path/to/source.py",
|
|
130
|
-
target_file="path/to/output.py",
|
|
131
|
-
old_pkg="original_pkg",
|
|
132
|
-
new_pkg="my_app.vendor"
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
print(f"Discovered dependencies: {detected_deps}")
|
|
136
|
-
HTTP REST API SpecificationWhen running pyforker serve, the server exposes the following endpoints:EndpointMethodParameters / BodyDescription/healthGETNoneReturns engine status and uptime./manifestGETNoneReturns history ledger stored in host configuration./takePOST{"repo_url": "...", "sub_path": "..."}Triggers background clone and path verification.Running Unit TestsRun the integrated self-test suite directly:Bashpython3 pyforker.py self-test
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pyforker"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.3.0"
|
|
8
8
|
description = "Zero-dependency toolkit for selectively extracting sub-modules, inspecting ASTs, and operating remote library mirror servers."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -10,7 +10,7 @@ if os.path.exists("README.md"):
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="pyforker",
|
|
13
|
-
version="2.
|
|
13
|
+
version="2.3.0",
|
|
14
14
|
description="Zero-dependency toolkit for selectively extracting sub-modules and running mirror servers.",
|
|
15
15
|
long_description=long_description,
|
|
16
16
|
long_description_content_type="text/markdown",
|
pyforker-2.1.0/README.md
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
# pyforker
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="https://github.com/powerofaisinstudy-debug/pyforker/blob/main/logo2.png" alt="pyforker logo" width="600"/>
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
**Production-Grade Single-File Python Library Extractor & Server Engine**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[](https://www.python.org/)
|
|
11
|
-
[](https://opensource.org/licenses/MIT)
|
|
12
|
-
[](#)
|
|
13
|
-
[](#)
|
|
14
|
-
|
|
15
|
-
`pyforker` is a lightweight, zero-dependency engine designed to selectively extract sub-modules from massive Python codebases or remote Git repositories. It automatically rewrites AST import graphs, resolves vendor dependencies, tracks upstream sync ledgers, and runs multi-threaded HTTP server daemons to mirror code snippets across networks.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Key Features
|
|
22
|
-
|
|
23
|
-
* **Zero External Dependencies:** Built entirely on standard Python modules (`ast`, `urllib`, `subprocess`, `concurrent.futures`, `http.server`).
|
|
24
|
-
* **Sub-Module Slicing (`take`):** Extract specific folders from remote Git repositories without pulling unnecessary weight into your project.
|
|
25
|
-
* **AST Import Rewriting:** Dynamically rewrites import statements during extraction so isolated sub-modules map directly into your local package tree.
|
|
26
|
-
* **Dependency Discovery (`deps`):** AST-level scanning detects third-party PyPI requirements versus Python standard library imports.
|
|
27
|
-
* **Upstream Synchronization (`sync`):** Keeps track of commit SHAs in local `pyforker.json` manifests to pull updates from upstream sources seamlessly.
|
|
28
|
-
* **Multi-Threaded Server Engine (`serve`):** Built-in daemon allows remote extraction and repository mirroring over network endpoints.
|
|
29
|
-
* **Transactional File Safety:** Uses OS-level file locking (`O_CREAT | O_EXCL`) to ensure multi-threaded and concurrent CLI ops avoid race conditions.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Architecture Overview
|
|
34
|
-
|
|
35
|
-
```text
|
|
36
|
-
+-------------------------------------------------+
|
|
37
|
-
| CLI Entry |
|
|
38
|
-
| (pyforker take / deps / sync / serve) |
|
|
39
|
-
+-----------------------+-------------------------+
|
|
40
|
-
|
|
|
41
|
-
+-----------------+-----------------+
|
|
42
|
-
| |
|
|
43
|
-
+-----------v-----------+ +-----------v-----------+
|
|
44
|
-
| Git Engine | | Multi-Threaded |
|
|
45
|
-
| (Local Cache/Clones) | | HTTP Daemon Server |
|
|
46
|
-
+-----------+-----------+ +-----------+-----------+
|
|
47
|
-
| |
|
|
48
|
-
+-----------------+-----------------+
|
|
49
|
-
|
|
|
50
|
-
+-------------v-------------+
|
|
51
|
-
| AST Rewriter & Analyzer |
|
|
52
|
-
| (Dependency Scanning) |
|
|
53
|
-
+-------------+-------------+
|
|
54
|
-
|
|
|
55
|
-
+-------------v-------------+
|
|
56
|
-
| Storage & File Locks |
|
|
57
|
-
| (pyforker.json Manifest) |
|
|
58
|
-
+---------------------------+
|
|
59
|
-
InstallationFrom Source (Editable Mode)Clone your repository and install the binary link locally:Bashgit clone [https://github.com/your-username/pyforker.git](https://github.com/your-username/pyforker.git)
|
|
60
|
-
cd pyforker
|
|
61
|
-
pip install -e .
|
|
62
|
-
Direct Pip InstallationBashpip install .
|
|
63
|
-
CLI Reference & Usage1. Extracting a Sub-Module (take)Pull a single sub-folder out of a target repository, rewrite its namespace imports, and store it locally:Bashpyforker take [https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git) \
|
|
64
|
-
--sub-path tools/testing/kunit \
|
|
65
|
-
--out ./vendor/kunit \
|
|
66
|
-
--rewrite-from kunit \
|
|
67
|
-
--rewrite-to my_app.vendor.kunit
|
|
68
|
-
2. Discovering Third-Party Dependencies (deps)Scan an extracted module to discover external PyPI packages required to run it:Bashpyforker deps ./vendor/kunit
|
|
69
|
-
Output Example:Plaintext--- Discovered Third-Party Dependencies ---
|
|
70
|
-
- requests
|
|
71
|
-
- typing_extensions
|
|
72
|
-
-------------------------------------------
|
|
73
|
-
3. Syncing Extracted Code Upstream (sync)Check local pyforker.json manifests and update extracted modules against upstream Git repositories:Bashpyforker sync ./vendor/kunit
|
|
74
|
-
4. Running the Remote Mirror Server (serve)Start a multi-threaded HTTP server on a remote server or local machine:Bashpyforker serve --host 0.0.0.0 --port 8080
|
|
75
|
-
5. Managing Remote Server Aliases (server-add / server-list)Save and query remote server endpoints inside ~/.pyforker_config.json:Bash# Add server alias
|
|
76
|
-
pyforker server-add prod-mirror [http://192.168.1.100:8080](http://192.168.1.100:8080)
|
|
77
|
-
|
|
78
|
-
# List saved servers
|
|
79
|
-
pyforker server-list
|
|
80
|
-
6. Executing System Diagnostics (self-test)Validate local environment, AST transformation hooks, file locks, and configuration storage:Bashpyforker self-test
|
|
81
|
-
Manifest Specification (pyforker.json)When pyforker take completes an extraction, it generates or updates a local pyforker.json ledger:JSON{
|
|
82
|
-
"./vendor/kunit": {
|
|
83
|
-
"source_repo": "[https://github.com/torvalds/linux.git](https://github.com/torvalds/linux.git)",
|
|
84
|
-
"sub_path": "tools/testing/kunit",
|
|
85
|
-
"commit": "a1b2c3d4e5f67890",
|
|
86
|
-
"files_extracted": 14,
|
|
87
|
-
"extracted_at": 1773724800.0,
|
|
88
|
-
"detected_imports": [
|
|
89
|
-
"sys",
|
|
90
|
-
"os",
|
|
91
|
-
"requests"
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
Programmatic Python APIYou can import pyforker as an internal module inside your Python pipelines:Pythonfrom pyforker import ASTAnalyzer, GitEngine, FileLock
|
|
96
|
-
|
|
97
|
-
# Clone or update a repository into local cache
|
|
98
|
-
repo_path = GitEngine.clone_or_update(
|
|
99
|
-
"[https://github.com/example/repo.git](https://github.com/example/repo.git)",
|
|
100
|
-
"~/.pyforker_cache"
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
# Rewrite AST imports programmatically
|
|
104
|
-
detected_deps = ASTAnalyzer.process_file(
|
|
105
|
-
source_file="path/to/source.py",
|
|
106
|
-
target_file="path/to/output.py",
|
|
107
|
-
old_pkg="original_pkg",
|
|
108
|
-
new_pkg="my_app.vendor"
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
print(f"Discovered dependencies: {detected_deps}")
|
|
112
|
-
HTTP REST API SpecificationWhen running pyforker serve, the server exposes the following endpoints:EndpointMethodParameters / BodyDescription/healthGETNoneReturns engine status and uptime./manifestGETNoneReturns history ledger stored in host configuration./takePOST{"repo_url": "...", "sub_path": "..."}Triggers background clone and path verification.Running Unit TestsRun the integrated self-test suite directly:Bashpython3 pyforker.py self-test
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|