-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify zip_safe=False
recommendation for PEP 561
#8802
Comments
Hi! Yeah this is a weirder edge of setuptools. For mypy to work, it needs to be able to read files off the disk, and it currently won't unzip eggs (this is something that mypy could support, but makes our already very complicated module searching code even more complicated). My understanding is that in some cases, such as running E: also, I'm a bit surprised that Jason said the flag shouldn't be passed, because when I talked to him at PyCon a couple of years back, he seemed to indicate that packaging tools are moving away from doing egg installs. |
Yeah that seems like a good idea. I'd be happy to review a PR if you'd like to make one. |
Eggs are deprecated. As is |
Hm, unfortunately a lot of people still use |
zip_safe=False was added because of a mypy recommendation when packinging 'py.typed'. But is seems this is outdated and for the case where `setup.py install` needs to be supported. See: python/mypy#8802 (comment)
What's the recommended alternative? |
@YodaEmbedding most people probably should be using |
I looked into this and found this comment: python/mypy#8802 (comment) Also, even if using `setup.py install` setuptools will automatically add the flag if it detects any package data present. https://setuptools.readthedocs.io/en/latest/userguide/miscellaneous.html#setting-the-zip-safe-flag
I looked into this and found this comment: python/mypy#8802 (comment) Also, even if using `setup.py install` setuptools will automatically add the flag if it detects any package data present. https://setuptools.readthedocs.io/en/latest/userguide/miscellaneous.html#setting-the-zip-safe-flag
This commit adds a py.typed file, which marks the package as having type information available. For more information, see https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages The zip_safe seems to be [still necessary](encode/httpx#193 (reference)), even though it is [deprecated](python/mypy#8802).
All of the Python code in this package is fully typed. That's great (and essential), but typechecking tools like MyPy weren't able to say if it was OK to use the typing info in these modules. The way for indicating this is PIP 561 (https://www.python.org/dev/peps/pep-0561/), which for us means putting a `py.typed` file at the root of each module we provide. The file can be empty; it's the presence of the file that provides the signal to type-checkers. This also modifies `MANIFEST.in` to ensure the `py.typed` files are bundled into distributions. Finally, `zip_safe` is disabled in `setup.cfg`. This ensures that, when someone tries to install this software using `setup.py install`, it will not attempt to produce an egg file. This is needed because MyPy does not look inside egg files when searching for module type information (see python/mypy#8802 for more details). People shouldn't be using `setup.py` directly anymore anyway, packages should be installed using `pip` (for example, `pip install stanford-mais`, or `pip install .` if installing from a Git clone). Closes: #1
python setup.py install is basically dead; this no longer appears in mypy docs |
This commit adds a py.typed file, which marks the package as having type information available. For more information, see https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages The zip_safe seems to be [still necessary](encode/httpx#193 (reference)), even though it is [deprecated](python/mypy#8802).
In pypa/twine#618, I'm adding
py.typed
so that Twine's type annotations are recognized when it's used as an installed package. I've setzip_safe=False
as suggested by the mypy docs:However, one of the other maintainers has requested removing this: pypa/twine#618 (comment)
The only references I've found to
zip_safe
in the mypy repo are:I've done some cursory testing without setting
zip_safe
, including usingpip install -e path/to/twine
, and it doesn't seem to be necessary. However, the note quoted above seems unequivocal. Is it still accurate? Could it be expanded?Caveat: I've only skimmed the issues above, and am far from an expert on the various use cases of setuptools, esp. editable installs.
The text was updated successfully, but these errors were encountered: