Skip to content

Py3 branch can not be installed with setuptools (dependency_links, install_requires), only through requirements.txt, due to version overload #50

@s-m-e

Description

@s-m-e

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions