Skip to content

Commit cf3103b

Browse files
committed
Trigger PyPI publish
1 parent afa0702 commit cf3103b

4 files changed

Lines changed: 115 additions & 41 deletions

File tree

.github/workflows/.publish.yml.swp

-1 KB
Binary file not shown.

.github/workflows/publish.yml.save

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main # veya senin ana branch adın
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install dependencies
21+
run: pip install build twine
22+
23+
- name: Build package
24+
run: python -m build
25+
26+
- name: Publish package to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
with:
29+
user: __token__
30+
password: ${{ secrets.PYPI_API_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "crosspulse",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Call Python from Node.js and Node.js from Python easily with Crosspulse’s lightweight bridge.",
55
"main": "crosspulse.js",
66
"directories": {

src/crosspulse.egg-info/PKG-INFO

Lines changed: 84 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,19 @@ That's it. No REST APIs, no HTTP servers, no complexity.
5757

5858
## 📦 Installation
5959

60-
Simply copy the files to your project:
60+
**Download Manual:**
61+
62+
JavaScript:
63+
```bash
64+
npm install crosspulse
65+
```
66+
67+
Python:
68+
```bash
69+
pip install crosspulse
70+
```
71+
72+
**or Simply copy the files to your project:**
6173

6274
```bash
6375
crosspulse.py
@@ -78,32 +90,41 @@ Call Python functions from JavaScript.
7890

7991
**JavaScript side:**
8092
```javascript
81-
const Crosspulse = require('./crosspulse');
93+
import Crosspulse from "crosspulse/src/crosspulse.js";
8294

8395
async function main() {
96+
// Create a bridge in "connect" mode
8497
const bridge = new Crosspulse("connect");
85-
await bridge.connect("./crosspulse.py");
8698

87-
// Call Python function
99+
// Connect to the Python script
100+
await bridge.connect("python main.py");
101+
102+
// Call a Python function and get the result
88103
const result = await bridge.call("py_add", 10, 20);
89104
console.log(result); // 30
90105

106+
// Disconnect the bridge
91107
bridge.disconnect();
92108
}
93109

110+
// Run the main function
94111
main();
95112
```
96113

97114
**Python side:**
98115
```python
99-
from crosspulse import Crosspulse
116+
import crosspulse
100117

101-
bridge = Crosspulse(mode="listen")
118+
# Create a bridge in "listen" mode
119+
bridge = crosspulse.Crosspulse(mode="listen")
102120

103-
# Register method
104-
bridge.register("py_add", lambda a, b: a + b)
121+
# Register a Python method that JS can call
122+
def py_add(a, b):
123+
return a + b
105124

106-
# Start listening
125+
bridge.register("py_add", py_add)
126+
127+
# Start listening for incoming calls from JavaScript
107128
bridge.listen()
108129
```
109130

@@ -120,34 +141,39 @@ Call JavaScript functions from Python.
120141

121142
**Python side:**
122143
```python
123-
from crosspulse import Crosspulse
144+
import crosspulse
145+
146+
# Create a bridge in "connect" mode
147+
bridge = crosspulse.Crosspulse(mode="connect")
124148

125-
bridge = Crosspulse(mode="connect")
126-
bridge.connect("./crosspulse.js")
149+
# Connect to the JavaScript script
150+
bridge.connect("node app.js")
127151

128-
# Call JavaScript function
152+
# Call a JavaScript function and get the result
129153
result = bridge.call("js_multiply", 100, 50)
130154
print(result) # 5000
131155

156+
# Disconnect the bridge
132157
bridge.disconnect()
133158
```
134159

135160
**JavaScript side:**
136161
```javascript
137-
const Crosspulse = require('./crosspulse');
162+
import Crosspulse from "crosspulse/src/crosspulse.js";
138163

164+
// Create a bridge in "listen" mode
139165
const bridge = new Crosspulse("listen");
140166

141-
// Register method
167+
// Register a JavaScript method that Python can call
142168
bridge.register("js_multiply", (a, b) => a * b);
143169

144-
// Start listening
170+
// Start listening for incoming calls from Python
145171
bridge.listen();
146172
```
147173

148174
**Run:**
149175
```bash
150-
python3 main.py
176+
python main.py
151177
```
152178

153179
---
@@ -158,33 +184,47 @@ Both languages can call each other simultaneously!
158184

159185
**Python side:**
160186
```python
161-
bridge = Crosspulse(mode="connect")
187+
import crosspulse
188+
189+
# Create a bridge in "connect" mode
190+
bridge = crosspulse.Crosspulse(mode="connect")
191+
192+
# Register Python methods that JavaScript can call
193+
def py_square(x):
194+
return x ** 2
162195

163-
# Register our methods (JS can call these)
164-
bridge.register("py_square", lambda x: x ** 2)
165-
bridge.register("py_reverse", lambda s: s[::-1])
196+
def py_reverse(s):
197+
return s[::-1]
166198

167-
bridge.connect("./app.js")
199+
bridge.register("py_square", py_square)
200+
bridge.register("py_reverse", py_reverse)
168201

169-
# Call JS methods
202+
# Connect to the JavaScript script
203+
bridge.connect("node app.js")
204+
205+
# Call JavaScript methods
170206
result = bridge.call("js_capitalize", "hello world")
171207
print(result) # "HELLO WORLD"
172208

173-
# JS can simultaneously call py_square() or py_reverse()
209+
# JavaScript can call py_square() or py_reverse() one request at a time
174210
```
175211

176212
**JavaScript side:**
177213
```javascript
214+
import Crosspulse from "crosspulse/src/crosspulse.js";
215+
216+
// Create a bridge in "listen" mode
178217
const bridge = new Crosspulse("listen");
179218

180-
// Register our methods (Python can call these)
219+
// Register JavaScript methods that Python can call
181220
bridge.register("js_capitalize", (str) => str.toUpperCase());
182221
bridge.register("js_length", (str) => str.length);
183222

223+
// Start listening for incoming calls from Python
184224
bridge.listen();
185225

186-
// Python can simultaneously call our methods
187-
// We automatically respond to incoming calls
226+
// Python can call these methods one request at a time
227+
// Incoming calls are automatically handled
188228
```
189229

190230
---
@@ -207,7 +247,7 @@ bridge.register("method_name", callback_function)
207247
bridge.listen()
208248

209249
# Connect to target (connect mode)
210-
bridge.connect("target_script.js")
250+
bridge.connect("node target_script.js")
211251

212252
# Call remote method
213253
result = bridge.call("method_name", arg1, arg2)
@@ -219,7 +259,7 @@ bridge.disconnect()
219259
### JavaScript
220260

221261
```javascript
222-
const Crosspulse = require('./crosspulse');
262+
import Crosspulse from "crosspulse/src/crosspulse.js";
223263

224264
// Create instance
225265
const bridge = new Crosspulse("listen"); // Listen mode
@@ -234,7 +274,7 @@ bridge.register("method_name", (arg1, arg2) => {
234274
bridge.listen();
235275

236276
// Connect to target (connect mode)
237-
await bridge.connect("./target_script.py");
277+
await bridge.connect("python target_script.py");
238278

239279
// Call remote method
240280
const result = await bridge.call("method_name", arg1, arg2);
@@ -255,7 +295,7 @@ import pandas as pd
255295
from crosspulse import Crosspulse
256296

257297
bridge = Crosspulse("connect")
258-
bridge.connect("./visualizer.js")
298+
bridge.connect("node visualizer.js")
259299

260300
# Process data in Python
261301
df = pd.read_csv("sales_data.csv")
@@ -268,6 +308,8 @@ print(f"Chart created: {chart}")
268308

269309
```javascript
270310
// visualizer.js
311+
import Crosspulse from "crosspulse/src/crosspulse.js";
312+
271313
const bridge = new Crosspulse("listen");
272314

273315
bridge.register("create_chart", (data) => {
@@ -283,10 +325,12 @@ bridge.listen();
283325

284326
```javascript
285327
// ml_interface.js
328+
import Crosspulse from "crosspulse/src/crosspulse.js";
329+
286330
const bridge = new Crosspulse("connect");
287331

288332
async function trainModel(dataset) {
289-
await bridge.connect("./ml_model.py");
333+
await bridge.connect("python ml_model.py");
290334

291335
const progress = await bridge.call("train", dataset);
292336
console.log("Training progress:", progress);
@@ -299,6 +343,7 @@ async function trainModel(dataset) {
299343
```python
300344
# ml_model.py
301345
from sklearn.ensemble import RandomForestClassifier
346+
from crosspulse import Crosspulse
302347

303348
bridge = Crosspulse("listen")
304349

@@ -330,18 +375,20 @@ def scrape_news():
330375
# Send to JavaScript for display
331376
bridge.call("update_ui", data)
332377

333-
bridge.connect("./server.js")
378+
bridge.connect("node server.js")
334379
scrape_news()
335380
```
336381

337382
### Example 4: Desktop App (Electron + Python)
338383

339384
```javascript
340385
// electron_main.js
386+
import Crosspulse from "crosspulse/src/crosspulse.js";
387+
341388
const bridge = new Crosspulse("connect");
342389

343390
ipcMain.on("process-image", async (event, imagePath) => {
344-
await bridge.connect("./image_processor.py");
391+
await bridge.connect("python image_processor.py");
345392

346393
const processed = await bridge.call("enhance_image", imagePath);
347394
event.reply("image-ready", processed);
@@ -463,7 +510,7 @@ bridge.listen() # Must be after register
463510
### Connection timeout
464511
```javascript
465512
// Ensure Python script is running
466-
await bridge.connect("./script.py");
513+
await bridge.connect("python script.py");
467514
// Python should be in listen mode
468515
```
469516

@@ -481,7 +528,7 @@ await bridge.connect("./script.py");
481528
Contributions are welcome! Here's how:
482529

483530
```bash
484-
git clone https://github.com/yourusername/crosspulse.git
531+
git clone https://github.com/AnarDevStudio/crosspulse.git
485532
cd crosspulse
486533
```
487534

@@ -524,8 +571,6 @@ SOFTWARE.
524571

525572
---
526573

527-
528-
529574
## 🌟 Show Your Support
530575

531576
If Crosspulse helps your project, give it a ⭐️ on GitHub!
@@ -540,9 +585,8 @@ If Crosspulse helps your project, give it a ⭐️ on GitHub!
540585

541586
---
542587

543-
544588
**Built with ❤️ by developers who believe languages should work together, not apart.**
545589

546590
**Crosspulse** - Where Python meets JavaScript. 🚀
547591

548-
**Make by AnarEsgerzade🌷**
592+
**Made by AnarEsgerzade🌷**

0 commit comments

Comments
 (0)