sopel-irc / cookiecutter-sopel

Cookiecutter template for Sopel plugins
3 stars 9 forks source link

Fix installation of generated packages #2

Closed maxpowa closed 9 years ago

maxpowa commented 9 years ago

When attempting to pip install . https://github.com/maxpowa/sopel-idlerpg a simple module created by cookiecutter, it appears to throw the ValueError when collecting the requirements.txt values.

(Snakepit)maxpowa@irc:~/sopel-idlerpg$ pip install .
Processing /home/maxpowa/sopel-idlerpg
    Complete output from command python setup.py egg_info:
    Sopel does not correctly load modules installed with setup.py directly. Please use "pip install .", or add /tmp/pip-PaYJMs-build/sopel_modules to core.extra in your config.
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-PaYJMs-build/setup.py", line 43, in <module>
        license='Eiffel Forum License, version 2',
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/maxpowa/Snakepit/local/lib/python2.7/site-packages/setuptools/dist.py", line 270, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 259, in __init__
        getattr(self.metadata, "set_" + key)(val)
      File "/usr/lib/python2.7/distutils/dist.py", line 1220, in set_requires
        distutils.versionpredicate.VersionPredicate(v)
      File "/usr/lib/python2.7/distutils/versionpredicate.py", line 113, in __init__
        raise ValueError("expected parenthesized list: %r" % paren)
    ValueError: expected parenthesized list: '>=6.0,<7'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-PaYJMs-build

If I wrap the versions in parentheses like it asks, I get another error claiming invalid version number '7'.

(Snakepit)maxpowa@irc:~/sopel-idlerpg$ pip install .
Processing /home/maxpowa/sopel-idlerpg
    Complete output from command python setup.py egg_info:
    Sopel does not correctly load modules installed with setup.py directly. Please use "pip install .", or add /tmp/pip-gs372sex-build/sopel_modules to core.extra in your config.
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-gs372sex-build/setup.py", line 43, in <module>
        license='Eiffel Forum License, version 2',
      File "/usr/lib/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/maxpowa/Snakepit/lib/python3.4/site-packages/setuptools/dist.py", line 272, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib/python3.4/distutils/dist.py", line 252, in __init__
        getattr(self.metadata, "set_" + key)(val)
      File "/usr/lib/python3.4/distutils/dist.py", line 1209, in set_requires
        distutils.versionpredicate.VersionPredicate(v)
      File "/usr/lib/python3.4/distutils/versionpredicate.py", line 116, in __init__
        self.pred = [splitUp(aPred) for aPred in str.split(",")]
      File "/usr/lib/python3.4/distutils/versionpredicate.py", line 116, in <listcomp>
        self.pred = [splitUp(aPred) for aPred in str.split(",")]
      File "/usr/lib/python3.4/distutils/versionpredicate.py", line 26, in splitUp
        return (comp, distutils.version.StrictVersion(verStr))
      File "/usr/lib/python3.4/distutils/version.py", line 40, in __init__
        self.parse(vstring)
      File "/usr/lib/python3.4/distutils/version.py", line 143, in parse
        raise ValueError("invalid version number '%s'" % vstring)
    ValueError: invalid version number '7'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-gs372sex-build

If I change the requirements.txt to be sopel(>=6.0,<7.0), then it gives me

(Snakepit)maxpowa@irc:~/sopel-idlerpg$ pip install .
Processing /home/maxpowa/sopel-idlerpg
    Complete output from command python setup.py egg_info:
    Sopel does not correctly load modules installed with setup.py directly. Please use "pip install .", or add /tmp/pip-j0v3SD-build/sopel_modules to core.extra in your config.
    error in sopel_modules.idlerpg setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-j0v3SD-build

Removing the install_requires=requirements from line 40 of the setup.py appeared to be the only way to resolve this.

On another note, since sopel_modules is a Namespace Package, it's supposed to have a very specific string in its __init__.py. I've included this change as well.

elad661 commented 9 years ago

This looks correct to me, but I want @embolalia's approval before merging.

maxpowa commented 9 years ago

Actually right now its still not correct. This just fixes pip going through, the drawback is that it now won't download sopel/dependencies in dependencies.txt . I don't know enough about setuptools/pip to properly fix that part without having sopel & other deps listed directly in setup.py On Oct 20, 2015 2:08 PM, "Elad Alfassa" notifications@github.com wrote:

This looks correct to me, but I want @embolalia https://github.com/embolalia's approval before merging.

— Reply to this email directly or view it on GitHub https://github.com/sopel-irc/sopel-cookiecutter/pull/2#issuecomment-149703786 .

embolalia commented 9 years ago

It seems the actual solution is to remove requires= and not install_requires=. Of course, this is documented absolutely nowhere. Thanks for catching this, @maxpowa.