Skip to content
Open
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
30 changes: 30 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ghcr.io/astral-sh/uv:python3.9-bookworm-slim

# Install the project into `/app`
WORKDIR /app

# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev

# Then, add the rest of the project source code and install it
# Installing separately from its dependencies allows optimal layer caching
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev

# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:/root/.local/bin:$PATH"

# Reset the entrypoint, don't invoke `uv`
ENTRYPOINT []

CMD ["/bin/bash"]
49 changes: 49 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Scrapabook",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "./Dockerfile"
},
"runArgs": [
"--name=scrapbook",
"-v=scrapbook-vscode-extensions:/root/.vscode-server/extensions"
],
"overrideCommand": true,
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.mypy-type-checker",
"charliermarsh.ruff",
"ryanluker.vscode-coverage-gutters"
],
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
"terminal.integrated.defaultProfile.linux": "bash",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"python.defaultInterpreterPath": ".venv/bin/python",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"coverage-gutters.showGutterCoverage": false,
"coverage-gutters.showLineCoverage": true
}
}
}
}
36 changes: 36 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Scrapbook

on:
push:
paths:
- "src/**"
- "tests/**"
- ".github/workflows/**"
- "pyproject.toml"
- "uv.lock"

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.30"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
run: uv python install 3.9

- name: Install the project
run: uv sync --all-extras --dev

- name: Run lint
run: uv run ruff check .

- name: Run tests
run: uv run tox
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
*.pyc
*.pyo
__pycache__
.direnv
.envrc
.vscode
.cache
.coverage
.pytest_cache
.ruff_cache
.tox
.venv
.vscode
*.pyc
*.pyo
coverage.xml
dist
scrapbook.egg-info
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Scrapbook
=================================================

[![CircleCI](https://circleci.com/gh/odoku/Scrapbook/tree/master.svg?style=svg)](https://circleci.com/gh/odoku/Scrapbook/tree/master)

Scrapbook is simple scraping library.


Expand Down Expand Up @@ -33,7 +31,7 @@ print(data)
Requirements
-------------------------------------------------

- Python 2.7 or Python 3.3+
- Python 3.9+


Installation
Expand Down
8 changes: 0 additions & 8 deletions circle.yml

This file was deleted.

8 changes: 0 additions & 8 deletions pip_requirements.txt

This file was deleted.

98 changes: 98 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[project]
name = "scrapbook"
version = "1.0.0"
description = "Simple scraping library."
keywords = ["html", "parse", "scraping"]
readme = { file = "README.md", content-type = "text/markdown" }
authors = [{ name = "Masashi Onogawa", email = "masashi.onogawa@wamw.jp" }]
license = { file = "LICENSE" }
requires-python = ">=3.9"
dependencies = ["parsel>=1.9.1", "python-dateutil>=2.9.0.post0"]

[project.urls]
Homepage = "https://github.com/odoku/Scrapbook"
Documentation = "https://scrapbook.readthedocs.io/"
Repository = "https://github.com/odoku/Scrapbook"
Issues = "https://github.com/odoku/Scrapbook/issues"

[dependency-groups]
dev = [
"mypy>=1.13.0",
"pytest-cov>=6.0.0",
"pytest-mock>=3.14.0",
"pytest>=8.3.3",
"ruff>=0.7.2",
"tox>=4.23.2",
"tox-uv>=1.16.0",
"types-python-dateutil>=2.9.0.20241003",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.mypy]
plugins = []
show_column_numbers = true
ignore_missing_imports = true
exclude = []

[tool.ruff]
target-version = "py39"
line-length = 120
indent-width = 4
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

[tool.ruff.lint]
select = ["B", "C", "E", "F", "W", "B9"]
ignore = ["E203", "E266"]
exclude = []

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
exclude = []

[tool.pytest.ini_options]
pythonpath = "src"
testpaths = ["tests"]
addopts = "--cov=. --cov-report=xml"
python_files = "*.py"

[tool.tox]
envlist = ["py39", "py310", "py311", "py312", "py313", "pypy39", "pypy310"]
isolated_build = true

[tool.tox.env_run_base]
description = "Run test under {base_python}"
runner = "uv-venv-lock-runner"
with_dev = true
commands = [["pytest"]]
Loading