Skip to content

Commit

Permalink
use gh actions, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrekk committed Apr 7, 2021
1 parent 03be520 commit f4c3a77
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 558 deletions.
File renamed without changes.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
tags:
- 'V*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install pypa/build
run: python -m pip install build --user

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit Test

on:
push:
branches:
- master
tags-ignore:
- 'V*'
pull_request:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt update
sudo apt install -y xvfb
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
sudo apt install -y ./wkhtmltox_0.12.6-1.bionic_amd64.deb
pip install -r requirements.txt
- name: Run unit test
run: nosetests --with-coverage --cover-package=src/imgkit --where tests imgkit_test.py

- name: Run code coverage
run: codecov
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
build
dist
imgkit.egg-info
__pycache__

# Tests
.tox
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

11 changes: 0 additions & 11 deletions AUTHORS.md

This file was deleted.

50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

# Change Log

## [1.2.0] - 2018-04-07

### Added

### Changed

Use GH actions for CI/CD.
### Fixed

Fix `six` package requirements.

## [1.1.1] - 2018-04-06

### Added

### Changed

### Fixed

Use `six` for `basestring` compatibility.

## [1.1.0] - 2021-03-17

### Added

### Changed

- Refine code on get `wkhtmltoimage` & `xvfb-run` path.
- Refine code based on codacy suggestion.
- Use issue templates in GitHub.

### Fixed

## [1.0.5] - 2021-03-12

### Added

### Changed

- Fix travis-ci CI/CD error.
- Support new python version: 3.7, 3.8, 3.9.

### Fixed

## [1.0.2] - 2019-05-16
## [1.0.1] - 2018-02-08
## [1.0.0] - 2018-02-07
1 change: 0 additions & 1 deletion MANIFEST.io

This file was deleted.

18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# IMGKit: Python library of HTML to IMG wrapper

