Repository: encode/httpx

Issue:
AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'
Just did a pip install of httpx, and it appeared to meet all the pre-reqs. However, I'd encounter the error in the title.


(python37) $ pip install httpx
Collecting httpx
  Using cached https://files.pythonhosted.org/packages/15/fb/81861a0dbe87a0de57491b1b587419845f9a99e5b3d48e56cd440b1fcb68/httpx-0.7.6-py2.py3-none-any.whl
Requirement already satisfied: certifi in .../envs/python37/lib/python3.7/site-packages (from httpx) (2019.6.16)
Requirement already satisfied: h2==3.* in .../envs/python37/lib/python3.7/site-packages (from httpx) (3.1.0)
Requirement already satisfied: chardet==3.* in .../envs/python37/lib/python3.7/site-packages (from httpx) (3.0.4)
Requirement already satisfied: h11==0.8.* in .../envs/python37/lib/python3.7/site-packages (from httpx) (0.8.1)
Requirement already satisfied: rfc3986==1.* in .../envs/python37/lib/python3.7/site-packages (from httpx) (1.2.0)
Requirement already satisfied: idna==2.* in .../envs/python37/lib/python3.7/site-packages (from httpx) (2.8)
Collecting hstspreload>=2019.8.27 (from httpx)
  Downloading https://files.pythonhosted.org/packages/55/77/e0031fbb2930891db135af5a53afdf5567ca6f1b1ff55bf231ed5330f66d/hstspreload-2019.11.4.tar.gz (701kB)
     |████████████████████████████████| 706kB 740kB/s 
Requirement already satisfied: hpack<4,>=2.3 in .../envs/python37/lib/python3.7/site-packages (from h2==3.*->httpx) (3.0.0)
Requirement already satisfied: hyperframe<6,>=5.2.0 in .../envs/python37/lib/python3.7/site-packages (from h2==3.*->httpx) (5.2.0)
Building wheels for collected packages: hstspreload
  Building wheel for hstspreload (setup.py) ... done
  Created wheel for hstspreload: filename=hstspreload-2019.11.4-cp37-none-any.whl size=704190 sha256=ac82e6b8abe795fa1a179318d64d73660fa3024715b04b7db0746971c3e5a87b
  Stored in directory: .../Library/Caches/pip/wheels/49/f1/9d/dc01d2c108593d8d2c32d00cdd9daf595e6ad4a727d57b7033
Successfully built hstspreload
Installing collected packages: hstspreload, httpx
Successfully installed hstspreload-2019.11.4 httpx-0.7.6

Manually upgrading rfc3986 to 1.3.2 resolved the issue. Seems the installer should be checking for rfc3986==1.3.2 or greater? 


Discussion:
Can confirm this happening when installing `rfc3986==1.2`:

```console
❯ pip install httpx rfc3986==1.2
Requirement already satisfied: httpx in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (0.7.6)
Collecting rfc3986==1.2
  Using cached https://files.pythonhosted.org/packages/e1/59/1d547e9e5e1bf8074951067c3d6b31a2e29fd5b49bd7d32e53ff0da6406c/rfc3986-1.2.0-py2.py3-none-any.whl
Requirement already satisfied: certifi in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.9.11)
Requirement already satisfied: chardet==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.0.4)
Requirement already satisfied: idna==2.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2.8)
Requirement already satisfied: h11==0.8.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (0.8.1)
Requirement already satisfied: hstspreload>=2019.8.27 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (2019.10.31)
Requirement already satisfied: h2==3.* in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from httpx) (3.1.1)
Requirement already satisfied: hyperframe<6,>=5.2.0 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (5.2.0)
Requirement already satisfied: hpack<4,>=2.3 in ./.pyenv/versions/3.8.0/lib/python3.8/site-packages (from h2==3.*->httpx) (3.0.0)
Installing collected packages: rfc3986
  Found existing installation: rfc3986 1.3.0
    Uninstalling rfc3986-1.3.0:
      Successfully uninstalled rfc3986-1.3.0
Successfully installed rfc3986-1.2.0

~ took 4s
❯ python
Python 3.8.0 (default, Oct 16 2019, 18:21:21)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import httpx
>>> httpx.get("https://httpbin.org")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 122, in get
    return request(
  File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/api.py", line 80, in request
    with Client(http_versions=["HTTP/1.1"]) as client:
  File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/client.py", line 107, in __init__
    self.base_url = URL("", allow_relative=True)
  File "/Users/florimond/.pyenv/versions/3.8.0/lib/python3.8/site-packages/httpx/models.py", line 108, in __init__
    self._uri_reference = rfc3986.api.iri_reference(url).encode()
AttributeError: module 'rfc3986.api' has no attribute 'iri_reference'
```

1.3.0 is fine, though — probably because `iri_reference` was introduced in 1.3, as indicated by the the [rfc3986 pull requests](https://github.com/python-hyper/rfc3986/pulls) page. For reference, it seems we switched to `iri_reference` in https://github.com/encode/httpx/pull/161.

If you're up for it, we'll gladly accept a pull request for this change. :-)

Just going to cc @sethmlarson as he's leading maintenance on `rfc3986` I believe.
Yep, rfc3986 didn't support IRIs pre 1.3 so we should probably mention that if we want to continue using rfc3986 as our URL parser.
https://github.com/encode/httpx/blob/2fcf23bbfe41c5526cb35a65d32dd98dde786988/setup.py#L60 should become
```py
"rfc3986>=1.3,<2",
```
then?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -57,7 +57,7 @@ def get_packages(package):
         "h11==0.8.*",
         "h2==3.*",
         "idna==2.*",
-        "rfc3986==1.*",
+        "rfc3986>=1.3,<2",
         "sniffio==1.*",
     ],
     classifiers=[


Test patch: