Skip to content

Commit

Permalink
Backport PR #16314: Run Python tests on MacOS with Python 12, replace…
Browse files Browse the repository at this point in the history
… `canvas` with `jest-canvas-mock` (#16501)
  • Loading branch information
krassowski authored Jun 19, 2024
1 parent d3897d2 commit 7b80cf9
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 86 deletions.
13 changes: 0 additions & 13 deletions docs/source/developer/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,6 @@ Notes:
called something else (such as "python3") then parts of the build
will fail. You may wish to build in a conda environment, or make an
alias.
- Some of the packages used in the development environment require
Python 3.0 or higher. If you encounter an ImportError during the
installation, make sure Python 3.0+ is installed. Also, try using the
Python 3.0+ version of ``pip`` or ``pip3 install -e .`` command to
install JupyterLab from the forked repository.
- If you see an error that says ``Call to 'pkg-config pixman-1 --libs'
returned exit status 127 while in binding.gyp`` while running the
``pip install`` command above, you may be missing packages required
by ``canvas``. On macOS with Homebrew, you can add these packages by
running
``brew install pkg-config cairo pango libpng jpeg giflib librsvg``.
If you are using mamba or conda, you can install the necessary packages
with `conda install -c conda-forge pkg-config glib pango pixman`.
- The ``jlpm`` command is a JupyterLab-provided, locked version of the
`yarn <https://classic.yarnpkg.com/en/>`__ package manager. If you have
``yarn`` installed already, you can use the ``yarn`` command when
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/csvviewer/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

const func = require('@jupyterlab/testutils/lib/jest-config');
const config = func(__dirname);
module.exports = func(__dirname);
config['setupFiles'].push('jest-canvas-mock');
module.exports = config;
2 changes: 1 addition & 1 deletion packages/csvviewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"devDependencies": {
"@jupyterlab/testutils": "^3.6.7",
"@types/jest": "^26.0.10",
"canvas": "^2.6.1",
"csv-spectrum": "^1.0.0",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.5.2",
"rimraf": "~3.0.0",
"ts-jest": "^26.3.0",
"typedoc": "~0.21.2",
Expand Down
9 changes: 8 additions & 1 deletion packages/debugger/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

const func = require('@jupyterlab/testutils/lib/jest-config');
module.exports = func(__dirname);
const config = func(__dirname);
config['setupFiles'].push('jest-canvas-mock');
module.exports = config;
2 changes: 1 addition & 1 deletion packages/debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
"@types/jest": "^26.0.10",
"@types/react-dom": "^17.0.0",
"@types/text-encoding": "^0.0.35",
"canvas": "^2.6.1",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.5.2",
"jest-junit": "^11.1.0",
"jest-raw-loader": "^1.0.1",
"jest-summary-reporter": "^0.0.2",
Expand Down
9 changes: 8 additions & 1 deletion packages/terminal/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

const func = require('@jupyterlab/testutils/lib/jest-config');
module.exports = func(__dirname);
const config = func(__dirname);
config['setupFiles'].push('jest-canvas-mock');
module.exports = config;
2 changes: 1 addition & 1 deletion packages/terminal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"devDependencies": {
"@jupyterlab/testutils": "^3.6.7",
"@types/jest": "^26.0.10",
"canvas": "^2.6.1",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.5.2",
"rimraf": "~3.0.0",
"ts-jest": "^26.3.0",
"typedoc": "~0.21.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/vega5-extension/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
*/

const func = require('@jupyterlab/testutils/lib/jest-config');
module.exports = func(__dirname);
const config = func(__dirname);
config['setupFiles'].push('jest-canvas-mock');
module.exports = config;
1 change: 1 addition & 0 deletions packages/vega5-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@types/jest": "^26.0.10",
"@types/webpack-env": "^1.14.1",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.5.2",
"rimraf": "~3.0.0",
"typedoc": "~0.21.2",
"typescript": "~4.1.3"
Expand Down
29 changes: 29 additions & 0 deletions packages/vega5-extension/test/renderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ describe('@jupyterlab/vega5-extension', () => {

expect(model).toHaveProperty('data.image/png');
expect(model).not.toHaveProperty(SCALE_FACTOR_PROP);
});

// requires `canvas`
it.skip('should keep size of PNG', async () => {
const model = new MimeModel({
data: {
[VEGALITE4_MIME_TYPE]: VEGALITE4_SPEC
}
});
await VEGALITE4_RENDERER.renderModel(model);

const size = getPNGSize(model.data['image/png'] as string);

Expand All @@ -49,6 +59,25 @@ describe('@jupyterlab/vega5-extension', () => {

expect(model).toHaveProperty('data.image/png');
expect(model).toHaveProperty(SCALE_FACTOR_PROP, scaleFactor);
});

// requires `canvas`
it.skip('should resize scaled PNG', async () => {
const scaleFactor = 2;

const model = new MimeModel({
data: {
[VEGALITE4_MIME_TYPE]: VEGALITE4_SPEC
},
metadata: {
[VEGALITE4_MIME_TYPE]: {
embed_options: {
scaleFactor
}
}
}
});
await VEGALITE4_RENDERER.renderModel(model);

const size = getPNGSize(model.data['image/png'] as string);

Expand Down
88 changes: 23 additions & 65 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2241,21 +2241,6 @@
"@lumino/signaling" "^1.11.1"
"@lumino/virtualdom" "^1.14.3"

"@mapbox/node-pre-gyp@^1.0.0":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz#2a0b32fcb416fb3f2250fd24cb2a81421a4f5950"
integrity sha512-4srsKPXWlIxp5Vbqz5uLfBN+du2fJChBoYn/f2h991WLdk7jUvcSk/McVLSv/X+xQIPI8eGD5GjrnygdyHnhPA==
dependencies:
detect-libc "^1.0.3"
https-proxy-agent "^5.0.0"
make-dir "^3.1.0"
node-fetch "^2.6.1"
nopt "^5.0.0"
npmlog "^4.1.2"
rimraf "^3.0.2"
semver "^7.3.4"
tar "^6.1.0"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
Expand Down Expand Up @@ -4390,7 +4375,7 @@ abab@^2.0.3, abab@^2.0.5:
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a"
integrity sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==

abbrev@1, abbrev@^1.0.0:
abbrev@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==
Expand Down Expand Up @@ -5849,15 +5834,6 @@ canonicalize@^1.0.1:
resolved "https://registry.yarnpkg.com/canonicalize/-/canonicalize-1.0.5.tgz#b43b390ce981d397908bb847c3a8d9614323a47b"
integrity sha512-mAjKJPIyP0xqqv6IAkvso07StOmz6cmGtNDg3pXCSzXVZOqka7StIkAhJl/zHOi4M2CgpYfD6aeRWbnrmtvBEA==

canvas@^2.6.1:
version "2.11.0"
resolved "https://registry.yarnpkg.com/canvas/-/canvas-2.11.0.tgz#7f0c3e9ae94cf469269b5d3a7963a7f3a9936434"
integrity sha512-bdTjFexjKJEwtIo0oRx8eD4G2yWoUOXP9lj279jmQ2zMnTQhT8C3512OKz3s+ZOaQlLbE7TuVvRDYDB3Llyy5g==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.0"
nan "^2.17.0"
simple-get "^3.0.3"

capture-exit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4"
Expand Down Expand Up @@ -6238,7 +6214,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=

color-name@^1.0.0, color-name@~1.1.4:
color-name@^1.0.0, color-name@^1.1.4, color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
Expand Down Expand Up @@ -6885,6 +6861,11 @@ cssesc@^3.0.0:
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==

cssfontparser@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/cssfontparser/-/cssfontparser-1.2.1.tgz#f4022fc8f9700c68029d542084afbaf425a3f3e3"
integrity sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==

csso@^4.0.2:
version "4.2.0"
resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529"
Expand Down Expand Up @@ -7154,13 +7135,6 @@ decompress-response@^3.3.0:
dependencies:
mimic-response "^1.0.0"

decompress-response@^4.2.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-4.2.1.tgz#414023cc7a302da25ce2ec82d0d5238ccafd8986"
integrity sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==
dependencies:
mimic-response "^2.0.0"

dedent@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
Expand Down Expand Up @@ -7315,11 +7289,6 @@ detect-indent@^6.0.0:
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6"
integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==

detect-libc@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=

[email protected], detect-newline@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
Expand Down Expand Up @@ -10377,6 +10346,14 @@ jake@^10.6.1:
filelist "^1.0.1"
minimatch "^3.0.4"

jest-canvas-mock@^2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/jest-canvas-mock/-/jest-canvas-mock-2.5.2.tgz#7e21ebd75e05ab41c890497f6ba8a77f915d2ad6"
integrity sha512-vgnpPupjOL6+L5oJXzxTxFrlGEIbHdZqFU+LFNdtLxZ3lRDCl17FlTMM7IatoRQkrcyOTMlDinjUguqmQ6bR2A==
dependencies:
cssfontparser "^1.2.1"
moo-color "^1.0.2"

jest-changed-files@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.2.tgz#f6198479e1cc66f22f9ae1e22acaa0b429c042d0"
Expand Down Expand Up @@ -11979,11 +11956,6 @@ mimic-response@^1.0.0, mimic-response@^1.0.1:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b"
integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==

mimic-response@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-2.1.0.tgz#d13763d35f613d09ec37ebb30bac0469c0ee8f43"
integrity sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==

min-document@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
Expand Down Expand Up @@ -12183,6 +12155,13 @@ moment@^2.24.0:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==

moo-color@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/moo-color/-/moo-color-1.0.3.tgz#d56435f8359c8284d83ac58016df7427febece74"
integrity sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==
dependencies:
color-name "^1.1.4"

move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
Expand Down Expand Up @@ -12245,7 +12224,7 @@ [email protected]:
ncp "~2.0.0"
rimraf "~2.4.0"

nan@^2.12.1, nan@^2.17.0:
nan@^2.12.1:
version "2.17.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb"
integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==
Expand Down Expand Up @@ -12424,13 +12403,6 @@ node-releases@^1.1.52, node-releases@^1.1.71:
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20"
integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==

nopt@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
integrity sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==
dependencies:
abbrev "1"

nopt@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-6.0.0.tgz#245801d8ebf409c6df22ab9d95b65e1309cdb16d"
Expand Down Expand Up @@ -15019,20 +14991,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==

simple-concat@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f"
integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==

simple-get@^3.0.3:
version "3.1.0"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-3.1.0.tgz#b45be062435e50d159540b576202ceec40b9c6b3"
integrity sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==
dependencies:
decompress-response "^4.2.0"
once "^1.3.1"
simple-concat "^1.0.0"

simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
Expand Down

0 comments on commit 7b80cf9

Please sign in to comment.