diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..d8110dc --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +extend-ignore = E203, E402, E501, E731, E741, B950, W503 +select = C,E,F,W,B,B9 +extend-immutable-calls = typer.Argument, typer.Option diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6fa2a70 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: main + +on: [push, pull_request] + +permissions: + contents: read + +concurrency: + group: main-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + environment: PyPi-deploy + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v3 + with: + python-version: 3.10.2 + - name: Install requirements and build wheel + shell: bash -l {0} + run: | + python -m pip install build twine + python -m build . + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b2c22d3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,62 @@ +default_language_version: + python: "3.10" + +exclude: ^micropip/externals +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.3.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + exclude: .clang-format + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + + - repo: https://github.com/PyCQA/isort + rev: "5.10.1" + hooks: + - id: isort + + - repo: https://github.com/asottile/pyupgrade + rev: "v2.37.3" + hooks: + - id: pyupgrade + args: ["--py310-plus"] + + - repo: https://github.com/hadialqattan/pycln + rev: "v2.1.1" + hooks: + - id: pycln + args: [--config=pyproject.toml] + stages: [manual] + + - repo: https://github.com/psf/black + rev: "22.8.0" + hooks: + - id: black + + - repo: https://github.com/pycqa/flake8 + rev: "5.0.4" + hooks: + - id: flake8 + additional_dependencies: [flake8-bugbear] + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v0.971" + hooks: + - id: mypy + args: [] + additional_dependencies: &mypy-deps + - pytest + + + - repo: https://github.com/codespell-project/codespell + rev: "v2.2.1" + hooks: + - id: codespell + args: ["-L", "te,slowy,aray,ba,nd,classs,crate,feld,lits"] diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..597bfdd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0] - Unreleased + +Initial standalone release. For earlier release notes, see +the [Pyodide project changelog](https://pyodide.org/en/stable/project/changelog.html). diff --git a/README.md b/README.md index 78cb1fb..d1990c1 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,22 @@ [![PyPI Latest Release](https://img.shields.io/pypi/v/matplotlib-pyodide.svg)](https://pypi.org/project/micropip/) ![GHA](https://github.com/pyodide/micropip/actions/workflows/main.yml/badge.svg) -A lightweight Python package installer for the web +A lightweight Python package installer for the web +## Installation + +In Pyodide, you can install micropip, + - either implicitly by importing it in the REPL + - or explicitly via `pyodide.loadPackage('micropip')`. You can also install by URL from PyPI for instance. + +## Usage + +```py +import micropip +await micropip.install() +``` +For more information see the +[documentation](https://pyodide.org/en/stable/usage/loading-packages.html#micropip). ## License diff --git a/micropip/_micropip.py b/micropip/_micropip.py index 0c2aa9f..4c67b5e 100644 --- a/micropip/_micropip.py +++ b/micropip/_micropip.py @@ -19,7 +19,6 @@ from packaging.tags import Tag, sys_tags from packaging.utils import canonicalize_name, parse_wheel_filename from packaging.version import Version - from pyodide._package_loader import get_dynlibs, wheel_dist_info_dir from pyodide.ffi import to_js diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b0796f5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["setuptools>=42", "setuptools_scm[toml]>=6.2"] + +build-backend = "setuptools.build_meta" + +# Evable versioning via setuptools_scm +[tool.setuptools_scm] + +[tool.pycln] +all = true + +[tool.isort] +profile = "black" +known_first_party = [ + "micropip", +] + +[tool.mypy] +python_version = "3.10" +show_error_codes = true +warn_unreachable = true +ignore_missing_imports = true diff --git a/tests/test_micropip.py b/tests/test_micropip.py index 7337418..06d9376 100644 --- a/tests/test_micropip.py +++ b/tests/test_micropip.py @@ -771,9 +771,10 @@ async def test_load_binary_wheel1( @pytest.mark.skip_refcount_check @run_in_pyodide(packages=["micropip"]) async def test_load_binary_wheel2(selenium): - import micropip from pyodide_js._api import repodata_packages + import micropip + await micropip.install(repodata_packages.regex.file_name) import regex # noqa: F401 @@ -813,9 +814,10 @@ def test_emfs(selenium_standalone_micropip): @run_in_pyodide(packages=["micropip"]) async def run_test(selenium, url, wheel_name): - import micropip from pyodide.http import pyfetch + import micropip + resp = await pyfetch(url + wheel_name) await resp._into_file(open(wheel_name, "wb")) await micropip.install("emfs:" + wheel_name)