Skip to content

Commit 22fb3bc

Browse files
authored
Merge pull request #2 from tupui/packaging
2 parents 456c427 + bae737e commit 22fb3bc

File tree

9 files changed

+182
-5
lines changed

9 files changed

+182
-5
lines changed

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See:
2+
#
3+
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes (E, W)
4+
# https://flake8.pycqa.org/en/latest/user/error-codes.html (F)
5+
# https://github.com/PyCQA/flake8-bugbear
6+
#
7+
# for error codes. And
8+
#
9+
# https://flake8.pycqa.org/en/latest/user/violations.html#selecting-violations-with-flake8
10+
#
11+
# for error classes selected below.
12+
13+
[flake8]
14+
max-line-length = 80
15+
select = C,E,F,W,B,B950
16+
ignore = E501, W503

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup Python 3.10
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: '3.10'
18+
architecture: 'x64'
19+
20+
- name: Install flit
21+
run: pip install flit
22+
23+
- name: Build
24+
run: flit build
25+
26+
- name: Publish to PyPI
27+
env:
28+
FLIT_USERNAME: __token__
29+
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }}
30+
run: |
31+
flit publish

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
default:
7+
runs-on: ${{ matrix.os }}-latest
8+
strategy:
9+
matrix:
10+
os: [ubuntu]
11+
python-version: ["3.10"]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
20+
- uses: actions/cache@v2
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install ".[test]"
31+
32+
- name: Lint
33+
run: pre-commit run --all-files --show-diff-on-failure --color always
34+
35+
- name: Test
36+
run: |
37+
pytest

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
11
*~
2+
# Byte-compiled / optimized / DLL files
23
**/__pycache__
4+
*.py[cod]
5+
6+
# Distribution / packaging
7+
dist/
8+
9+
# Unit test / coverage reports
10+
.pytest_cache/
11+
12+
# General
13+
.DS_Store
14+
15+
# Environments
16+
.env
17+
.venv
18+
env/
19+
venv/
20+
ENV/
21+
env.bak/
22+
venv.bak/
23+
24+
# IntelliJ project files
25+
.idea
26+
27+
# Spyder project settings
28+
.spyderproject
29+
.spyproject

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Install pre-commit hooks via
2+
# pre-commit install
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
7+
hooks:
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- repo: https://github.com/psf/black
12+
rev: 22.1.0
13+
hooks:
14+
- id: black
15+
- repo: https://gitlab.com/pycqa/flake8
16+
rev: 3.8.4
17+
hooks:
18+
- id: flake8
19+
pass_filenames: true
20+
- repo: https://github.com/pycqa/isort
21+
rev: 5.10.1
22+
hooks:
23+
- id: isort

Makefile

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
`lazy_loader` makes it easy to load subpackages and functions on demand.
1+
![PyPI](https://img.shields.io/pypi/v/lazy-loader?style=for-the-badge)
2+
3+
`lazy-loader` makes it easy to load subpackages and functions on demand.
24

35
## Motivation
46

@@ -7,6 +9,12 @@
79

810
For a more detailed discussion, see [the SPEC](https://scientific-python.org/specs/spec-0001/).
911

12+
## Installation
13+
14+
```
15+
pip install -U lazy-loader
16+
```
17+
1018
## Usage
1119

1220
### Lazily load subpackages
@@ -15,12 +23,12 @@ Consider the `__init__.py` from [scikit-image](https://scikit-image.org):
1523

1624
```python
1725
subpackages = [
18-
...
26+
...,
1927
'filters',
2028
...
2129
]
2230

23-
from lazy_loader import lazy
31+
import lazy_loader as lazy
2432
__getattr__, __dir__, _ = lazy.attach(__name__, subpackages)
2533
```
2634

lazy_loader/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
lazy_loader
3+
===========
4+
5+
Makes it easy to load subpackages and functions on demand.
6+
"""
17
import importlib
28
import importlib.util
39
import types

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["flit_core >=3.3,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "lazy_loader"
7+
version = "0.1rc1"
8+
requires-python = ">=3.8"
9+
authors = [{name = "The Scientific Python Group"}]
10+
readme = "README.md"
11+
license = {file = "LICENSE.md"}
12+
classifiers = ["License :: OSI Approved :: BSD License"]
13+
dynamic = ["description"]
14+
15+
[project.optional-dependencies]
16+
dev = [
17+
"flit"
18+
]
19+
test = [
20+
"pytest",
21+
"black",
22+
"pre-commit",
23+
"flake8"
24+
]
25+
26+
[project.urls]
27+
Home = "https://scientific-python.org/specs/spec-0001/"
28+
Source = "https://github.com/scientific-python/lazy-loader"
29+
30+
[tool.flit.sdist]
31+
exclude = ["tests/*"]

0 commit comments

Comments
 (0)