Skip to content

By default its not considering current working directory as source directory #8

Open
@rdev06

Description

@rdev06

create a file foo.py

and define a function

def greet(name: str):
    return 'greet ' + name

then within js file

import { python } from "bun_python";

const foo = python.import('foo')
console.log(foo.greet('yourself'))

This will throw an error.
I checked in sys.path, current working directory was not their.
For now the only possible way to use this by a workaround like this

import { python } from "bun_python";

// +++++++manually add current working directory into sys path++++++
const sys = python.import('sys');
sys.path.append(__dirname);

const foo = python.import('foo')
console.log(foo.greet('yourself'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions