Skip to content

Commit ff222be

Browse files
committed
configure to prepare for PyPI release
1 parent 7514b08 commit ff222be

File tree

8 files changed

+129
-36
lines changed

8 files changed

+129
-36
lines changed

.codecov.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
comment:
2+
layout: "header, diff, tree"
3+
4+
coverage:
5+
status:
6+
project: false

.github/workflows/publish.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: publish
5+
6+
on:
7+
push:
8+
tags:
9+
- "[0-9]+.[0-9]+.[0-9]+"
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
if: startsWith(github.ref, 'refs/tags')
27+
env:
28+
TWINE_USERNAME: __token__
29+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
30+
run: |
31+
python setup.py sdist bdist_wheel
32+
twine upload dist/*

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.coverage
2+
.mypy_cache/
3+
.tox/
4+
dist/
5+
htmlcov/
6+
coverage.xml
7+
docs/_build
8+
*.egg-info/
9+
__pycache__/

CHANGES.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Changes
2+
=======
3+
4+
0.1.0 (2022-02-03)
5+
------------------
6+
7+
* Initial release

README.md

-33
This file was deleted.

README.rst

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
===============
2+
scrapy-zyte-api
3+
===============
4+
5+
.. image:: https://img.shields.io/pypi/v/scrapy-zyte-api.svg
6+
:target: https://pypi.python.org/pypi/scrapy-zyte-api
7+
:alt: PyPI Version
8+
9+
.. image:: https://img.shields.io/pypi/pyversions/scrapy-zyte-api.svg
10+
:target: https://pypi.python.org/pypi/scrapy-zyte-api
11+
:alt: Supported Python Versions
12+
13+
.. image:: https://github.com/scrapy-plugins/scrapy-zyte-api/actions/workflows/test.yml/badge.svg
14+
:target: https://github.com/scrapy-plugins/scrapy-zyte-api/actions/workflows/test.yml
15+
:alt: Automated tests
16+
17+
.. image:: https://codecov.io/github/scrapinghub/scrapy-zyte-api/coverage.svg?branch=master
18+
:target: https://codecov.io/gh/scrapinghub/scrapy-zyte-api
19+
:alt: Coverage report
20+
21+
Installation
22+
------------
23+
24+
.. code-block::
25+
26+
pip install scrapy-zyte-api
27+
28+
This package requires Python 3.7+.
29+
30+
How to configure
31+
----------------
32+
33+
Replace the default ``http`` and ``https`` in Scrapy's
34+
`DOWNLOAD_HANDLERS <https://docs.scrapy.org/en/latest/topics/settings.html>`_.
35+
36+
.. code-block:: python
37+
38+
DOWNLOAD_HANDLERS = {
39+
"http": "scrapy_zyte_api.handler.ScrapyZyteAPIDownloadHandler",
40+
"https": "scrapy_zyte_api.handler.ScrapyZyteAPIDownloadHandler"
41+
}
42+
43+
Also, make sure to `install the asyncio-based Twisted reactor
44+
<https://docs.scrapy.org/en/latest/topics/asyncio.html#installing-the-asyncio-reactor)>`_ :
45+
46+
.. code-block:: python
47+
48+
TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
49+
50+
How to use
51+
----------
52+
53+
Set the ``zyte_api`` `Request.meta
54+
<https://docs.scrapy.org/en/latest/topics/request-response.html#scrapy.http.Request.meta>`_
55+
key to download a request using Zyte API. Full list of parameters is provided in the
56+
`Zyte API Specification <https://docs.zyte.com/zyte-api/openapi.html#zyte-openapi-spec>`_.
57+
58+
.. code-block:: python
59+
60+
yield scrapy.Request(
61+
"http://books.toscrape.com/",
62+
callback=self.parse,
63+
meta={
64+
"zyte_api": {
65+
"browserHtml": True,
66+
"geolocation": "US",
67+
"javascript": True,
68+
"echoData": {"something": True}
69+
}
70+
}
71+
)

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
name="scrapy-zyte-api",
55
version="0.0.0",
66
description="Client library to process URLs through Zyte API",
7-
long_description=open("README.md").read(),
8-
long_description_content_type="text/markdown",
7+
long_description=open("README.rst").read(),
8+
long_description_content_type="text/x-rst",
99
author="Zyte Group Ltd",
1010
author_email="[email protected]",
1111
url="https://github.com/scrapy-plugins/scrapy-zyte-api",

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ commands =
1111
-r {toxinidir}/tests/requirements.txt
1212
py.test \
1313
--cov-report=html:coverage-html \
14-
--cov-report= --cov=scrapy_zyte_api \
14+
--cov-report=xml \
15+
--cov=scrapy_zyte_api \
1516
--junitxml=test-results/junit.xml \
1617
{posargs:scrapy_zyte_api tests}
1718

0 commit comments

Comments
 (0)