Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check requirements for python 3 support

I have several python projects with different set of dependencies listed in pip requirements files. I've started to think about porting the code to python 3, but I need to know if my dependencies are already there.

Is it possible to check what packages from a requirements.txt file support python 3 and what don't?

Example requirements.txt contents:

mysql-python==1.2.5
lxml==3.3.4
Fabric==1.8.0

From this list, only lxml supports python 3.


Just a side note.

There is a Python 3 Wall of Superpowers (python3wos project) that shows python 3 support of popular python packages.

As far as I understand, python3wos periodically parses the Python Package Index html pages and checks for the Programming Language :: Python :: 3 text to define whether a packages supports python 3rd branch or not. Isn't there anything simpler than scraping the html on PyPI?

like image 488
alecxe Avatar asked Apr 09 '14 01:04

alecxe


People also ask

How do I know if Python 3 is compatible?

Just open the python files in the pycharm editor, it will show warnings if the code is not compatible to Python2 or Python3. Here is the screenshot where it shows print command syntax warning. Minimum Individual cost is $89/year. Is this still erroneous in today's Python 3?

How do I know if a Python package is compatible?

If you are using an older version of Python and need the most recent version of the package that is compatible with that version, you can go to the release history (the second link at the top of the sidebar) and try different versions, scrolling down to the "Meta" section for every version.

How do I install Python requirements?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.

How do I check my pip dependency?

Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.


1 Answers

With the help of @thefourtheye and py3readiness.org sources, I've found exactly what I needed.

caniusepython3 module by Brett Cannon:

Determine what projects are blocking you from porting to Python 3

This script takes in a set of dependencies and then figures out which of them are holding you up from porting to Python 3.

Example (for the requirements.txt from the question):

$ caniusepython3 -r requirements.txt 
Finding and checking dependencies ...

You need 2 projects to transition to Python 3.
Of those 2 projects, 2 have no direct dependencies blocking their transition:

  fabric
  mysql-python

I should note that it still uses the same approach as python3wos - looking for Programming Language :: Python :: 3x classifiers on the package page.

There is also a web-interface where you can type your dependencies or drop a requirements.txt file.

like image 102
alecxe Avatar answered Sep 21 '22 19:09

alecxe