Skip to main content

pythonodejs 🐍➕🟢

PyPI version Python versions License: MIT Downloads

Embed Node.js natively in Python with seamless integration.

📋 Overview

pythonodejs lets you harness the power of the Node.js ecosystem directly within your Python applications. Run JavaScript code, use NPM packages, and leverage the best of both worlds in a single application.

🚀 Installation

pip install pythonodejs

🔍 Quick Example

from pythonodejs import node_eval

# Execute JavaScript directly
node_eval("console.log('Hello from Node.js in Python!')")
# > Hello from Node.js in Python!

# Create and return JavaScript functions
read_file = node_eval("""
const fs = require('fs');

function readFile(filePath) {
    return fs.readFileSync(filePath, 'utf8');
}

readFile; // Return the function
""")

# Call JavaScript functions from Python
content = read_file("example.txt")
print(content)
More Examples

🔄 Integration with NPM

npm init -y
npm install lodash express axios
from pythonodejs import node_eval

result = node_eval("""
const _ = require('lodash');
const numbers = [1, 2, 3, 4, 5];
_.sum(numbers);
""")
print(f"Sum: {result}")

node_eval("""
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello from Express running in Python!');
});

app.listen(3000, () => {
  console.log('Express server running on port 3000');
});
""")

🔧 Advanced Usage

Working with JS Objects

person = node_eval("""
const person = {
  name: 'John',
  age: 30,
  greet: function() {
    return `Hello, my name is ${this.name}`;
  }
};
person;
""")
print(person['name'])
print(person['greet']())

Passing Python → JS

process_data = node_eval("""
function processData(data) {
  return {
    processed: true,
    items: data.items.map(x => x * 2),
    message: `Processed ${data.items.length} items`
  };
}
processData;
""")

result = process_data({'items': [1, 2, 3, 4, 5]})
print(result)

✅ ToDo

  • Stable release
  • Loading ES Modules
  • Automatic npm install on dependency detection
  • Better error logging

🏗️ Building from Source

  1. Install SConstruct and Clang
  2. Run pip install -r requirements.txt
  3. Run scons

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License.

🙏 Special Thanks

A special thanks to M-logique for their contribution to this project.

Metadata

Release files for pythonodejs 1.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pythonodejs 1.4.6
File Actions
pythonodejs-1.4.6-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pythonodejs-1.4.6-cp312-cp312-win_amd64.whl
pythonodejs-1.4.6-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details for pythonodejs-1.4.6-cp312-cp312-macosx_14_0_arm64.whl
pythonodejs-1.4.6-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for pythonodejs-1.4.6-cp311-cp311-win_amd64.whl
pythonodejs-1.4.6-cp311-cp311-macosx_14_0_arm64.whl CPython 3.11 CPython 3.11 macOS 14.0+ ARM64 Details for pythonodejs-1.4.6-cp311-cp311-macosx_14_0_arm64.whl
pythonodejs-1.4.6-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for pythonodejs-1.4.6-cp310-cp310-win_amd64.whl
pythonodejs-1.4.6-cp310-cp310-macosx_14_0_arm64.whl CPython 3.10 CPython 3.10 macOS 14.0+ ARM64 Details for pythonodejs-1.4.6-cp310-cp310-macosx_14_0_arm64.whl
pythonodejs-1.4.6-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for pythonodejs-1.4.6-cp39-cp39-win_amd64.whl
pythonodejs-1.4.6-cp39-cp39-macosx_14_0_arm64.whl CPython 3.9 CPython 3.9 macOS 14.0+ ARM64 Details for pythonodejs-1.4.6-cp39-cp39-macosx_14_0_arm64.whl

Total release size: 554.0 MB

Release files / pythonodejs-1.4.6-cp312-cp312-win_amd64.whl

Download URL pythonodejs-1.4.6-cp312-cp312-win_amd64.whl
Size 35.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
bb6a50315bb9b149778e0fc5e2249f3164432e2eeceefb023636d1e4462a7995
BLAKE2b-256 checksum
How to use checksums
cc804296ac287aa09bf71c4809b94cd813223926e92db5ab9eba3ed548afc92f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp312-cp312-macosx_14_0_arm64.whl

Download URL pythonodejs-1.4.6-cp312-cp312-macosx_14_0_arm64.whl
Size 102.8 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
945d17a423ff398ee9265a380df98d279a3cd4c8df8ec3f8a08f2e8a14f41d4f
BLAKE2b-256 checksum
How to use checksums
e7c5f02aa5dd200d429fa270fa7ff95b2c991bbcd90c14a92ebc2994cd2ab748
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp311-cp311-win_amd64.whl

Download URL pythonodejs-1.4.6-cp311-cp311-win_amd64.whl
Size 35.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0c3377b03b33cdf24861397ed6e9c06446015aab3e692f12de6fdcef2249e69f
BLAKE2b-256 checksum
How to use checksums
5e6a77a3d4b34c373742d98d38262e09a800615879423073a1609019daed4d56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp311-cp311-macosx_14_0_arm64.whl

Download URL pythonodejs-1.4.6-cp311-cp311-macosx_14_0_arm64.whl
Size 102.8 MB
Tags CPython 3.11 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
babe84e4fe47ff0f6a45253c6a2fdab1fdca6c6e18e10f5f40c32c5257fa3036
BLAKE2b-256 checksum
How to use checksums
8ed6a33e33aa9f6653a0e6d52e3795671a3aa35cbf821db53273e12a1fb80f31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp310-cp310-win_amd64.whl

Download URL pythonodejs-1.4.6-cp310-cp310-win_amd64.whl
Size 35.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
79827062aed54584e4c3063a1af04b2125604179ba494c57331606c0b6e8c2cb
BLAKE2b-256 checksum
How to use checksums
fc566e01bcf4ba4c46121ee29a4b77f46cc5abe10dc05308ee79b5155719a65d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp310-cp310-macosx_14_0_arm64.whl

Download URL pythonodejs-1.4.6-cp310-cp310-macosx_14_0_arm64.whl
Size 102.8 MB
Tags CPython 3.10 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
9f44824381d217eb27c266de31fc1dcb72187815f71952492b07e6eb9ebf5e0a
BLAKE2b-256 checksum
How to use checksums
4309c9d8659e2487e62034044add40ae0f387fd9c51e22a36e4c606e128bac5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp39-cp39-win_amd64.whl

Download URL pythonodejs-1.4.6-cp39-cp39-win_amd64.whl
Size 35.7 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
08afd083aa234714d05cd9804b135842411f5d6161f03eb5a99c739febf75a83
BLAKE2b-256 checksum
How to use checksums
b6b41ef5706efee61a22d02e341c7548bf62e5b0344021784a811e8f07f3e4db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / pythonodejs-1.4.6-cp39-cp39-macosx_14_0_arm64.whl

Download URL pythonodejs-1.4.6-cp39-cp39-macosx_14_0_arm64.whl
Size 102.8 MB
Tags CPython 3.9 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
35ceee3240a637416d4637d368d561bda6eea58b464e86c06435413b5a653bbd
BLAKE2b-256 checksum
How to use checksums
755483b699da23554e33ffcca0fd15d3c86e8861e6baea584ab42e222f9da074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Security for pythonodejs 1.4.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page