Can I Use Python 3?
** NOTE ** This project is no longer actively developed!
You can read the documentation on how to use caniusepython3 from its PyPI page. A web interface is also available.
On PyPI each project can specify various trove classifiers (typically in a project's
setup.pythrough a
classifierargument to
setup()). There are various classifiers related to what version of Python a project can run on. E.g.:
Programming Language :: Python :: 3 Programming Language :: Python :: 3.0 Programming Language :: Python :: 3.1 Programming Language :: Python :: 3.2 Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7
As long as a trove classifier for some version of Python 3 is specified then the project is considered to support Python 3 (project owners: it is preferred you at least specify
Programming Language :: Python :: 3as that is how you end up listed on the Python 3 Packages list on PyPI; you can represent Python 2 support with
Programming Language :: Python). Note that Python 3.0 through 3.4 have reached their End Of Life.
The other way is through a manual override in
caniusepython3itself. Projects ends up on this list because:
If any of these various requirements are met, then a project is considered to support Python 3 and thus will be added to the manual overrides list. You can see the list of overrides when you use caniusepython3's CLI with verbose output turned on.
If a project has Python 3 support in a release on PyPI but they have not added the proper trove classifier, then either submit a pull request or file an issue with the name of the project and a link to some proof that a release available on PyPI has indeed been ported (e.g. PyPI page stating the support, tox.ini file showing tests being run against Python 3, etc.). Projects that have Python 3 support in their version control system but not yet available on PyPI will not be considered for inclusion in the overrides file.
Typically projects which have not switched to Python 3 yet are waiting for:
Since
caniusepython3will tell you what dependencies are blocking a project that you depend on from being ported, you can try to port a project farther down your dependency graph to help a more direct dependency make the transition.
Which brings up the second point: volunteering to do a port. Most projects happily accept help, they just have not done the port yet because they have not had the time ("volunteering" can also take the form of paying someone to do the port on your behalf). Some projects are simply waiting for people to ask for it, so even speaking up politely and requesting a port can get the process started.
If you are looking for help to port a project, you can always search online for various sources of help. If you want a specific starting point there are HOWTOs in the Python documentation on porting pure Python modules and extension modules.
Yes! Begin by installing pre-commit:
pip install pre-commit pre-commit install
You can add the following hook in your
.pre-commit-config.yamlfile.
- repo: https://github.com/brettcannon/caniusepython3 rev: v7.1.0 # Update as desired to new releases/tags hooks: - id: caniusepython3 files: requirements\.txt$ # Update to match your requirements files accordingly. args: [ -r # Causes caniusepython3 to treat the `files` argument as a requirements file. ] stages: [commit] # Change it to `manual`, if `caniusepython3` takes too long between commits, so as to only run them manually in build jobs.
If you are running manually somewhere, we can run the following command:
pre-commit run --hook-stage manual caniusepython3 --files requirements.txt
--index/
-iflag to specify an index URL (thanks macleodbroad-wf)
--excludeflag (thanks Milind Shakya)
3error code when a command completes successfully but there are found blockers (patch by pcattori; accidentally left out of the 4.0.0 release)
from __future__ import unicode_literals(issue #103; reported by David Euresti)
-v(patch by @msabramo)
setup.pyintegration (issue #80; patch by @msabramo)
filter,
map,
range, and
zipas they have been improved upon and merged upstream in Pylint
caniusepython3.pylint_checkerwhich extends
pylint --py3kwith very strict porting checks
xmlrpclib.Faultexception under Python 2.6 when trying to close an XML-RPC connection (can't close a connection under Python 2.6 anyway and the exception has only been seen on Travis)
setup.py caniusepython3to work with
extras_requireproperly
just_name()function to a new module in 2.0.0 (patch by Vaibhav Sagar w/ input from Jannis Leidel)
-r,
-m, and
-pnow take 1+ arguments instead of a single comma-separated list
icanusepython3.check()
-vto actually do something again
-raccepts a comma-separated list of file paths
Initial release.