Skip to content

Add the packaging infrastructure #2

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 3 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See:
#
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes (E, W)
# https://flake8.pycqa.org/en/latest/user/error-codes.html (F)
# https://github.com/PyCQA/flake8-bugbear
#
# for error codes. And
#
# https://flake8.pycqa.org/en/latest/user/violations.html#selecting-violations-with-flake8
#
# for error classes selected below.

[flake8]
max-line-length = 80
select = C,E,F,W,B,B950
ignore = E501, W503
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
tags:
- '*.*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
architecture: 'x64'

- name: Install flit
run: pip install flit

- name: Build
run: flit build

- name: Publish to PyPI
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
flit publish
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test

on: [push, pull_request]

jobs:
default:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[test]"

- name: Lint
run: pre-commit run --all-files --show-diff-on-failure --color always

- name: Test
run: |
pytest
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
*~
# Byte-compiled / optimized / DLL files
**/__pycache__
*.py[cod]

# Distribution / packaging
dist/

# Unit test / coverage reports
.pytest_cache/

# General
.DS_Store

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# IntelliJ project files
.idea

# Spyder project settings
.spyderproject
.spyproject
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Install pre-commit hooks via
# pre-commit install

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
pass_filenames: true
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
2 changes: 0 additions & 2 deletions Makefile

This file was deleted.

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

`lazy-loader` makes it easy to load subpackages and functions on demand.

## Motivation

Expand All @@ -7,6 +9,12 @@

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

## Installation

```
pip install -U lazy-loader
```

## Usage

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

```python
subpackages = [
...
...,
'filters',
...
]

from lazy_loader import lazy
import lazy_loader as lazy
__getattr__, __dir__, _ = lazy.attach(__name__, subpackages)
```

Expand Down
6 changes: 6 additions & 0 deletions lazy_loader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
lazy_loader
===========

Makes it easy to load subpackages and functions on demand.
"""
import importlib
import importlib.util
import types
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
requires = ["flit_core >=3.3,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "lazy_loader"
version = "0.1rc1"
requires-python = ">=3.8"
authors = [{name = "The Scientific Python Group"}]
readme = "README.md"
license = {file = "LICENSE.md"}
classifiers = ["License :: OSI Approved :: BSD License"]
dynamic = ["description"]

[project.optional-dependencies]
dev = [
"flit"
]
test = [
"pytest",
"black",
"pre-commit",
"flake8"
]

[project.urls]
Home = "https://scientific-python.org/specs/spec-0001/"
Source = "https://github.com/scientific-python/lazy-loader"

[tool.flit.sdist]
exclude = ["tests/*"]