Skip to content

build: refactor build strategy #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e8600dd
build: move information to pyproject.toml
12rambau Apr 21, 2023
5a0b012
refactor: move more things to pyproject.toml
12rambau Apr 21, 2023
9d551db
refactor: move bdist_wheel config to pyproject.toml
12rambau Apr 21, 2023
d4af14a
refactor: file cleaning
12rambau Apr 21, 2023
67abd19
build: update the gitignore with all the generated files
12rambau Apr 21, 2023
703dde7
refactor: use pathlib in generate_source
12rambau Apr 21, 2023
79b60df
fix: set the path in sys explicitely
12rambau Apr 25, 2023
c96795e
build: manage files that should be included in the distrib
12rambau Apr 25, 2023
24d3623
refactor: avoid using single used class
12rambau Apr 26, 2023
69549be
build: add js folder to manifest.in
12rambau Apr 26, 2023
933e7c3
build: fix action build
12rambau Apr 26, 2023
5e5ca6a
Merge branch 'master' into install
12rambau Apr 26, 2023
4ce25a8
build(deps): set playwrite and solara in pyproject.toml
12rambau Apr 26, 2023
825b055
test: update actions
12rambau Apr 26, 2023
7aa421e
build: run CI in parralel
12rambau Apr 26, 2023
dc8aa2f
test(CI): reintroduce a wheel build test
12rambau Apr 26, 2023
2ea00a7
build: restore export artifacts
12rambau Apr 26, 2023
54ed8eb
build: use the build wheel in the CI
12rambau Apr 26, 2023
bb2167d
refactor: prettier
12rambau Apr 26, 2023
e548b0b
refactor: typo
12rambau Apr 26, 2023
0315b3f
build: wheel file cannot be renamed
12rambau Apr 26, 2023
9d7996e
build: add legacy provider node option to actions
12rambau Apr 27, 2023
1213eb5
build: us node12
12rambau Apr 27, 2023
3e335dd
build: typo
12rambau Apr 27, 2023
7c870bf
build: use node 16
12rambau Apr 27, 2023
b9bd30d
build: use node 16
12rambau Apr 27, 2023
ef98fda
refactor: typo
12rambau Apr 27, 2023
11ac604
buimd: only install npm packages upon egg-info creation
12rambau Apr 27, 2023
ad5f5eb
refactor: remove the test notebook
12rambau Jun 13, 2023
23c1b9b
Update .gitignore
12rambau Aug 21, 2023
e84b4b2
fix: pin ubuntu version in CI
12rambau Aug 21, 2023
f996604
fix: restore binder requirements
12rambau Aug 21, 2023
f3980bb
build: support Python from 3.6 to 3.11
12rambau Aug 21, 2023
0140143
build(ci): use the default install for ui-test
12rambau Aug 21, 2023
1ec1816
Revert "build(ci): use the default install for ui-test"
mariobuikhuizen Aug 21, 2023
95cb6b4
build(ci): fix test job for python 3.6 by removing playwright dep
mariobuikhuizen Aug 21, 2023
cfdeaaf
build(ci): fix failing Jupyter Lab ui test
mariobuikhuizen Aug 21, 2023
d6c7200
build(ci): fix "no such kernel" error on readthedocs
mariobuikhuizen Aug 21, 2023
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
102 changes: 39 additions & 63 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,77 @@ on:
- workflow_dispatch

jobs:
build:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
python-version: "3.10"
- uses: pre-commit/[email protected]

- name: Install Python
uses: actions/setup-python@v2
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel jupyter-packaging jupyterlab

- name: Build
run: |
python setup.py generate_source
python setup.py sdist bdist_wheel

- name: Build
run: |
cd js
npm pack

- name: Upload builds
uses: actions/upload-artifact@v3
python-version: "3.10"
# https://github.com/webpack/webpack/issues/14532
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: install build
run: python -m pip install build
- name: build wheel
run: python -m build
- uses: actions/upload-artifact@v3
with:
name: ipyvuetify-dist-${{ github.run_number }}
path: |
./dist
./js/*.tgz

test:
needs: [build]
needs: [lint, build]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v3
with:
name: ipyvuetify-dist-${{ github.run_number }}

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: pip install dist/*.whl

- name: Import
# do the import in a subdirectory, as after installation, files in de current directory are also imported
run: |
(mkdir test-install; cd test-install; python -c "from ipyvuetify import Btn")
- name: Install ipyvuetify
run: python -m pip install "$(find dist -name *.whl)"
- name: test import
run: (mkdir test-install; cd test-install; python -c "from ipyvuetify import Btn")

ui-test:
needs: [build]
needs: [lint, build]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/download-artifact@v3
with:
name: ipyvuetify-dist-${{ github.run_number }}

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install vuetify and test deps
run: |
wheel=(dist/*.whl)
pip install ${wheel}[test] "jupyter_server<2"

- name: Install playwright browsers
- name: Install ipyvuetify
run: python -m pip install "$(find dist -name *.whl)[test]"
- name: Install chromium
run: playwright install chromium

- name: Run ui-tests
run: pytest tests/ui/ --video=retain-on-failure --solara-update-snapshots-ci -s

- name: Upload Test artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ipyvuetify-test-results
path: test-results
Expand Down
21 changes: 16 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
*.egg-info/
.eggs/
.ipynb_checkpoints/
dist/
build/
*.py[cod]
**/node_modules/

