Skip to content

Commit

Permalink
Add python packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
johtso committed Mar 18, 2022
1 parent c52f2fc commit a19026a
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 26 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
push:
tags:
- '*'

jobs:
publish:
name: "Publish release"
runs-on: "ubuntu-latest"

environment:
name: deploy

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: 3.9
- name: "Install dependencies"
run: "scripts/install"
- name: "Build packag"
run: "scripts/build"
- name: "Publish to PyPI"
run: "scripts/publish"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
run: "scripts/check"
- name: "Generate sync code"
run: "scripts/compile"
- name: "Build package"
run: "scripts/build"
- name: "Run tests"
run: "scripts/test"
- name: "Enforce coverage"
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.1a1 (18th February, 2022)

First PyPI release.
21 changes: 0 additions & 21 deletions dev_requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions httpx_caching/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__title__ = "httpx-caching"
__description__ = "Caching for HTTPX."
__version__ = "0.1a1"
Empty file added httpx_caching/py.typed
Empty file.
29 changes: 25 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
httpx==0.22.*
msgpack
anyio
multimethod
# Packaging
twine==3.7.1
wheel==0.37.0

# Testing
autoflake==1.4
black==22.1.0
CherryPy==18.6.1
coverage==6.3.2
flake8==4.0.1
flake8-bugbear==22.1.11
freezegun==1.2.0
isort==5.10.1
mock==4.0.3
mypy==0.941
pyparsing==3.0.7
pytest==7.1.0
pytest-asyncio==0.18.2
pytest-cov==3.0.0
pytest-mock==3.7.0
pytest-timeout==2.1.0
types-dataclasses==0.6.4
types-freezegun==1.1.7
types-mock==4.0.11
unasync==0.5.0
12 changes: 12 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh -e

if [ -d 'venv' ] ; then
PREFIX="venv/bin/"
else
PREFIX=""
fi

set -x

${PREFIX}python setup.py sdist bdist_wheel
${PREFIX}twine check dist/*
3 changes: 2 additions & 1 deletion scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Use the Python executable provided from the `-p` option, or a default.
[ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3"

REQUIREMENTS="dev_requirements.txt"
REQUIREMENTS="requirements.txt"
VENV="venv"

set -x
Expand All @@ -16,3 +16,4 @@ else
fi

"$PIP" install -r "$REQUIREMENTS"
"$PIP" install -e .
13 changes: 13 additions & 0 deletions scripts/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh -e

VERSION_FILE="httpx_caching/__version__.py"

if [ -d 'venv' ] ; then
PREFIX="venv/bin/"
else
PREFIX=""
fi

set -x

${PREFIX}twine upload dist/*
77 changes: 77 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
from pathlib import Path

from setuptools import setup


def get_version(package):
"""
Return package version as listed in `__version__.py`.
"""
version = Path(package, "__version__.py").read_text()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", version).group(1)


def get_long_description():
"""
Return the README.
"""
long_description = ""
with open("README.md", encoding="utf8") as f:
long_description += f.read()
# long_description += "\n\n"
# with open("CHANGELOG.md", encoding="utf8") as f:
# long_description += f.read()
return long_description


def get_packages(package):
"""
Return root package and all sub-packages.
"""
return [str(path.parent) for path in Path(package).glob("**/__init__.py")]


setup(
name="httpx-caching",
python_requires=">=3.7",
version=get_version("httpx_caching"),
url="https://github.com/johtso/httpx-caching",
project_urls={
"Source": "https://github.com/johtso/httpx-caching",
},
license="Apache-2.0",
description="Caching for HTTPX.",
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Johannes (johtso)",
author_email="[email protected]",
package_data={"httpx_caching": ["py.typed"]},
packages=get_packages("httpx_caching"),
include_package_data=True,
zip_safe=False,
install_requires=[
"httpx==0.22.*",
"msgpack",
"anyio",
"multimethod",
],
extras_require={},
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Internet :: WWW/HTTP",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
],
)

0 comments on commit a19026a

Please sign in to comment.