Skip to content
Draft
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
16 changes: 14 additions & 2 deletions .github/workflows/deploy-github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
environment-file: environment-wasm-build.yml
init-shell: bash
environment-name: xeus-python-wasm-build

- name: Set ncpus
run: echo "ncpus=$(nproc --all)" >> $GITHUB_ENV

Expand All @@ -47,6 +47,12 @@ jobs:

set -eux


URL=https://github.com/DerThorsten/xeus-python-shell/archive/refs/heads/libuv.zip
curl -L $URL -o xeus-python-shell-libuv.zip
unzip xeus-python-shell-libuv.zip


export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-python-wasm-host
echo "PREFIX=$PREFIX" >> $GITHUB_ENV

Expand All @@ -60,13 +66,19 @@ jobs:

emmake make -j${{ env.ncpus }} install




- name: Jupyter Lite integration
shell: bash -l {0}
run: |
THIS_DIR=$(pwd)
jupyter lite build \
--XeusAddon.prefix=${{ env.PREFIX }} \
--contents notebooks/ \
--output-dir dist
--output-dir dist \
--XeusAddon.mounts=$THIS_DIR/xeus-python-shell-libuv/xeus_python_shell/:/lib/python3.13/site-packages/xeus_python_shell/


- name: Upload artifact
uses: actions/upload-pages-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-13, macos-14]
os: [ubuntu-22.04, ubuntu-24.04, macos-14]
build_type: [static_build, shared_build]

steps:
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ else ()
if (NOT TARGET xeus-zmq AND NOT TARGET xeus-zmq-static)
find_package(xeus-zmq ${xeus-zmq_REQUIRED_VERSION} REQUIRED)
endif ()

find_package(xeus-uv REQUIRED)
find_library(UVW_LIBRARY uvw)
find_path(UVW_INCLUDE_DIR uvw.hpp)
endif()



# Configuration
# =============

Expand Down Expand Up @@ -163,6 +169,7 @@ set(XEUS_PYTHON_SRC
src/xdebugpy_client.cpp
src/xdisplay.cpp
src/xdisplay.hpp
src/xhook.cpp
src/xinput.cpp
src/xinput.hpp
src/xinspect.cpp
Expand All @@ -188,6 +195,7 @@ set(XEUS_PYTHON_HEADERS
include/xeus-python/xinterpreter_raw.hpp
include/xeus-python/xtraceback.hpp
include/xeus-python/xutils.hpp
include/xeus-python/xhook.hpp
)

set(XPYTHON_SRC
Expand Down Expand Up @@ -317,7 +325,10 @@ macro(xpyt_create_target target_name src headers linkage output_name)
set(XPYT_XEUS_TARGET xeus-zmq-static)
endif ()

target_link_libraries(${target_name} PUBLIC ${XPYT_XEUS_TARGET} PRIVATE pybind11::pybind11 pybind11_json)
target_link_libraries(${target_name}
PUBLIC ${XPYT_XEUS_TARGET} ${UVW_LIBRARY}
PRIVATE pybind11::pybind11 pybind11_json
)
if (WIN32 OR CYGWIN)
target_link_libraries(${target_name} PRIVATE ${PYTHON_LIBRARIES})
elseif (APPLE)
Expand Down Expand Up @@ -371,7 +382,7 @@ endif ()

if (XPYT_BUILD_XPYTHON_EXECUTABLE)
add_executable(xpython ${XPYTHON_SRC})
target_link_libraries(xpython PRIVATE pybind11::embed)
target_link_libraries(xpython PRIVATE xeus-uv pybind11::embed )

xpyt_set_common_options(xpython)
xpyt_set_kernel_options(xpython)
Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- python <3.13
- xeus-python-shell>=0.6.3,<0.7
- debugpy>=1.6.5
- libuvw
- ipython
# Test dependencies
- pytest
Expand Down
2 changes: 2 additions & 0 deletions environment-wasm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ dependencies:
- jupyterlite-core >0.6
- jupyter_server
- jupyterlite-xeus
- # widgets
- ipywidgets
4 changes: 3 additions & 1 deletion environment-wasm-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ dependencies:
- numpy
- xeus-lite
- xeus
- xeus-python-shell>=0.6.3
- pyjs >=2,<3
- libpython
- zstd
- openssl
- xz
- ipywidgets
# - xeus-python-shell>=0.6.3

52 changes: 52 additions & 0 deletions include/xeus-python/xhook.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (c) 2018, Martin Renou, Johan Mabille, Sylvain Corlay, and *
* Wolf Vollprecht *
* Copyright (c) 2018, QuantStack
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XPYT_HOOK_HPP
#define XPYT_HOOK_HPP

// pybind11 code internally forces hidden visibility on all internal code, but
// if non-hidden (and thus exported) code attempts to include a pybind type
// this warning occurs:
// 'xpyt::hook' declared with greater visibility than the type of its
// field 'xpyt::hook::p_acquire' [-Wattributes]
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wattributes"
#endif

#include "xeus-python/xeus_python_config.hpp"
#include "xeus-uv/xhook_base.hpp"

#include "pybind11/embed.h"
#include "pybind11/pybind11.h"

namespace py = pybind11;

namespace xpyt
{
XEUS_PYTHON_API
class hook : public xeus::xhook_base
{
public:

hook() = default;
virtual ~hook();

private:

void pre_hook_impl() override;
void post_hook_impl() override;
void run_impl(std::shared_ptr<uvw::loop> loop) override;

py::gil_scoped_acquire* p_acquire{ nullptr};
};

}

#endif
16 changes: 15 additions & 1 deletion include/xeus-python/xinterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,28 @@ namespace xpyt
// is started, m_release_gil_at_startup has to be set to false to prevent
// releasing it again in configure_impl().
//
bool m_release_gil_at_startup = true;
bool m_release_gil_at_startup = false;
gil_scoped_release_ptr m_release_gil = nullptr;

bool m_redirect_output_enabled;
bool m_redirect_display_enabled;

private:

// helper methods:
void execute_request_impl_sync(send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config config,
nl::json user_expressions);

void execute_request_impl_async(send_reply_callback cb,
int execution_counter,
const std::string& code,
xeus::execute_request_config config,
nl::json user_expressions);


virtual void instanciate_ipython_shell();
virtual bool use_jedi_for_completion() const;
};
Expand Down
54 changes: 45 additions & 9 deletions notebooks/xeus-python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -28,18 +28,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"7921"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = 89\n",
"\n",
Expand All @@ -51,9 +73,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"<function print(*args, sep=' ', end='\\n', file=None, flush=False)>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print"
]
Expand Down Expand Up @@ -653,15 +686,18 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9 (XPython)",
"display_name": "Python 3.13 (XPython)",
"language": "python",
"name": "xpython"
},
"language_info": {
"codemirror_mode": "{\"name\": \"ipython\", \"version\": 3}",
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"version": "3.9.1"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.11"
}
},
"nbformat": 4,
Expand Down
Loading
Loading