# generated code
generate_source/build
Expand All @@ -16,6 +19,14 @@ ipyvuetify/labextension/
ipyvuetify/nbextension/
js/lib

# readthedocs
_build/
# Sphinx documentation
docs/_build/

# Jupyter Notebook
.ipynb_checkpoints

# Unit test / coverage reports
.ruff_cache

# node installed dependencies
**/node_modules/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ recursive-include ipyvuetify/labextension *.*
include jupyter-vuetify.json
recursive-include ipyvuetify/extra *.vue
recursive-include generate_source/ *.*
recursive-include js/ *.*
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ipyvuetify>=1.2.2<2
jupyter-sphinx==0.2.4a1
sphinx_rtd_theme

ipykernel
1 change: 0 additions & 1 deletion generate_source/__init__.py

This file was deleted.

15 changes: 9 additions & 6 deletions generate_source/generate_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from itertools import chain
from pathlib import Path

sizes = ["xs", "sm", "md", "lg", "xl"]

Expand Down Expand Up @@ -92,8 +93,8 @@ def make_type(api_type):
"oneOf": list(filter(identity, map(make_type, api_type))),
}

# Not supported
if api_type == "function":
# Not supported
return None

print(f"Unknown type: {api_type}")
Expand Down Expand Up @@ -150,8 +151,8 @@ def make_widget(data):
name, attributes = data
widget_name = kebab_to_camel(name)

# Widgets without props are directives, internationalization or $vuetify
if "props" not in attributes.keys():
# Widgets without props are directives, internationalization or $vuetify
return None

properties = chain(*filter(identity, map(make_properties, attributes["props"])))
Expand All @@ -166,14 +167,16 @@ def make_widget(data):


def generate_schema(
vuetify_api_file_name, base_schema_file_name, schema_output_file_name
vuetify_api_file_name: Path,
base_schema_file_name: Path,
schema_output_file_name: Path,
):
api_data = json.loads(open(vuetify_api_file_name).read())
base_schema = json.loads(open(base_schema_file_name).read())
api_data = json.loads(vuetify_api_file_name.read_text())
base_schema = json.loads(base_schema_file_name.read_text())

widgets = filter(identity, map(make_widget, api_data.items()))

schema = {"widgets": {**base_schema["widgets"], **dict(widgets)}}

with open(schema_output_file_name, "w") as outfile:
with schema_output_file_name.open("w") as outfile:
json.dump(schema, outfile)
49 changes: 22 additions & 27 deletions generate_source/generate_source.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,48 @@
import os
import platform
import shutil
import subprocess
from pathlib import Path

from .generate_schema import generate_schema

here = os.path.dirname(os.path.abspath(__file__))

vuetify_api = f"{here}/vuetify_api.json"
base_schema = f"{here}/base.json"
build_dir = f"{here}/build"
widget_gen_schema = f"{build_dir}/widget_gen_schema.json"
from pynpm import NPMPackage

widgetgen = f"{here}/node_modules/.bin/widgetgen"
from .generate_schema import generate_schema

es6_template = f"{here}/es6-template.njk"
python_template = f"{here}/python.njk"
here = Path(__file__).parent

project_dir = f"{here}/.."
destination_js = f"{project_dir}/js/src/generated"
destination_python = f"{project_dir}/ipyvuetify/generated"
vuetify_api = here / "vuetify_api.json"
base_schema = here / "base.json"
build_dir = here / "build"
widget_gen_schema = build_dir / "widget_gen_schema.json"

widgetgen = here / "node_modules" / ".bin" / "widgetgen"

def reset_dir(name):
if os.path.isdir(name):
shutil.rmtree(name)
es6_template = here / "es6-template.njk"
python_template = here / "python.njk"

os.mkdir(name)
project_dir = here.parent
destination_js = project_dir / "js" / "src" / "generated"
destination_python = project_dir / "ipyvuetify" / "generated"


npm = "npm"
if platform.system() == "Windows":
npm = "npm.cmd"
def reset_dir(name: Path):
shutil.rmtree(name, ignore_errors=True)
name.mkdir(exist_ok=True)


def generate():
if not os.path.isdir(build_dir):
os.mkdir(build_dir)

build_dir.mkdir(exist_ok=True)

generate_schema(vuetify_api, base_schema, widget_gen_schema)

subprocess.check_call(f"{npm} install", cwd=here, shell=True)
NPMPackage(here / "package.json").install()

reset_dir(destination_js)

subprocess.check_call(
f"{widgetgen} -p json -o {destination_js} -t {es6_template} {widget_gen_schema} es6",
shell=True,
)
with open(f"{destination_js}/.eslintrc.js", "w") as f:
with open(destination_js / ".eslintrc.js", "w") as f:
f.write(
"""
module.exports = {
Expand Down
Loading