eventbrite / invoke-release

A set of command line tools that help software engineers release Python projects quickly, easily, and in a consistent manner.
Apache License 2.0
0 stars 3 forks source link

ImportError: cannot import name 'archive' from 'wheel' #8

Closed dazza-codes closed 5 years ago

dazza-codes commented 5 years ago

Raised by https://github.com/eventbrite/invoke-release/blob/master/python/invoke_release/tasks.py#L16

$ pipenv --version
pipenv, version 2018.11.26

$ pip --version
pip 18.1 from /home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/pip (python 3.7)

$ pip freeze | grep invoke
invoke==1.2.0
invoke-release==4.0.5

$ wheel version
wheel 0.32.3

$ invoke version
Traceback (most recent call last):
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/bin/invoke", line 11, in <module>
    sys.exit(program.run())
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/invoke/program.py", line 352, in run
    self.parse_collection()
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/invoke/program.py", line 444, in parse_collection
    self.load_collection()
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/invoke/program.py", line 661, in load_collection
    module, parent = loader.load(coll_name)
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/invoke/loader.py", line 76, in load
    module = imp.load_module(name, fd, path, desc)
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/SNIPPED/src/jupiter/py_package_template/tasks.py", line 5, in <module>
    from invoke_release.tasks import *  # noqa: F403
  File "/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/invoke_release/tasks.py", line 16, in <module>
    from wheel import archive
ImportError: cannot import name 'archive' from 'wheel' (/home/SNIPPED/.local/share/virtualenvs/py_package_template-AfLMl-fG/lib/python3.7/site-packages/wheel/__init__.py
)
# tasks.py 
"""
Configure the invoke release task
"""

from invoke_release.tasks import *  # noqa: F403
from invoke_release.plugins import PatternReplaceVersionInFilesPlugin

configure_release_parameters(  # noqa: F405
    module_name='snipper',
    display_name='Snipper',
    python_directory='snipper',
    plugins=[
        PatternReplaceVersionInFilesPlugin('setup.py', 'README.md'),
    ],
)
dazza-codes commented 5 years ago

Should have been fixed in https://github.com/eventbrite/invoke-release/commit/764712d7abf31d26504ca49d3c3c99b071bf0c64 but apparently not? Or that change is not yet released to pypi?

dazza-codes commented 5 years ago

This might be a pipenv issue when creating a new virtualenv - it may not parse any restrictions on wheel versions in the Pipfile dependency graph before installing the latest version of wheel in a new virtualenv. It could be related to using pipenv install without the --dev option when creating the new virtualenv.

dazza-codes commented 5 years ago

This seems to be easily fixed by reinstalling the pipenv:

$ pipenv --rm
$ pipenv install --dev
$ pipenv shell
$ wheel version
wheel 0.31.1

To be sure, the problem can be replicated when recreating the pipenv virtualenv without installing the dev-dependencies, i.e.

$ pipenv --rm
$ pipenv install  # without --dev option
$ pipenv shell
$ wheel version
wheel 0.32.3

Update fix

Add the following to Pipfile [dev-packages]:

wheel = "~=0.31.0"  # invoke needs wheel.archive

Until there is an updated release of either invoke and/or invoke-release that works without the archive component of wheel.