Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ethern-myth/py-em-node
`py-em-node` is a Node.js package designed to facilitate the execution and management of Python scripts within a Node.js environment.
https://github.com/ethern-myth/py-em-node
node python
Last synced: about 1 month ago
JSON representation
`py-em-node` is a Node.js package designed to facilitate the execution and management of Python scripts within a Node.js environment.
- Host: GitHub
- URL: https://github.com/ethern-myth/py-em-node
- Owner: Ethern-Myth
- License: mit
- Created: 2024-03-01T10:23:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-13T18:57:56.000Z (10 months ago)
- Last Synced: 2024-12-02T09:05:51.514Z (about 1 month ago)
- Topics: node, python
- Language: TypeScript
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# py-em-node
[![npm downloads](https://img.shields.io/npm/dm/py-em-node)](https://www.npmjs.com/package/py-em-node)
## Introduction
`py-em-node` is a Node.js package designed to facilitate the execution and management of Python scripts within a Node.js environment. It provides functions to install Python, read configuration files, and execute Python scripts seamlessly.
## Installation
You can install `py-em-node` via npm, yarn or pnpm:
```bash
npm install py-em-node
OR
pnpm add py-em-node
OR
yarn add py-em-node
```## Usage
### Package.json OR Command-Line Interface (CLI)
`py-em-node` offers a command-line interface (CLI) or package.json for executing scripts directly from the terminal.
#### Example Usage
For this: Follow the Configuration Options as well
```bash
py-em-node start
```OR
```json
"scripts": {
"start": "py-em-node start"
},
``````bash
npm run start
OR
pnpm start
OR
yarn start
```This command will execute the Python script specified as the entry point in the configuration file.
**Check out this video for quick sample usage**:
[![Py-em-node-sample-video](https://img.youtube.com/vi/ByRaGhVCKPQ/0.jpg)](https://www.youtube.com/watch?v=ByRaGhVCKPQ)
### Configuration
`py-em-node` supports configuration through a JSON file named `python.config.json`. **TSON file** `python.config.tson` will be removed in the next upcoming version.
Place this file in the root directory of your project.#### Configuration Options
- `entryPoint`: Specifies the entry point Python file (default: `app.py`).
- `usePythonThree`: Specifies the use of python3 if installed on system#### Example Configuration File (python.config.json)
```json
{
"entryPoint": "main.py",
}
```If using python3, and/or already installed
```json
{
"entryPoint": "main.py",
"usePythonThree": true
}
```## API Reference
### executeScript(script: string): Promise
Executes the specified Python script based on the provided script name.
- `script`: Name of the script to execute.
### readConfig(): Config
Reads the configuration from the `python.config.json` file and returns the configuration object.
### executePythonScript(scriptPath: string, args: string[]): void
Executes the Python script located at the specified path with the provided arguments.
- `scriptPath`: Path to the Python script.
- `args`: Array of arguments to pass to the Python script.## License
This package is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
## Acknowledgements
- This package was inspired by the need to seamlessly integrate Python scripts into Node.js applications.
---
**Note:** Make sure to have Python installed on your system before using this package.
## Credits
[Ethern Myth](https://github.com/ethern-myth)
## 🎯 The following features are planned for future support
- Allow user to enter the requirement.txt, and let this handle the installation.
- Add support for command support that execute a script or starts a project.
- More to be added.