File: buildapi.py

package info (click to toggle)
jupyterlab 4.0.11%2Bds1%2B~cs11.25.27-7
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 43,496 kB
  • sloc: javascript: 18,395; python: 8,932; sh: 399; makefile: 95; perl: 33; xml: 1
file content (38 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

# Custom build target that removes .js.map files for published
# dist files.
import glob
import json
import os
import subprocess

from hatch_jupyter_builder import npm_builder
from packaging.version import Version


def builder(target_name, version, *args, **kwargs):
    # Allow building from sdist without node.
    if target_name == "wheel" and not os.path.exists("dev_mode"):
        return

    npm_builder(target_name, version, *args, **kwargs)

    if version == "editable":
        return

    files = glob.glob("jupyterlab/static/*.js.map")
    for path in files:
        os.remove(path)

    target = glob.glob("jupyterlab/static/package.json")[0]
    with open(target) as fid:
        npm_version = json.load(fid)["jupyterlab"]["version"]

    py_version = subprocess.check_output(["hatchling", "version"])  # noqa S603 S607
    py_version = py_version.decode("utf-8").strip()

    if Version(npm_version) != Version(py_version):
        msg = "Version mismatch, please run `npm run prepare:python-release`"
        raise ValueError(msg)