Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Bun #305

Open
exKAZUu opened this issue May 11, 2024 · 2 comments
Open

Support Bun #305

exKAZUu opened this issue May 11, 2024 · 2 comments
Labels

Comments

@exKAZUu
Copy link

exKAZUu commented May 11, 2024

Describe the bug
python-shell doesn't work on Bun.

Python code
See the below.

Javascript code
https://github.com/extrabacon/python-shell#running-python-code

import { PythonShell } from 'python-shell';

PythonShell.runString('x=1+1;print(x)', null).then((messages) => {
  console.log('finished');
});

Expected behavior
2 is shown.

Actual behavior

$ bun example.js
128 |         this.stderrParser = resolve('parse', options.stderrParser || 'text');
129 |         this.terminated = false;
130 |         this.childProcess = (0, child_process_1.spawn)(pythonPath, this.command, options);
131 |         ['stdout', 'stdin', 'stderr'].forEach(function (name) {
132 |             self[name] = self.childProcess[name];
133 |             self.parser && self[name] && self[name].setEncoding(options.encoding || 'utf8');
                                               ^
TypeError: self[name].setEncoding is not a function. (In 'self[name].setEncoding(options.encoding || "utf8")', 'self[name].setEncoding' is undefined)
      at /Users/exkazuu/ghq/github.com/WillBoosterLab/repair-ai/node_modules/python-shell/index.js:133:42
      at forEach (:1:21)
      at new PythonShell (/Users/exkazuu/ghq/github.com/WillBoosterLab/repair-ai/node_modules/python-shell/index.js:131:9)
      at /Users/exkazuu/ghq/github.com/WillBoosterLab/repair-ai/node_modules/python-shell/index.js:252:27
      at new Promise (:1:21)
      at run (/Users/exkazuu/ghq/github.com/WillBoosterLab/repair-ai/node_modules/python-shell/index.js:251:16)
      at /Users/exkazuu/ghq/github.com/WillBoosterLab/repair-ai/example.js:3:1

Bun v1.1.8 (macOS arm64)

Other Information (please complete the following information):

  • OS: macOS
  • Python Version 3.12.3
  • Node Version Bun v1.1.8 (macOS arm64)

Additional context
Nothing.

@exKAZUu exKAZUu added the bug label May 11, 2024
@Almenon
Copy link
Collaborator

Almenon commented May 11, 2024

This looks like a bug with Bun, not python-shell. Bun should be support nodeJS functions, it's supposed to be compatible. I'll open up a issue there.

@Almenon
Copy link
Collaborator

Almenon commented May 11, 2024

Created an issue over at oven-sh/bun#11011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants