I've worked on adding Python 3.5 type hints to the responses library. But when I test making a distribution, sdist
or bdist_wheel
, it doesn't install my .pyi
file. I can see it being part of the distribution, but it doesn't go further than that.
You can see what I got in my repo here: https://github.com/gaqzi/responses/tree/feature/type-hints-file
I read PEP484 which mentions that stub files should be distributable. But I can't seem to figure out how. :)
Is there a problem because responses doesn't create a package? It's just a single module file and that's why it doesn't get added correctly?
What I see when I build the package:
% python setup.py sdist
running sdist
running egg_info
writing requirements to responses.egg-info/requires.txt
writing top-level names to responses.egg-info/top_level.txt
writing responses.egg-info/PKG-INFO
writing dependency_links to responses.egg-info/dependency_links.txt
reading manifest file 'responses.egg-info/SOURCES.txt'
writing manifest file 'responses.egg-info/SOURCES.txt'
running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too
creating responses-0.6.0
creating responses-0.6.0/responses.egg-info
making hard links in responses-0.6.0...
hard linking README.rst -> responses-0.6.0
hard linking responses.py -> responses-0.6.0
hard linking responses.pyi -> responses-0.6.0
hard linking setup.cfg -> responses-0.6.0
hard linking setup.py -> responses-0.6.0
hard linking responses.egg-info/PKG-INFO -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/SOURCES.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/dependency_links.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/not-zip-safe -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/requires.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/top_level.txt -> responses-0.6.0/responses.egg-info
copying setup.cfg -> responses-0.6.0
Writing responses-0.6.0/setup.cfg
Creating tar archive
removing 'responses-0.6.0' (and everything under it)
After I've installed the package I got this:
% pip install dist/responses-0.6.0.tar.gz
[...snip...]
Installing collected packages: responses
Successfully installed responses-0.6.0
% pwd
/Users/ba/.virtualenvs/responses/lib/python3.5/site-packages
% ls responses*
responses.py
responses-0.6.0.dist-info:
DESCRIPTION.rst METADATA RECORD WHEEL metadata.json top_level.txt
According to the mypy docs, you should pass package_data={"my_package": ["py.typed", "foo.pyi"]}
as an argument to setup
in setup.py
. Note that "foo.pyi"
is the relative path from the root of the package to be distributed to the
stub file (docs).
I've created an example repo where you can test this out at https://github.com/SKalt/stub_distrib_demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With