diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 2c19cbee348..2e178927525 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -11,7 +11,9 @@ body: There will always be more issues than there is time to do them, and so we will need to selectively close issues that don't provide enough information, so we can focus our time on helping people like you who fill out the issue form completely. Thank you for your collaboration! - There are also already a lot of open issues, so please take 2 minutes and search through existing ones to see if what you are experiencing already exists + There are also already a lot of open issues, so please take 2 minutes and search through existing ones to see if what you are experiencing already exists. + + Finally, if you are opening **a bug report related to PyScript.com** please [use this repository instead](https://github.com/anaconda/pyscript-dot-com-issues/issues/new/choose). Thanks for helping PyScript be amazing. We are nothing without people like you helping build a better community 💐! - type: checkboxes diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d5bf9b2d18b..591e81853a0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,12 +4,9 @@ ## Changes - + ## Checklist - - -- [ ] All tests pass locally -- [ ] I have updated `docs/changelog.md` -- [ ] I have created documentation for this(if applicable) +- [ ] I have checked `make build` works locally. +- [ ] I have created / updated documentation for this change (if applicable). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..e29bff2bead --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 77fe8941488..43fe719dbf1 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -7,7 +7,7 @@ on: defaults: run: - working-directory: ./pyscript.core + working-directory: ./core jobs: prepare-release: @@ -17,12 +17,27 @@ jobs: uses: actions/checkout@v4 - name: Install node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: @@ -35,20 +50,20 @@ jobs: ${{ runner.os }}- - name: NPM Install - run: npm install + run: npm install && npx playwright install chromium - name: Build run: npm run build - name: Generate index.html working-directory: . - run: sed 's#_PATH_#./#' ./public/index.html > ./pyscript.core/dist/index.html + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html - name: Zip dist folder run: zip -r -q ./build.zip ./dist - name: Prepare Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: draft: true prerelease: true diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 273562584a4..5c605299dbc 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -6,7 +6,7 @@ on: defaults: run: - working-directory: ./pyscript.core + working-directory: ./core jobs: publish-release: @@ -19,12 +19,27 @@ jobs: uses: actions/checkout@v4 - name: Install node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: @@ -37,14 +52,18 @@ jobs: ${{ runner.os }}- - name: npm install - run: npm install + run: npm install && npx playwright install chromium - name: build run: npm run build - name: Generate index.html in snapshot working-directory: . - run: sed 's#_PATH_#https://pyscript.net/releases/${{ github.ref_name }}/#' ./public/index.html > ./pyscript.core/dist/index.html + run: sed -e 's#_PATH_#https://pyscript.net/releases/${{ github.ref_name }}/#' -e 's#_DOC_VERSION_#${{ github.ref_name }}#' -e 's#_TAG_VERSION_#/tag/${{ github.ref_name }}#' -e 's#_VERSION_#${{ github.ref_name }}#' ./public/index.html > ./core/dist/index.html + + - name: Generate release.tar from snapshot and put it in dist/ + working-directory: . + run: tar -cvf ../release.tar * && mv ../release.tar . - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 17699458d45..b7f51d52ae7 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -10,7 +10,7 @@ on: defaults: run: - working-directory: ./pyscript.core + working-directory: ./core jobs: publish-snapshot: @@ -23,12 +23,27 @@ jobs: uses: actions/checkout@v4 - name: Install node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: @@ -41,7 +56,7 @@ jobs: ${{ runner.os }}- - name: Install Dependencies - run: npm install + run: npm install && npx playwright install chromium - name: Build Pyscript.core run: npm run build @@ -54,7 +69,7 @@ jobs: - name: Generate index.html in snapshot working-directory: . - run: sed 's#_PATH_#https://pyscript.net/snapshots/${{ inputs.snapshot_version }}/#' ./public/index.html > ./pyscript.core/dist/index.html + run: sed -e 's#_PATH_#https://pyscript.net/snapshots/${{ inputs.snapshot_version }}/#' -e 's#_DOC_VERSION_#${{ inputs.snapshot_version }}#' -e 's#_TAG_VERSION_#/tag/${{ inputs.snapshot_version }}#' -e 's#_VERSION_#${{ inputs.snapshot_version }}#' ./public/index.html > ./core/dist/index.html - name: Copy to Snapshot run: > diff --git a/.github/workflows/publish-unstable.yml b/.github/workflows/publish-unstable.yml index 26436e916a4..89a0e2b8902 100644 --- a/.github/workflows/publish-unstable.yml +++ b/.github/workflows/publish-unstable.yml @@ -1,11 +1,11 @@ name: "Publish Unstable" on: - push: # Only run on merges into main that modify files under pyscript.core/ and examples/ + push: # Only run on merges into main that modify files under core/ and examples/ branches: - main paths: - - pyscript.core/** + - core/** - examples/** workflow_dispatch: @@ -18,18 +18,33 @@ jobs: contents: read defaults: run: - working-directory: ./pyscript.core + working-directory: ./core steps: - name: Checkout uses: actions/checkout@v4 - name: Install node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20.x + + - name: Python venv + run: python -m venv env + + - name: Activate Python + run: source env/bin/activate + + - name: Update pip + run: pip install --upgrade pip + + - name: Install PyMinifier + run: pip install --ignore-requires-python python-minifier + + - name: Install Setuptools + run: pip install setuptools - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: @@ -42,14 +57,14 @@ jobs: ${{ runner.os }}- - name: NPM Install - run: npm install + run: npm install && npx playwright install chromium - name: Build run: npm run build - name: Generate index.html in snapshot working-directory: . - run: sed 's#_PATH_#https://pyscript.net/unstable/#' ./public/index.html > ./pyscript.core/dist/index.html + run: sed -e 's#_PATH_#./#' -e 's#_DOC_VERSION_#latest#' -e 's#_TAG_VERSION_##' -e 's#_VERSION_#latest#' ./public/index.html > ./core/dist/index.html - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb62b8838ec..785b7cbbf3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,20 +5,20 @@ on: branches: - main paths: - - pyscript.core/** + - core/** - .github/workflows/test.yml pull_request: # Only run on merges into main that modify certain files branches: - main paths: - - pyscript.core/** + - core/** - .github/workflows/test.yml workflow_dispatch: jobs: BuildAndTest: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest env: MINICONDA_PYTHON_VERSION: py38 MINICONDA_VERSION: 4.11.0 @@ -37,12 +37,12 @@ jobs: run: git log --graph -3 - name: Install node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20.x - name: Cache node modules - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: @@ -55,29 +55,26 @@ jobs: ${{ runner.os }}- - name: setup Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 - - name: Setup Environment - run: make setup + - name: Create and activate virtual environment + run: | + python3 -m venv test_venv + source test_venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + echo VIRTUAL_ENV=$VIRTUAL_ENV >> $GITHUB_ENV - - name: Build - run: make build + - name: Setup dependencies in virtual environment + run: | + make setup - - name: Integration Tests - #run: make test-integration-parallel - run: make test-integration + - name: Build + run: make build # Integration tests run in the build step. - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: pyscript path: | - pyscript.core/dist/ + core/dist/ if-no-files-found: error retention-days: 7 - - - uses: actions/upload-artifact@v3 - if: success() || failure() - with: - name: test_results - path: test_results/ - if-no-files-found: error diff --git a/.github/workflows/test_report.yml b/.github/workflows/test_report.yml deleted file mode 100644 index 6debdbdce4d..00000000000 --- a/.github/workflows/test_report.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Test Report -on: - workflow_run: - workflows: ['\[CI\] Test'] - types: - - completed -jobs: - report: - runs-on: ubuntu-latest-8core - steps: - - uses: dorny/test-reporter@v1.6.0 - with: - artifact: test_results - name: Test reports - path: "*.xml" - reporter: java-junit diff --git a/.gitignore b/.gitignore index c1e2cf988ea..6ccef40cf9e 100644 --- a/.gitignore +++ b/.gitignore @@ -142,8 +142,11 @@ coverage/ test_results # @pyscript/core npm artifacts -pyscript.core/core.* -pyscript.core/dist -pyscript.core/dist -pyscript.core/src/plugins.js -pyscript.core/src/stdlib/pyscript.js +core/test-results/* +core/core.* +core/dist +core/dist.zip +core/src/plugins.js +core/src/stdlib/pyscript.js +core/src/3rd-party/* +!core/src/3rd-party/READMEmd diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f34c0d0b3af..b18b22ee168 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,10 +4,10 @@ ci: #skip: [eslint] autoupdate_schedule: monthly -default_stages: [commit] +default_stages: [pre-commit] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: check-builtin-literals - id: check-case-conflict @@ -21,33 +21,33 @@ repos: - id: check-yaml - id: detect-private-key - id: end-of-file-fixer - exclude: pyscript\.core/dist|\.min\.js$ + exclude: core/dist|\.min\.js$ - id: trailing-whitespace - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 25.1.0 hooks: - id: black - exclude: pyscript\.core/src/stdlib/pyscript/__init__\.py + exclude: core/tests + args: ["-l", "88", "--skip-string-normalization"] - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.4.1 hooks: - id: codespell # See 'pyproject.toml' for args - exclude: \.js\.map$ + exclude: fs\.py|\.js\.map$ additional_dependencies: - tomli + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.8 + hooks: + - id: ruff + exclude: core/tests + - repo: https://github.com/hoodmane/pyscript-prettier-precommit rev: "v3.0.0-alpha.6" hooks: - id: prettier - exclude: pyscript\.core/test|pyscript\.core/dist|pyscript\.core/types|pyscript.core/src/stdlib/pyscript.js|pyscript\.sw/ + exclude: core/tests|core/dist|core/types|core/src/stdlib/pyscript.js|pyscript\.sw/|core/src/3rd-party args: [--tab-width, "4"] - - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) - args: [--profile, black] diff --git a/.prettierignore b/.prettierignore index bff93a895e5..8251e101bf7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ ISSUE_TEMPLATE *.min.* package-lock.json -docs -examples/panel.html +bridge/ diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index b5324a7e886..00000000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,28 +0,0 @@ -# .readthedocs.yaml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Set the version of Python and other tools you might need -build: - os: ubuntu-20.04 - tools: - python: miniconda3-4.7 - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/conf.py - -conda: - environment: docs/environment.yml - -# If using Sphinx, optionally build your docs in additional formats such as PDF -# formats: -# - pdf - -# Optionally declare the Python requirements required to build your docs -python: - install: - - requirements: docs/requirements.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4fc34f49a0e..8ce2c517a45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,81 +1,4 @@ # Contributing to PyScript -Thank you for wanting to contribute to the PyScript project! - -## Table of contents - -- [Contributing to PyScript](#contributing-to-pyscript) - - [Table of contents](#table-of-contents) -- [Code of Conduct](#code-of-conduct) -- [Contributing](#contributing) - - [Reporting bugs](#reporting-bugs) - - [Creating useful issues](#creating-useful-issues) - - [Reporting security issues](#reporting-security-issues) - - [Asking questions](#asking-questions) - - [Setting up your local environment and developing](#setting-up-your-local-environment-and-developing) - - [Developing](#developing) - - [Rebasing changes](#rebasing-changes) - - [Building the docs](#building-the-docs) - - [Places to start](#places-to-start) - - [Setting up your local environment and developing](#setting-up-your-local-environment-and-developing) - - [Submitting a change](#submitting-a-change) -- [License terms for contributions](#license-terms-for-contributions) -- [Becoming a maintainer](#becoming-a-maintainer) -- [Trademarks](#trademarks) - -# Code of Conduct - -The [PyScript Code of Conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md) governs the project and everyone participating in it. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers or administrators as described in that document. - -# Contributing - -## Reporting bugs - -Bugs are tracked on the [project issues page](https://github.com/pyscript/pyscript/issues). Please check if your issue has already been filed by someone else by searching the existing issues before filing a new one. Once your issue is filed, it will be triaged by another contributor or maintainer. If there are questions raised about your issue, please respond promptly. - -## Creating useful issues - -- Use a clear and descriptive title. -- Describe the specific steps that reproduce the problem with as many details as possible so that someone can verify the issue. -- Describe the behavior you observed, and the behavior you had expected. -- Include screenshots if they help make the issue clear. - -## Reporting security issues - -If you aren't confident that it is appropriate to submit a security issue using the above process, you can e-mail it to security@pyscript.net - -## Asking questions - -If you have questions about the project, using PyScript, or anything else, please ask in the [PyScript forum](https://community.anaconda.cloud/c/tech-topics/pyscript). - -## Places to start - -If you would like to contribute to PyScript, but you aren't sure where to begin, here are some suggestions: - -- **Read over the existing documentation.** Are there things missing, or could they be clearer? Make some changes/additions to those documents. -- **Review the open issues.** Are they clear? Can you reproduce them? You can add comments, clarifications, or additions to those issues. If you think you have an idea of how to address the issue, submit a fix! -- **Look over the open pull requests.** Do you have comments or suggestions for the proposed changes? Add them. -- **Check out the examples.** Is there a use case that would be good to have sample code for? Create an example for it. - -## Setting up your local environment and developing - -If you would like to contribute to PyScript, you will need to set up a local development environment. The [following instructions](https://docs.pyscript.net/latest/development/setting-up-environment.html) will help you get started. - -You can also read about PyScript's [development process](https://docs.pyscript.net/latest/development/developing.html) to learn how to contribute code to PyScript, how to run tests and what's the PR etiquette of the community! - -## License terms for contributions - -This Project welcomes contributions, suggestions, and feedback. All contributions, suggestions, and feedback you submitted are accepted under the [Apache 2.0](./LICENSE) license. You represent that if you do not own copyright in the code that you have the authority to submit it under the [Apache 2.0](./LICENSE) license. All feedback, suggestions, or contributions are not confidential. - -## Becoming a maintainer - -Contributors are invited to be maintainers of the project by demonstrating good decision making in their contributions, a commitment to the goals of the project, and consistent adherence to the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md). New maintainers are invited by a 3/4 vote of the existing maintainers. - -## Trademarks - -The Project abides by the Organization's [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md). - ---- - -Part of MVG-0.1-beta. -Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/). +Please see our guide to contributing to PyScript +[in our documentation](https://docs.pyscript.net/latest/contributing/). diff --git a/LICENSE b/LICENSE index 261eeb9e9f8..aa530349d35 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,11 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + + Copyright (c) 2022-present, PyScript Development Team + + Originated at Anaconda, Inc. in 2022 + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 4db11559ddb..0e603bfa847 100644 --- a/Makefile +++ b/Makefile @@ -1,122 +1,93 @@ -tag := latest -git_hash ?= $(shell git log -1 --pretty=format:%h) - -base_dir ?= $(shell git rev-parse --show-toplevel) -examples ?= ../$(base_dir)/examples -app_dir ?= $(shell git rev-parse --show-prefix) - -CONDA_EXE := conda -CONDA_ENV ?= $(base_dir)/env -env := $(CONDA_ENV) -conda_run := $(CONDA_EXE) run -p $(env) -PYTEST_EXE := $(CONDA_ENV)/bin/pytest - -MIN_NODE_VER := 14 -MIN_NPM_VER := 6 -NODE_VER := $(shell node -v | cut -d. -f1 | sed 's/^v\(.*\)/\1/') -NPM_VER := $(shell npm -v | cut -d. -f1) - -ifeq ($(shell uname -s), Darwin) - SED_I_ARG := -i '' -else - SED_I_ARG := -i -endif +MIN_NODE_VER := 20 +MIN_NPM_VER := 6 +MIN_PY3_VER := 8 +NODE_VER := $(shell node -v | cut -d. -f1 | sed 's/^v\(.*\)/\1/') +NPM_VER := $(shell npm -v | cut -d. -f1) +PY3_VER := $(shell python3 -c "import sys;t='{v[1]}'.format(v=list(sys.version_info[:2]));print(t)") +PY_OK := $(shell python3 -c "print(int($(PY3_VER) >= $(MIN_PY3_VER)))") + +all: + @echo "\nThere is no default Makefile target right now. Try:\n" + @echo "make setup - check your environment and install the dependencies." + @echo "make update - update dependencies." + @echo "make clean - clean up auto-generated assets." + @echo "make build - build PyScript." + @echo "make precommit-check - run the precommit checks (run eslint)." + @echo "make test - run all automated tests in playwright." + @echo "make fmt - format the code." + @echo "make fmt-check - check the code formatting.\n" .PHONY: check-node check-node: @if [ $(NODE_VER) -lt $(MIN_NODE_VER) ]; then \ - echo "Build requires Node $(MIN_NODE_VER).x or higher: $(NODE_VER) detected"; \ + echo "\033[0;31mBuild requires Node $(MIN_NODE_VER).x or higher: $(NODE_VER) detected.\033[0m"; \ false; \ fi .PHONY: check-npm check-npm: @if [ $(NPM_VER) -lt $(MIN_NPM_VER) ]; then \ - echo "Build requires Node $(MIN_NPM_VER).x or higher: $(NPM_VER) detected"; \ + echo "\033[0;31mBuild requires Node $(MIN_NPM_VER).x or higher: $(NPM_VER) detected.\033[0m"; \ + false; \ + fi + +.PHONY: check-python +check-python: + @if [ $(PY_OK) -eq 0 ]; then \ + echo "\033[0;31mRequires Python 3.$(MIN_PY3_VER).x or higher: 3.$(PY3_VER) detected.\033[0m"; \ false; \ fi -setup: check-node check-npm - cd pyscript.core && npm install && cd .. - $(CONDA_EXE) env $(shell [ -d $(env) ] && echo update || echo create) -p $(env) --file environment.yml - $(conda_run) playwright install - $(CONDA_EXE) install -c anaconda pytest -y +# Check the environment, install the dependencies. +setup: check-node check-npm check-python + cd core && npm ci && cd .. +ifeq (,$(VIRTUAL_ENV)$(CONDA_PREFIX)) + echo "\n\n\033[0;31mCannot install Python dependencies. Your virtualenv or conda env is not activated.\033[0m" + false +else + python -m pip install -r requirements.txt +endif +# Clean up generated assets. clean: find . -name \*.py[cod] -delete - rm -rf .pytest_cache .coverage coverage.xml - -clean-all: clean rm -rf $(env) *.egg-info + rm -rf .pytest_cache .coverage coverage.xml -shell: - @export CONDA_ENV_PROMPT='<{name}>' - @echo 'conda activate $(env)' - -dev: - cd pyscript.core && npm run dev +# Build PyScript. +build: precommit-check + cd core && npx playwright install chromium && npm run build -build: - cd pyscript.core && npm run build +# Update the dependencies. +update: + python -m pip install -r requirements.txt --upgrade -# use the following rule to do all the checks done by precommit: in -# particular, use this if you want to run eslint. +# Run the precommit checks (run eslint). precommit-check: pre-commit run --all-files -examples: - mkdir -p ./examples - cp -r ../examples/* ./examples - chmod -R 755 examples - find ./examples/toga -type f -name '*.html' -exec sed $(SED_I_ARG) s+https://pyscript.net/latest/+../../build/+g {} \; - find ./examples/webgl -type f -name '*.html' -exec sed $(SED_I_ARG) s+https://pyscript.net/latest/+../../../build/+g {} \; - find ./examples -type f -name '*.html' -exec sed $(SED_I_ARG) s+https://pyscript.net/latest/+../build/+g {} \; - npm run build - rm -rf ./examples/build - mkdir -p ./examples/build - cp -R ./build/* ./examples/build - @echo "To serve examples run: $(conda_run) python -m http.server 8080 --directory examples" - -# run prerequisites and serve pyscript examples at http://localhost:8000/examples/ -run-examples: setup build examples - make examples - npm install - make dev - -# run all integration tests *including examples* sequentially -# TODO: (fpliger) The cd pyscript.core before running the tests shouldn't be needed but for -# but for some reason it seems to bother pytest tmppaths (or test cache?). Unclear. -test-integration: - mkdir -p test_results - $(PYTEST_EXE) -vv $(ARGS) pyscript.core/tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml - -# run all integration tests *except examples* in parallel (examples use too much memory) -test-integration-parallel: - mkdir -p test_results - $(PYTEST_EXE) --numprocesses auto -vv $(ARGS) pyscript.core/tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml - -# run integration tests on only examples sequentially (to avoid running out of memory) -test-examples: - mkdir -p test_results - $(PYTEST_EXE) -vv $(ARGS) pyscript.core/tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml -k 'zz_examples' - -fmt: fmt-py fmt-ts - @echo "Format completed" +# Run all automated tests in playwright. +test: + cd core && npm run test:integration -fmt-check: fmt-ts-check fmt-py-check - @echo "Format check completed" +# Serve the repository with the correct headers. +serve: + npx mini-coi . -fmt-ts: - npm run format +# Format the code. +fmt: fmt-py + @echo "Format completed" -fmt-ts-check: - npm run format:check +# Check the code formatting. +fmt-check: fmt-py-check + @echo "Format check completed" +# Format Python code. fmt-py: - $(conda_run) black --skip-string-normalization . - $(conda_run) isort --profile black . + black -l 88 --skip-string-normalization . +# Check the format of Python code. fmt-py-check: - $(conda_run) black -l 88 --check . + black -l 88 --check . .PHONY: $(MAKECMDGOALS) diff --git a/README.md b/README.md index 11fb03d5591..5026b7990f1 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,94 @@ # PyScript -## What is PyScript +## PyScript is an open source platform for Python in the browser. -### Summary +Using PyScript is as simple as: -PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of [Pyodide](https://pyodide.org/en/stable/), [WASM](https://webassembly.org/), and modern web technologies. +```html + + +
+ + +