From 0b92a6075915169d33eb0135e69ab49faa231e12 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 4 Oct 2019 09:53:54 +0100 Subject: [PATCH 1/4] use declarative metadata --- setup.cfg | 47 ++++++++++++++++++++++++++++++++++ setup.py | 75 +------------------------------------------------------ src.py | 9 +++++++ 3 files changed, 57 insertions(+), 74 deletions(-) create mode 100644 src.py diff --git a/setup.cfg b/setup.cfg index 9b77116701..f5a3466c45 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,50 @@ +[metadata] +name = httpx +version = attr: src.get_version +url = https://github.com/encode/httpx +license = BSD +description = The next generation HTTP client. +long_description = file: README.md, file: CHANGELOG.md +long_description_content_type = text/markdown +author = Tom Christie +author_email = tom@tomchristie.com +classifiers = + Development Status :: 3 - Alpha + Environment :: Web Environment + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Operating System :: OS Independent + Topic :: Internet :: WWW/HTTP + Framework :: AsyncIO + Framework :: Trio + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + +[options] +python_requires = >=3.6 +packages = find: +include_package_data = True +zip_safe = False +install_requires = + certifi + chardet==3.* + h11==0.8.* + h2==3.* + hstspreload>=2019.8.27 + idna==2.* + rfc3986==1.* + +[options.packages.find] +include = + httpx + httpx.* + +[options.package_data] +httpx = + py.typed + [bdist_wheel] universal = 1 diff --git a/setup.py b/setup.py index bb16e9631b..606849326a 100644 --- a/setup.py +++ b/setup.py @@ -1,76 +1,3 @@ -#!/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__` in `init.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", - python_requires=">=3.6", - version=get_version("httpx"), - url="https://github.com/encode/httpx", - license="BSD", - description="The next generation HTTP client.", - long_description=get_long_description(), - long_description_content_type="text/markdown", - author="Tom Christie", - author_email="tom@tomchristie.com", - package_data={"httpx": ["py.typed"]}, - packages=get_packages("httpx"), - include_package_data=True, - zip_safe=False, - install_requires=[ - "certifi", - "chardet==3.*", - "h11==0.8.*", - "h2==3.*", - "hstspreload>=2019.8.27", - "idna==2.*", - "rfc3986==1.*", - ], - classifiers=[ - "Development Status :: 3 - Alpha", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Topic :: Internet :: WWW/HTTP", - "Framework :: AsyncIO", - "Framework :: Trio", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - ], -) +setup() diff --git a/src.py b/src.py new file mode 100644 index 0000000000..fbc817ee49 --- /dev/null +++ b/src.py @@ -0,0 +1,9 @@ +import pathlib +import re + +PACKAGE = "httpx" + + +def get_version(package=PACKAGE): + version = pathlib.Path(package, "__version__.py").read_text() + return re.search("__version__ = ['\"]([^'\"]+)['\"]", version).group(1) From efba460e0e5d002e619165b990e6a29cf0bc3105 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 4 Oct 2019 12:43:46 +0100 Subject: [PATCH 2/4] remove include_package_data and MANIFEST.in Fixes #193 --- MANIFEST.in | 3 --- setup.cfg | 1 - 2 files changed, 4 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ddac380d8f..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include CHANGELOG.md -include LICENSE.md diff --git a/setup.cfg b/setup.cfg index f5a3466c45..552d920ce1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,6 @@ classifiers = [options] python_requires = >=3.6 packages = find: -include_package_data = True zip_safe = False install_requires = certifi From 0eb6b3cfc02cb04b8f52cb30d913cbd3173b3abd Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 4 Oct 2019 14:59:41 +0100 Subject: [PATCH 3/4] test that httpx/py.typed shows up in sdist and whl --- .travis.yml | 2 ++ noxfile.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/.travis.yml b/.travis.yml index 550e55df93..32870596c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ matrix: env: NOX_SESSION=check - python: 3.7 env: NOX_SESSION=docs + - python: 3.7 + env: NOX_SESSION=check_dist - python: 3.6 env: NOX_SESSION=test-3.6 diff --git a/noxfile.py b/noxfile.py index 747e30ef6b..039246aa1f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,8 @@ +import pathlib +import re +import tarfile +import zipfile + import nox nox.options.stop_on_first_error = True @@ -48,3 +53,36 @@ def docs(session): def test(session): session.install("-r", "test-requirements.txt") session.run("python", "-m", "pytest", *session.posargs) + + +@nox.session(reuse_venv=True) +def check_dist(session): + output = session.run("python", "setup.py", "sdist", "bdist_wheel", silent=True) + assert ( + re.search(r"(?m)^copying httpx/py\.typed -> httpx-[^/]+/httpx$", output) + is not None + ) + assert ( + re.search( + r"(?m)^copying build/lib/httpx/py\.typed -> " + r"build/bdist\.[^/]+/wheel/httpx$", + output, + ) + is not None + ) + assert re.search(r"(?m)^adding 'httpx/py\.typed'$", output) is not None + + def tgz_has_py_typed(p: pathlib.Path) -> bool: + with tarfile.open(p) as sdist: + return any( + re.match(r"httpx-[^/]+/httpx/py\.typed", member.name) + for member in sdist + ) + + def whl_has_py_typed(p: pathlib.Path) -> bool: + with zipfile.ZipFile(p) as whl: + return whl.getinfo("httpx/py.typed").file_size == 0 + + dist_dir = pathlib.Path("dist") + assert [tgz_has_py_typed(sdist) for sdist in dist_dir.glob("**/*.tar.gz")] == [True] + assert [whl_has_py_typed(whl) for whl in dist_dir.glob("**/*.whl")] == [True] From caa04c902a24ae46f3c460aaa13a7b1092fab988 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 4 Oct 2019 20:56:11 +0100 Subject: [PATCH 4/4] Revert "Ensure py.typed makes it into source distributions. (#441)" This reverts commit b479ceb24fc37e64b2d87e7842099cdd9dde4033. --- MANIFEST.in | 1 - 1 file changed, 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 61e3dfa59f..ddac380d8f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ include README.md include CHANGELOG.md include LICENSE.md -include httpx/py.typed