[![Build Status](https://travis-ci.org/jarrekk/imgkit.svg?branch=master)](https://travis-ci.org/jarrekk/imgkit)
[![Unit Test](https://github.com/jarrekk/imgkit/actions/workflows/unit_test.yml/badge.svg?branch=master)](https://github.com/jarrekk/imgkit/actions/workflows/unit_test.yml)
[![codecov](https://codecov.io/gh/jarrekk/imgkit/branch/master/graph/badge.svg?token=pNl4TtuAzz)](https://codecov.io/gh/jarrekk/imgkit)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/aa1f67f04ff24bb080b7f8c8a9b7b8b1)](https://www.codacy.com/app/jarrekk/imgkit?utm_source=github.com&utm_medium=referral&utm_content=jarrekk/imgkit&utm_campaign=Badge_Grade)
[![Release](https://github.com/jarrekk/imgkit/actions/workflows/release.yml/badge.svg)](https://github.com/jarrekk/imgkit/actions/workflows/release.yml)
[![PyPI version](https://badge.fury.io/py/imgkit.svg)](https://badge.fury.io/py/imgkit)

``` text
Expand Down Expand Up @@ -71,7 +72,7 @@ If you wish to further process generated IMG, you can read it to a variable:
img = imgkit.from_url('http://google.com', False)
```

You can find all wkhtmltoimage options by type `wkhtmltoimage` command or visit this [Manual](http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltoimage_0.10.0_rc2-doc.html). You can drop '--' in option name. If option without value, use *None, False* or *''* for dict value:. For repeatable options (incl. allow, cookie, custom-header, post, postfile, run-script, replace) you may use a list or a tuple. With option that need multiple values (e.g. --custom-header Authorization secret) we may use a 2-tuple (see example below).
You can find all wkhtmltoimage options by type `wkhtmltoimage` command or visit this [Manual](https://wkhtmltopdf.org/usage/wkhtmltopdf.txt). You can drop '--' in option name. If option without value, use *None, False* or *''* for dict value:. For repeatable options (incl. allow, cookie, custom-header, post, postfile, run-script, replace) you may use a list or a tuple. With option that need multiple values (e.g. --custom-header Authorization secret) we may use a 2-tuple (see example below).

``` python
options = {
Expand Down Expand Up @@ -190,3 +191,16 @@ imgkit.from_string(html_string, output_file, config=config)
## Credit

[python PDFKit](https://github.com/JazzCore/python-pdfkit)

## IMGKit author

* **jarrekk** <https://github.com/jarrekk>

### Contributors

* **v-hunt** <https://github.com/v-hunt>
* **archydeberker** <https://github.com/archydeberker>
* **arayate** <https://github.com/arayate>
* **xtrntr** <https://github.com/xtrntr>
* **mike1703** <https://github.com/mike1703>
* **themeewa** <https://github.com/themeewa>
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"wheel",
"six"
]
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
six
coverage
codecov
nose
35 changes: 35 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[metadata]
# replace with your username:
name = imgkit
version = 1.2.0
author = Jarrekk
author_email = [email protected]
description = Wkhtmltopdf python wrapper to convert html to image using the webkit rendering engine and qt
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/jarrekk/imgkit
project_urls =
Bug Tracker = https://github.com/jarrekk/imgkit/issues
classifiers =
Programming Language :: Python
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Topic :: Text Processing
Topic :: Text Processing :: General
Topic :: Text Processing :: Markup
Topic :: Text Processing :: Markup :: HTML
Topic :: Text Processing :: Markup :: XML
Topic :: Utilities

[options]
package_dir =
= src
packages = find:

[options.packages.find]
where = src
63 changes: 5 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,8 @@
# -*- coding: utf-8 -*-
from distutils.core import setup
from setuptools.command.test import test
import os
import sys
import imgkit


class PyTest(test):
def finalize_options(self):
test.finalize_options(self)
self.test_args = ['imgkit_test.py']
self.test_suite = True

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
os.chdir('test/')
err_no = pytest.main(self.test_args)
sys.exit(err_no)


def long_description():
try:
import pypandoc
long_desc = pypandoc.convert_file('README.md', 'rst')
long_desc += '\n' + pypandoc.convert_file('AUTHORS.md', 'rst')
except Exception as e:
print(e)
long_desc = imgkit.__doc__.strip()
return long_desc

from setuptools import setup

setup(
name='imgkit',
version=imgkit.__version__,
description=imgkit.__doc__.strip(),
long_description=long_description(),
download_url='https://github.com/jarrekk/imgkit',
license=imgkit.__license__,
tests_require=['pytest'],
cmdclass={'test': PyTest},
packages=['imgkit'],
author=imgkit.__author__,
author_email=imgkit.__contact__,
url=imgkit.__homepage__,
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Text Processing',
'Topic :: Text Processing :: General',
'Topic :: Text Processing :: Markup',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Text Processing :: Markup :: XML',
'Topic :: Utilities'
]
name="imgkit",
install_requires=[
"six",
],
)
3 changes: 1 addition & 2 deletions imgkit/__init__.py → src/imgkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

__author__ = "jarrekk"
__contact__ = "[email protected]"
__version__ = "1.1.0"
__homepage__ = "https://github.com/jarrekk/imgkit"
__license__ = "MIT"

from .api import config, from_file, from_string, from_url
from .imgkit import IMGKit
from .api import from_url, from_file, from_string, config
File renamed without changes.
File renamed without changes.
9 changes: 2 additions & 7 deletions imgkit/imgkit.py → src/imgkit/imgkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
from .config import Config
import io
import codecs

# Python 2.x and 3.x support for checking string types
try:
assert basestring
except NameError:
basestring = str
from six import string_types


class IMGKit(object):
Expand Down Expand Up @@ -111,7 +106,7 @@ def _command(self, path=None):
if self.source.isString() or self.source.isFileObj():
yield '-'
else:
if isinstance(self.source.source, basestring):
if isinstance(self.source.source, string_types):
yield self.source.to_s()
else:
for s in self.source.source:
Expand Down
File renamed without changes.
Loading

0 comments on commit f4c3a77

Please sign in to comment.