In a Python 3 project, I used to install wikitools by adding a line in requirements.txt pointing to the py3 branch looking this this:
-e git+https://github.com/alexz-enwp/wikitools.git@py3#egg=wikitools
This works fine for development purposes. However, for releasing the package, it is recommended to define dependencies in setup.py instead, as Donald Stufft (the core developer of PyPI) explains in this blog post. However, in a nutshell, a setup.py in of the following form will install the Python 2 version from PyPI instead of the Python 3 version from GitHub:
from setuptools import setup
setup(
dependency_links = [
'https://github.com/alexz-enwp/wikitools/tarball/py3#egg=wikitools_py3-1.2'
],
install_requires = [
'wikitools==1.2'
]
)
The problem is that wikitools is already available in version 1.2 (and 1.3) on PyPI, so pip will give it priority. The py3 branch contains something labeled as version 1.2, which will therefore be ignored by pip.
The problem can be solved in three ways:
- The
wikitoolsmodule for Python 3 is renamed into something like wikitools_py3. Without starting a new repository, this can be achieved by simply changing the name parameter in wikitools' own setup.py in the existing py3 branch. EDIT: It actually requires a lot of changes, more than I thought, see pull request, so the next option might be a lot easier.
- Alternatively (temporarily) the
version parameter in wikitools' own setup.py in the py3 branch can be pumped to something higher than what is available on PyPI, e.g. 1.4 (as of today's latest version on PyPI being 1.3).
- The ideal (theoretical) solution would be if
wikitools had a common codebase for supporting both Python 2 and Python 3, which wont be trivial ...
For reference, two related discussions on StackOverflow:
In a Python 3 project, I used to install
wikitoolsby adding a line inrequirements.txtpointing to thepy3branch looking this this:This works fine for development purposes. However, for releasing the package, it is recommended to define dependencies in
setup.pyinstead, as Donald Stufft (the core developer of PyPI) explains in this blog post. However, in a nutshell, asetup.pyin of the following form will install the Python 2 version from PyPI instead of the Python 3 version from GitHub:The problem is that
wikitoolsis already available in version 1.2 (and 1.3) on PyPI, so pip will give it priority. Thepy3branch contains something labeled as version 1.2, which will therefore be ignored by pip.The problem can be solved in three ways:
wikitoolsmodule for Python 3 is renamed into something likewikitools_py3. Without starting a new repository, this can be achieved by simply changing thenameparameter inwikitools' ownsetup.pyin the existingpy3branch. EDIT: It actually requires a lot of changes, more than I thought, see pull request, so the next option might be a lot easier.versionparameter inwikitools' ownsetup.pyin thepy3branch can be pumped to something higher than what is available on PyPI, e.g. 1.4 (as of today's latest version on PyPI being 1.3).wikitoolshad a common codebase for supporting both Python 2 and Python 3, which wont be trivial ...For reference, two related discussions on StackOverflow: