Skip to content

Commit

Permalink
Initial package setup (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
rth authored Sep 15, 2022
1 parent 9d46746 commit b47358d
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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 }}
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(<list-of-packages>)
```
For more information see the
[documentation](https://pyodide.org/en/stable/usage/loading-packages.html#micropip).

## License

Expand Down
1 change: 0 additions & 1 deletion micropip/_micropip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions tests/test_micropip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b47358d

Please sign in to comment.