Tool to automate porting of Python 2-only packages to both Python 2&3 and sending pull requests
https://github.com/PythonCharmers/autoporter
Automate porting of Py2 packages to Py3 while preserving compatibility with Py2.
write a script that takes a package name as an argument and does this:
-
Py3?: Examines whether it already has the Python 3 (or 3.3 or 3.4) trove classifier. If so, exit. DONE in
tests/test_package.py
(Chee Ming). -
GitHub?: Examines whether there is a github link on the PyPI page. If not, exit. DONE in
tests/test_package.py
. -
Env: Creates a virtualenv for the package
-
Fork: Forks the package repo on GitHub
-
Clone: Clones the package to the local filesystem
-
Futurize: Runs futurize --stage1 on the code
-
Commit: Commits the changes locally
-
Test: If the package has a test suite, try running it with
python setup.py test
. -
Push: Pushes the changes to the new GitHub repo
-
PR: Sends a pull request (marked "Work In Progress") upstream
Run this script over all 47,000 packages on PyPI! :)
We can run this from e.g. an EC2 or Digital Ocean instance that has an SSD disk and is geographically close to the PyPI server.
see docs/CONTRIBUTORS.rst
-
Githubpy: http://github.liaoxuefeng.com/githubpy/
-
Caniusepython3: https://github.com/brettcannon/caniusepython3
This has routines we can use to extract Trove classifiers (whether a package supports Py3 etc.)
- futurize: http://python-future.org:
$ pip install future
$ futurize --stage1 **/*.py
with recursive globbing (default in zsh
, or in bash
with shopt -s globstar
set).
- Miniconda Python distribution (Ed's recommendation for easily creating side-by-side Py2 and Py3 environments): http://conda.pydata.org/miniconda.html
To run tests for the autoporter code base:
python -m unittest discover -v tests
- This will require packages to set Python 2.6 as their minimum supported version.