Skip to content

Add EMBEDPY_EXECUTABLE and EMBEDPY_PYTHON_LIB_PATH #120

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ q)

See [docker/README.md](docker/README.md) for more details.

## Configuration

- `EMBEDPY_EXECUTABLE` export this environment variable to define the Python executable for embedPy to use.
- If not set, embedPy attempts to use `python3` and then `python` from `PATH`.
- `EMBEDPY_PYTHON_LIB_PATH` export this environment variable to define the `libpython.so` for embedPy to use.
- Used in cases of `'libpython` error on load of EmbedPy when filepath is incorrect. See also [FAQ](./docs/faq.md#installing-embedpy-on-system-with-python-installed-from-source).

Example:

```bash
$export EMBEDPY_EXECUTABLE="/usr/bin/python"
$export EMBEDPY_PYTHON_LIB_PATH="/usr/lib/x86_64-linux-gnu/libpython3.10.so"
$q p.q
```

## Back-incompatible changes

Expand Down
10 changes: 6 additions & 4 deletions p.q
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ o:first string .z.o;
$[o="w";if[3.6>.z.K;'`$"kdb+ version must be 3.6+"];if[3.5>.z.K;'`$"kdb+ version must be 3.5+"]];
if[not .P.loaded:-1h=type@[`.p@;`numpy;`];
sc:{"'",x,"'.join([__import__('sysconfig').get_config_var(v)for v in",ssr[.j.j y;"\"";"'"],"])"};pr:{"print(",x,");"};
c:"-c \"",pr["'.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']])"],"\"2>",$[o="w";"nul <nul";"/dev/null"];
if[(o="w")and any 3 6>"J"$"." vs first@[system"python3 ",;c;{system"python ",c}];'"embedPy requires python 3.6 or higher on windows"];
c:"-c \"",pr[$[o="w";sc["/python";`BINDIR`VERSION];sc["/libpython";`LIBDIR`LDVERSION]],"+'",$[o="w";".dll";o="l";".so";".dylib"],"'"],pr["__import__('sys').base_prefix"],pr["__import__('sys').prefix"],pr["__import__('sys').executable"],"\"2>",$[o="w";"nul <nul";"/dev/null"];
`L`H`P`B set'@[system"python3 ",;c;{system"python ",c}];
c:"\"",pr["'.'.join([str(getattr(__import__('sys').version_info,x))for x in ['major','minor']])"],"\"2>",$[o="w";"nul <nul";"/dev/null"];
pyc:$[""~py:getenv`EMBEDPY_EXECUTABLE;{@[system"python3 -c",;x;{system"python -c",x}]};{system x," -c",y}[py]];
if[(o="w")and any 3 6>"J"$"." vs first pyc c;'"embedPy requires python 3.6 or higher on windows"];
c:"\"",pr[$[o="w";sc["/python";`BINDIR`VERSION];sc["/libpython";`LIBDIR`LDVERSION]],"+'",$[o="w";".dll";o="l";".so";".dylib"],"'"],pr["__import__('sys').base_prefix"],pr["__import__('sys').prefix"],pr["__import__('sys').executable"],"\"2>",$[o="w";"nul <nul";"/dev/null"];
`L`H`P`B set'pyc c;
if[not ""~lp:getenv`EMBEDPY_PYTHON_LIB_PATH;L:lp];
.P.env:not H~P;
.p:(`:./p 2:(`init;3))[L;H;B]]
loaded:.P.loaded
Expand Down