Skip to content

Commit

Permalink
rename to be more like PyPI api
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Nov 18, 2021
1 parent 8128dbd commit 5e9b97d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ index.template.js
config-utils.js

# generated
**/_wheels.ts
**/_pypi.ts
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ parts/
sdist/
var/
wheels/
_wheels.ts
pypi/
_pypi.ts
pip-wheel-metadata/
share/python-wheels/
.installed.cfg
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bootstrap.js
index.template.js

# generated
_wheels.ts
_pypi.ts

# The changelog is updated by the releaser
CHANGELOG.md
2 changes: 1 addition & 1 deletion app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ module.exports = [
module: {
rules: [
{
test: /wheels\/.*/,
test: /pypi\/.*/,
type: 'asset/resource'
},
{
Expand Down
18 changes: 10 additions & 8 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,9 @@ class B:
DIST = P.ROOT / "dist"
APP_PACK = DIST / f"""{C.NAME}-app-{D.APP_VERSION}.tgz"""
PYOLITE_JS = P.ROOT / "packages/pyolite-kernel"
PYOLITE_WHEELS = PYOLITE_JS / "wheels"
PYOLITE_WHEELS = PYOLITE_JS / "pypi"
PYOLITE_WHEEL_INDEX = PYOLITE_WHEELS / "all.json"
PYOLITE_WHEEL_TS = PYOLITE_JS / "src/_wheels.ts"
PYOLITE_WHEEL_TS = PYOLITE_JS / "src/_pypi.ts"
PY_APP_PACK = P.ROOT / "py" / C.NAME / "src" / C.NAME / APP_PACK.name

EXAMPLE_DEPS = BUILD / "depfinder"
Expand All @@ -910,7 +910,7 @@ class B:
DOCS_APP = BUILD / "docs-app"
DOCS_APP_SHA256SUMS = DOCS_APP / "SHA256SUMS"
DOCS_APP_ARCHIVE = DOCS_APP / f"""jupyterlite-docs-{D.APP_VERSION}.tgz"""
DOCS_APP_WHEEL_INDEX = DOCS_APP / "lab/wheels/all.json"
DOCS_APP_WHEEL_INDEX = DOCS_APP / "lab/pypi/all.json"
DOCS_APP_JS_BUNDLE = DOCS_APP / "lab/build/bundle.js"

DOCS = Path(os.environ.get("JLITE_DOCS_OUT", P.DOCS / "_build"))
Expand Down Expand Up @@ -1411,17 +1411,19 @@ def make_pyolite_wheel_js():
"// this file is autogenerated from the wheels described in ../package.json",
"export * as allJSONUrl from '!!file-loader"
""
"?name=wheels/[name].[ext]"
"&context=.!../wheels/all.json';",
"?name=pypi/[name].[ext]"
"&context=.!../pypi/all.json';",
]
for wheel in B.PYOLITE_WHEELS.glob(f"*{C.NOARCH_WHL}"):
# this might be brittle
name = wheel.name.split("-")[0]
bang = f"!../wheels/{wheel.name}"
if name == "piplite":
lines += [f"export const PIPLITE_WHEEL = '{wheel.name}';"]
bang = f"!../pypi/{wheel.name}"
lines += [
f"export * as {name}Url from '!!file-loader"
f"export * as {name}WheelUrl from '!!file-loader"
""
f"?name=wheels/[name].[ext]&context=.{bang}';"
f"?name=pypi/[name].[ext]&context=.{bang}';"
]
B.PYOLITE_WHEEL_TS.write_text("\n".join(sorted(lines) + [""]))

Expand Down
2 changes: 1 addition & 1 deletion examples/jupyter_lite_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"https://files.pythonhosted.org/packages/py3/n/nbclient/nbclient-0.5.8-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/n/nbconvert/nbconvert-6.3.0-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/n/nest-asyncio/nest_asyncio-1.5.1-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/n/notebook/notebook-6.4.5-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/n/notebook/notebook-6.4.6-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/p/prompt-toolkit/prompt_toolkit-3.0.22-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/s/setuptools-scm/setuptools_scm-6.3.2-py3-none-any.whl",
"https://files.pythonhosted.org/packages/py3/t/tenacity/tenacity-8.0.1-py3-none-any.whl",
Expand Down
2 changes: 1 addition & 1 deletion packages/pyolite-kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"lib/*.js",
"style/*.css",
"style/index.js",
"src/wheels/*.{json,whl}"
"pypi/*.{json,whl}"
],
"scripts": {
"build": "yarn run build:lib",
Expand Down
14 changes: 9 additions & 5 deletions packages/pyolite-kernel/src/kernel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { URLExt } from '@jupyterlab/coreutils';
import { URLExt, PageConfig } from '@jupyterlab/coreutils';

import { KernelMessage } from '@jupyterlab/services';

Expand All @@ -8,7 +8,7 @@ import { PromiseDelegate } from '@lumino/coreutils';

import worker from './worker?raw';

import { pipliteUrl, allJSONUrl } from './_wheels';
import { PIPLITE_WHEEL } from './_pypi';

/**
* A kernel that executes Python code with Pyodide.
Expand Down Expand Up @@ -42,9 +42,13 @@ export class PyoliteKernel extends BaseKernel implements IKernel {

const indexUrl = pyodideUrl.slice(0, pyodideUrl.lastIndexOf('/') + 1);

const pipliteWheel = (pipliteUrl as unknown) as string;
const pipliteWheelUrl = URLExt.join(window.location.origin, pipliteWheel);
const pipliteUrls = [allJSONUrl, ...(options.pipliteUrls || [])];
const { origin } = window.location;

const pypi = URLExt.join(origin, PageConfig.getOption('appUrl'), 'build/pypi');

const pipliteUrls = [...(options.pipliteUrls || []), URLExt.join(pypi, 'all.json')];

const pipliteWheelUrl = URLExt.join(pypi, PIPLITE_WHEEL);

return [
// first we need the pyodide initialization scripts...
Expand Down
2 changes: 1 addition & 1 deletion py/jupyterlite/src/jupyterlite/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
NOARCH_WHL = "py3-none-any.whl"

#: where we put wheels, for now
LAB_WHEELS = "lab/wheels"
LAB_WHEELS = "lab/pypi"

### URLs

Expand Down
4 changes: 2 additions & 2 deletions py/jupyterlite/src/jupyterlite/tests/test_piplite.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def test_piplite_urls(
"@jupyterlite/pyolite-kernel-extension:kernel"
]["pipliteUrls"], "bad wheel urls"

wheel_out = output / "lab/wheels"
wheel_out = output / "lab/pypi"
assert (wheel_out / WHEELS[0].name).exists()
wheel_index = output / "lab/wheels/all.json"
wheel_index = output / "lab/pypi/all.json"
wheel_index_text = wheel_index.read_text(encoding="utf-8")
assert WHEELS[0].name in wheel_index_text, wheel_index_text

Expand Down

0 comments on commit 5e9b97d

Please sign in to comment.