Skip to content

Commit e38e38a

Browse files
committed
Stable and Tested commit for npm
0 parents  commit e38e38a

13 files changed

+4103
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
/dist

CONTRIBUTING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Contributing to python-spawn
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
- Becoming a maintainer
10+
11+
## We Develop with Github
12+
13+
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
14+
15+
## We Use [Github Flow](https://docs.github.com/en/get-started/using-github/github-flow), So All Code Changes Happen Through Pull Requests
16+
17+
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
18+
19+
1. Fork the repo and create your branch from `main`.
20+
2. If you've added code that should be tested, add tests.
21+
3. If you've changed APIs, update the documentation.
22+
4. Ensure the test suite passes.
23+
5. Make sure your code lints.
24+
6. Issue that pull request!
25+
26+
## Any contributions you make will be under the MIT Software License
27+
28+
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](https://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
29+
30+
## Report bugs using Github's [issues](https://github.com/your/project/issues)
31+
32+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/your/project/issues/new); it's that easy!
33+
34+
## Write bug reports with detail, background, and sample code
35+
36+
**Great Bug Reports** tend to have:
37+
38+
- A quick summary and/or background
39+
- Steps to reproduce
40+
- Be specific!
41+
- Give sample code if you can.
42+
- What you expected would happen
43+
- What actually happens
44+
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
45+
46+
People _love_ thorough bug reports.
47+
48+
## License
49+
50+
By contributing, you agree that your contributions will be licensed under its MIT License.
51+
52+
## References
53+
54+
This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/master/CONTRIBUTING.md)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2024] [SHREYAS M KAUSHIK]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# python-spawn
2+
3+
`python-spawn` is an npm package designed to bridge the gap between Node.js and Python, allowing Node.js applications to execute Python scripts seamlessly. This package simplifies the integration process by providing an easy-to-use interface for running Python code, functions, and scripts directly from Node.js.
4+
5+
## Features
6+
7+
- **Automatic Python Command Detection**: Determines the available Python command (`python` or `python3`) on the system.
8+
- **Script Execution**: Enables the execution of entire Python scripts or specific functions within scripts, with argument passing capability.
9+
- **Asynchronous Support**: Executes Python scripts asynchronously, returning results via Promises for better integration with modern JavaScript code.
10+
- **Error Handling**: Provides comprehensive error messages to aid in debugging.
11+
- **Temporary Script Wrapping**: Generates a temporary wrapper script for executing specific Python functions, ensuring clean execution and removal post-execution.
12+
13+
## Installation
14+
15+
Install `python-spawn` using npm:
16+
17+
```bash
18+
npm install python-spawn
19+
```
20+
21+
## Usage
22+
23+
### Basic Usage
24+
25+
```javascript
26+
const { PythonExecutor } = require("python-spawn");
27+
28+
// Creating an Instance
29+
const executor = new PythonExecutor();
30+
31+
// Executing a Python Script
32+
executor
33+
.executeScript("/path/to/your/script.py")
34+
.then((result) => console.log(result))
35+
.catch((error) => console.error(error));
36+
37+
// Executing a Python Function withing a Script
38+
executor
39+
.executeScript("/path/to/your/script.py", "function_name", ["arg1", "arg2"])
40+
.then((result) => console.log(result))
41+
.catch((error) => console.error(error));
42+
```
43+
44+
## Contributing
45+
46+
Contributions are welcome! Please refer to the [Contributing Guidelines](CONTRIBUTING.md) for detailed information.
47+
48+
## License
49+
50+
This project is licensed under the [MIT License](LICENSE).

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy