Commit 3f3d7432 authored by Jérome Perrin's avatar Jérome Perrin

fixup! ERP5 py3: WIP ( all changes squashed )

parent df368467
......@@ -10,11 +10,12 @@ parts =
LDFLAGS = -L${hdf5:location}/lib -Wl,-rpath=${hdf5:location}/lib
CPPFLAGS = -I${hdf5:location}/include
LD_LIBRARY_PATH=${hdf5:location}/lib
HDF5_DIR=${hdf5:location}
[h5py]
recipe = zc.recipe.egg:custom
egg = h5py
setup-eggs =
setup-eggs =
${cython:egg}
${numpy:egg}
pkgconfig
......
......@@ -11,7 +11,7 @@ parts =
<= numpy-env
[ipython]
recipe = zc.recipe.egg:custom
recipe = zc.recipe.egg
egg = ipython
environment = ipython-env
setup-eggs =
......
......@@ -75,7 +75,7 @@ class ERP5Kernel(Kernel):
self.title = None
# Allowed HTTP request code list for making request to erp5 from Kernel
# This list should be to used check status_code before making requests to erp5
self.allowed_HTTP_request_code_list = range(500, 511)
self.allowed_HTTP_request_code_list = list(range(500, 511))
# Append request code 200 in the allowed HTTP status code list
self.allowed_HTTP_request_code_list.append(200)
......
......@@ -15,11 +15,11 @@
[instance-jupyter-notebook]
filename = instance.cfg.in
md5sum = fd7ed44da8d8723983b8666df2971a36
md5sum = 8760f6cbc16277f09cc575ad87bdd25b
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
md5sum = 9d579353b579b6e488ae6330c7f4ad68
md5sum = a4c4fc83f8fe2f18a851bbb4cd0d20c7
[jupyter-set-password]
filename = jupyter_set_password.cgi.jinja
......@@ -27,7 +27,7 @@ md5sum = ac10fbcf790bd8e58750cfdd069812d2
[erp5-kernel]
filename = ERP5kernel.py
md5sum = 7d5309fe79afbcb455c0d8181b42e56c
md5sum = da04b99b70b2e327c9e9b4cdd056098e
[kernel-json]
filename = kernel.json.jinja
......
......@@ -74,10 +74,13 @@ environment =
[jupyter-notebook-config]
recipe = slapos.recipe.template:jinja2
url = {{ jupyter_config_location }}/{{ jupyter_config_filename }}
output = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
output = ${directory:jupyter_config_dir}/jupyter_server_config.py
context =
raw config_cfg ${buildout:directory}/knowledge0.cfg
[jupyter-notebook-config:python2]
output = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
......@@ -100,7 +103,7 @@ erp5_kernel_dir = ${:jupyter_kernel_dir}/ERP5
# This part is called like this because knowledge0.write uses the part name for
# the section name in the config file.
recipe = slapos.cookbook:zero-knowledge.write
password =
password =
filename = knowledge0.cfg
[read-knowledge0]
......@@ -136,7 +139,7 @@ output = ${directory:erp5_kernel_dir}/kernel.json
context =
raw python_executable {{ python_executable }}
raw kernel_dir ${erp5-kernel:target-directory}/{{ erp5_kernel_filename }}
key erp5_url slapconfiguration:configuration.erp5-url
key erp5_url slapconfiguration:configuration.erp5-url
raw display_name ERP5
raw language_name python
......
......@@ -2,9 +2,13 @@
This script initializes Jupyter's configuration such as passwords and other
things. It is run by IPython hence why it can use functions like get_config().
'''
import ConfigParser
import six
from six.moves.configparser import ConfigParser
import random
from notebook.auth import passwd
if six.PY3:
from jupyter_server.auth import passwd
else:
from notebook.auth import passwd
import os
import ssl
......@@ -17,8 +21,8 @@ def random_password(length = 10):
knowledge_0 = '{{ config_cfg }}'
if not os.path.exists(knowledge_0):
print "Your software does <b>not</b> embed 0-knowledge. \
This interface is useless in this case</body></html>"
print ("Your software does <b>not</b> embed 0-knowledge.\n"
"This interface is useless in this case</body></html>")
exit(0)
c = get_config()
......@@ -33,10 +37,29 @@ if not parser.has_option("jupyter_notebook", "password") or \
parser.get("jupyter_notebook", "password") == "":
parser.set("jupyter_notebook", "password", random_password())
c.NotebookApp.password = passwd(parser.get("jupyter_notebook", "password"))
c.NotebookApp.ssl_options = {
c.ServerApp.password = passwd(parser.get("jupyter_notebook", "password"))
c.ServerApp.ssl_options = {
'ssl_version': ssl.PROTOCOL_TLSv1_2,
}
if 0 and six.PY3: # WIP
import pathlib
import jupyterlab
# JUPYTERLAB_DIR set to ~/jupyter/lab
jupyterlab_dir = pathlib.Path(os.environ['JUPYTERLAB_DIR'])
if not jupyterlab_dir.exists():
jupyterlab_dir.mkdir()
for d in 'schemas', 'static', 'themes':
local_dir = jupyterlab_dir / d
if not local_dir.exists():
dir_from_package = (pathlib.Path(jupyterlab.__file__).parent.parent / 'share' / 'jupyter' / 'lab' / d)
local_dir.symlink_to(dir_from_package)
if d == 'static':
c.ServerApp.extra_template_paths = str(local_dir)
# c.LabApp.extra_template_paths = str(local_dir)
# c.LabApp.static_url_prefix = 'static/lab'
# c.ServerApp.static_url_prefix = 'static/lab'
with open(knowledge_0, 'w') as file:
parser.write(file)
......@@ -21,7 +21,7 @@ environment = numpy-env
eggs = ${cython:egg}
[versions]
numpy = 1.22.0
numpy = 1.24.4
[numpy:sys.version_info < (3,8)]
depends =
......
......@@ -19,11 +19,11 @@ md5sum = 5f39952f94095b1f12f41db76867e71e
[instance-jupyter]
filename = instance-jupyter.cfg.in
md5sum = f9a0e5a134456d74ca8b4d87862f903d
md5sum = ab06344a4f52a7cc453b5d88176e8ee4
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
md5sum = 089e4c511a3c7b110471bf41ca2695a4
md5sum = 601efe6ee4c9e2712d03981c0da870b0
[erp5-kernel]
filename = ERP5kernel.py
......
......@@ -91,12 +91,11 @@ environment =
[jupyter-password]
recipe = slapos.cookbook:generate.password
bytes = 10
[jupyter-notebook-config]
recipe = slapos.recipe.template:jinja2
url = {{ jupyter_config_location }}/{{ jupyter_config_filename }}
output = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
output = ${directory:jupyter_config_dir}/jupyter_server_config.py
context =
key password jupyter-password:passwd
raw gcc_location {{ gcc_location }}
......@@ -171,13 +170,11 @@ instance-configuration =
[publish-connection-parameter]
recipe = slapos.cookbook:publish
jupyter-classic-url = ${request-slave-frontend:connection-secure_access}/tree
url = ${:jupyter-classic-url}
jupyterlab-url = ${request-slave-frontend:connection-secure_access}/lab
url = ${:jupyterlab-url}
{% if additional_frontend %}
jupyter-classic-url-additional = ${request-slave-frontend-additional:connection-secure_access}/tree
url-additional = ${:jupyter-classic-url-additional}
jupyterlab-url-additional = ${request-slave-frontend-additional:connection-secure_access}/lab
url-additional = ${:jupyterlab-url-additional}
{% endif %}
password = ${jupyter-password:passwd}
......@@ -194,7 +191,7 @@ output = ${directory:erp5_kernel_dir}/kernel.json
context =
raw python_executable {{ python_executable }}
raw kernel_dir ${erp5-kernel:target-directory}/{{ erp5_kernel_filename }}
key erp5_url slapconfiguration:configuration.erp5-url
key erp5_url slapconfiguration:configuration.erp5-url
raw display_name ERP5
raw language_name python
......
......@@ -2,13 +2,15 @@
This script initializes Jupyter's configuration such as passwords and other
things. It is run by IPython hence why it can use functions like get_config().
'''
import configparser
from notebook.auth import passwd
from jupyter_server.auth import passwd
import pathlib
import jupyterlab
import os
c = get_config()
c.NotebookApp.password = passwd("{{ password }}")
c.ServerApp.password = passwd("{{ password }}")
c.LabApp.app_dir = str(pathlib.Path(jupyterlab.__file__).parent.parent / 'share' / 'jupyter' / 'lab')
try:
os.environ['PATH'] = "{{ gcc_location }}/bin" + os.pathsep + os.environ['PATH']
......
......@@ -52,10 +52,9 @@ class TestJupyter(InstanceTestCase):
self.assertEqual(
{
'jupyter-classic-url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, ),
'jupyterlab-url': 'https://[%s]:8888/lab' % (self.computer_partition_ipv6_address, ),
'password': '%s' % (password, ),
'url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, )
'url': 'https://[%s]:8888/lab' % (self.computer_partition_ipv6_address, )
},
connection_dict
)
......@@ -63,7 +62,7 @@ class TestJupyter(InstanceTestCase):
result = requests.get(
connection_dict['url'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -71,15 +70,7 @@ class TestJupyter(InstanceTestCase):
connection_dict['jupyter-classic-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyterlab-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Flab'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -98,15 +89,7 @@ class TestJupyterAdditional(InstanceTestCase):
result = requests.get(
connection_dict['url'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyter-classic-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -121,15 +104,7 @@ class TestJupyterAdditional(InstanceTestCase):
result = requests.get(
connection_dict['url-additional'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyter-classic-url-additional'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -137,7 +112,7 @@ class TestJupyterAdditional(InstanceTestCase):
connection_dict['jupyterlab-url-additional'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Flab'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......
......@@ -798,7 +798,6 @@ Zope = 5.9+SlapOSPatched003
# Pinned versions
alabaster = 0.7.12
APacheDEX = 2.0
arrow = 1.2.3
astroid = 3.1.0:whl
Beaker = 1.11.0
cloudpickle = 0.5.3
......@@ -813,7 +812,6 @@ facebook-sdk = 2.0.0
five.formlib = 1.0.4
five.localsitemanager = 4.0
fpconst = 0.7.2
fqdn = 1.5.1
google-api-core = 2.17.1
google-api-python-client = 2.118.0
google-auth = 2.28.1
......@@ -826,11 +824,9 @@ huBarcode = 1.0.0+SlapOSPatched001
imageio = 2.34.0
interval = 1.0.0+SlapOSPatched001
ipdb = 0.10.2
isoduration = 20.11.0
isort = 5.13.2
jdcal = 1.3
jsonpickle = 0.9.6
jsonpointer = 2.2
lazy-object-proxy = 1.10.0
logilab-common = 1.3.0
Mako = 1.1.4
......@@ -849,7 +845,6 @@ oic = 1.6.1
olefile = 0.44
ordered-set = 4.1.0
Pillow = 10.2.0+SlapOSPatched001
platformdirs = 4.2.0:whl
polib = 1.2.0
pprofile = 2.0.4
Products.BTreeFolder2 = 4.4+SlapOSPatched001
......@@ -892,7 +887,6 @@ PyWavelets = 1.4.0
qrcode = 5.3
Record = 4.1.0
responses = 0.10.6
rfc3339-validator = 0.1.4
rfc3987 = 1.3.8
rsa = 3.4.2
scikit-image = 0.19.3
......@@ -903,17 +897,14 @@ StructuredText = 2.11.1
suds = 0.4
suds-py3 = 1.4.5.0
tifffile = 2024.2.12
tomli = 2.0.1:whl
tomlkit = 0.12.4:whl
toolz = 0.9.0
typed-ast = 1.5.5
typing = 3.10.0.0
unidiff = 0.5.5
uri-template = 1.2.0
urlnorm = 1.1.4+SlapOSPatched001
uuid = 1.30
validictory = 1.1.0
webcolors = 1.12
wrapt = 1.16.0
WSGIProxy2 = 0.4.6
WSGIUtils = 0.7
......@@ -1037,7 +1028,6 @@ zope.globalrequest = 1.6
zope.hookable = 5.4
zope.i18n = 4.9.0
zope.i18nmessageid = 5.1.1
zope.interface = 5.5.2
zope.lifecycleevent = 4.4
zope.location = 4.3
zope.pagetemplate = 4.6.0
......@@ -1056,8 +1046,6 @@ zope.structuredtext = 4.4
zope.tal = 4.5
zope.tales = 5.2
zope.testbrowser = 5.6.1
zope.testing = 4.10
zope.testrunner = 5.6
zope.traversing = 4.4.1
zope.viewlet = 4.3
ZServer = 4.0.2
......@@ -209,7 +209,7 @@ gitdb = 4.0.10
GitPython = 3.1.30
greenlet = 3.0.1
h11 = 0.14.0
h5py = 2.7.1
h5py = 3.11.0
httpcore = 1.0.4:whl
httplib2 = 0.22.0
httpx = 0.27.0:whl
......@@ -230,12 +230,14 @@ jedi = 0.17.2
Jinja2 = 3.1.2:whl
joblib = 1.3.2:whl
json5 = 0.9.20:whl
jsonpointer = 2.2
jsonschema = 4.17.3:whl
jupyter = 1.0.0
jupyter-client = 8.6.1:whl
jupyter-console = 6.6.3:whl
jupyter-core = 5.7.1:whl
jupyter-events = 0.6.3:whl
isoduration = 20.11.0
jupyter-lsp = 2.2.3:whl
jupyter-server = 2.10.0:whl
jupyter-server-terminals = 0.5.2:whl
......@@ -244,6 +246,8 @@ jupyterlab-launcher = 0.13.1
jupyterlab-pygments = 0.3.0:whl
jupyterlab-server = 2.24.0:whl
jupyterlab-widgets = 3.0.10:whl
arrow = 1.2.3
fqdn = 1.5.1
lock-file = 2.0
lockfile = 0.12.2:whl
lsprotocol = 2023.0.0b1:whl
......@@ -258,7 +262,7 @@ more-itertools = 5.0.0
mpmath = 1.3.0
msgpack = 1.0.5
multidict = 6.0.4
nbclient = 0.5.1
nbclient = 0.10.0:whl
nbconvert = 6.5.4
nbformat = 5.9.2:whl
nest-asyncio = 1.5.6
......@@ -282,6 +286,7 @@ pickleshare = 0.7.4
pim-dm = 1.4.0nxd002
pkgconfig = 1.5.1
pkgutil-resolve-name = 1.3.10
platformdirs = 4.2.0:whl
plone.recipe.command = 1.1
pluggy = 0.13.1:whl
ply = 3.11
......@@ -319,6 +324,7 @@ qtpy = 2.4.1:whl
random2 = 1.0.1
regex = 2020.9.27
requests = 2.31.0
rfc3339-validator = 0.1.4
rfc3986-validator = 0.1.1:whl
rpdb = 0.1.5
rubygemsrecipe = 0.4.4
......@@ -355,6 +361,7 @@ terminado = 0.9.1
testpath = 0.4.4
threadpoolctl = 3.3.0:whl
tinycss2 = 1.2.1:whl
tomli = 2.0.1:whl
tornado = 6.4
traitlets = 5.14.1:whl
trio = 0.22.0
......@@ -363,9 +370,11 @@ typeguard = 3.0.2:whl
typing-extensions = 4.8.0:whl
tzlocal = 1.5.1
unicodecsv = 0.14.1
uri-template = 1.2.0
uritemplate = 4.1.1
urllib3 = 1.26.12
wcwidth = 0.2.5
webcolors = 1.12
webencodings = 0.5.1
websocket-client = 1.5.1
websockets = 10.4
......@@ -414,6 +423,7 @@ gevent = 20.9.0
gitdb2 = 2.0.5
GitPython = 2.1.11
greenlet = 0.4.17
h5py = 2.7.1
idna = 2.9
importlib-metadata = 1.7.0:whl
ipykernel = 5.3.4:whl
......@@ -430,6 +440,7 @@ jupyterlab-pygments = 0.1.2
MarkupSafe = 1.0
mpmath = 1.0.0
msgpack = 0.6.2
nbclient = 0.5.1
notebook = 6.1.5
packaging = 16.8
prompt-toolkit = 3.0.19
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment