Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast_unparse - AttributeError: 'Name' object has no attribute 'update' #4357

Closed
kjcole opened this issue Jun 20, 2020 · 7 comments
Closed

ast_unparse - AttributeError: 'Name' object has no attribute 'update' #4357

kjcole opened this issue Jun 20, 2020 · 7 comments
Labels
Category: Requirement Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.

Comments

@kjcole
Copy link

kjcole commented Jun 20, 2020

Issue description

I recently installed Ubuntu 20.04 from scratch (reformatted the hard disk, etc.). I verified there were no files named pipenv* anywhere on the system -- including ~/.cache/.

$ pip install --user pipenv
$ pipenv update
...
  File "/home/kjcole/.local/lib/python3.8/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1139, in ast_unparse
    unparsed[func_name].update(unparse(keyword))
AttributeError: 'Name' object has no attribute 'update'

I've included the full traceback.

Expected result

I expecte pipenv to update

Actual result

It didn't update.

Steps to replicate

$ sudo updatedb
$ locate pipenv    # (returned no matching files)
$ pip install --user pipenv
$ pipenv update

$ pipenv --support

Pipenv version: '2020.6.2'

Pipenv location: '/home/kjcole/.local/lib/python3.8/site-packages/pipenv'

Python location: '/usr/bin/python3'

Python installations found:

  • 3.8.2: /usr/bin/python3.8
  • 3.8.2: /usr/bin/python3
  • 3.8.2: /bin/python3.8
  • 3.8.2: /bin/python3
  • 2.7.18: /usr/bin/python2.7
  • 2.7.18: /usr/bin/python2
  • 2.7.18: /bin/python2.7
  • 2.7.18: /bin/python2

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.8.2',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.4.0-37-lowlatency',
 'platform_system': 'Linux',
 'platform_version': '#41-Ubuntu SMP PREEMPT Wed Jun 3 19:52:07 UTC 2020',
 'python_full_version': '3.8.2',
 'python_version': '3.8',
 'sys_platform': 'linux'}

System environment variables:

  • SHELL
  • SESSION_MANAGER
  • WINDOWID
  • QT_ACCESSIBILITY
  • COLORTERM
  • BYOBU_PYTHON
  • XDG_CONFIG_DIRS
  • LESS
  • XDG_SESSION_PATH
  • BYOBU_HIGHLIGHT
  • LANGUAGE
  • MANDATORY_PATH
  • SSH_AUTH_SOCK
  • MOST_SWITCHES
  • BYOBU_DATE
  • SHELL_SESSION_ID
  • DEBFULLNAME
  • DESKTOP_SESSION
  • SSH_AGENT_PID
  • GTK_RC_FILES
  • BYOBU_CONFIG_DIR
  • GPG_TTY
  • EDITOR
  • XDG_SEAT
  • PWD
  • XDG_SESSION_DESKTOP
  • LOGNAME
  • XDG_SESSION_TYPE
  • DSSI_PATH
  • GPG_AGENT_INFO
  • XAUTHORITY
  • FONT_HOME
  • BYOBU_EDITOR
  • VIRTUALENVWRAPPER_VIRTUALENV
  • GTK2_RC_FILES
  • HOME
  • SSH_ASKPASS
  • LANG
  • VST_PATH
  • LS_COLORS
  • XDG_CURRENT_DESKTOP
  • KONSOLE_DBUS_SERVICE
  • BYOBU_ULIMIT
  • BYOBU_BACKEND
  • BYOBU_ACCENT
  • KONSOLE_DBUS_SESSION
  • PROFILEHOME
  • DEBEMAIL
  • XDG_SEAT_PATH
  • VIRTUALENVWRAPPER_PYTHON
  • OPENSCADPATH
  • KONSOLE_VERSION
  • BYOBU_DARK
  • BYOBU_PAGER
  • KDE_SESSION_UID
  • WORKON_HOME
  • LESSCLOSE
  • XDG_SESSION_CLASS
  • BYOBU_SED
  • TERM
  • DEFAULTS_PATH
  • LESSOPEN
  • LIBVIRT_DEFAULT_URI
  • USER
  • COLORFGBG
  • KDE_SESSION_VERSION
  • PAM_KWALLET5_LOGIN
  • BYOBU_PREFIX
  • DISPLAY
  • SHLVL
  • BYOBU_LIGHT
  • PAGER
  • BYOBU_TIME
  • XDG_VTNR
  • BYOBU_WINDOW_NAME
  • XDG_SESSION_ID
  • BYOBU_READLINK
  • BYOBU_DISTRO
  • XDG_RUNTIME_DIR
  • QT_AUTO_SCREEN_SCALE_FACTOR
  • XCURSOR_THEME
  • XDG_DATA_DIRS
  • KDE_FULL_SESSION
  • PATH
  • DBUS_SESSION_BUS_ADDRESS
  • LV2_PATH
  • EMSDK
  • WASMER_DIR
  • OLDPWD
  • LADSPA_PATH
  • BYOBU_RUN_DIR
  • CADENCE_AUTO_STARTED
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/kjcole/Packages/AUR/emsdk/src/emsdk-portable:/home/kjcole/.cargo/bin:/home/kjcole/.cabal/bin:/home/kjcole/.cask/bin:/home/kjcole/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/kjcole/.local/bin
  • SHELL: /bin/bash
  • EDITOR: emacs -nw
  • LANG: en_US.UTF-8
  • PWD: /home/kjcole/gits/novaweb/rerc/SoundAdvice/pythonqt

Contents of Pipfile ('/home/kjcole/gits/novaweb/rerc/SoundAdvice/pythonqt/Pipfile'):

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
six = "*"
py2app = "*"
zeroconf = "==0.19.1"
PySide = "==1.2.2"
python2_osc = {git = "https://github.com/kjcole/python2-osc.git"}

[dev-packages]

[requires]
python_version = "2.7"
@wind1101
Copy link

wind1101 commented Jul 22, 2020

I have encountered the same issue.

$ pipenv install
...
  File "/usr/local/Cellar/pipenv/2020.6.2/libexec/lib/python3.8/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1139, in ast_unparse
    unparsed[func_name].update(unparse(keyword))
AttributeError: 'Name' object has no attribute 'update'

Has this issue fixed? Or some way to walk around?

@elijahr
Copy link

elijahr commented Jul 24, 2020

I downgraded to pipenv==2018.11.26 as a workaround.

@the-moog
Copy link

Ubuntu 20.04LTS installed pipenv 2020.8.13 that had the same Attribute error issue with the svn [package] trachtmlnotification = {svn = "https://trac-hacks.org/svn/trachtmlnotificationplugin/0.12"}

I downgraded to pipenv==2018.11.26 and that resolved the issue.

I hope this info will help resolve the issue.

I also note that -v option is much more informative in the older release.

user@trac01:~/test$ PIPENV_VENV_IN_PROJECT=1 pipenv install
Pipfile.lock (d4f21f) out of date, updating to (74052c)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
✘ Locking Failed!
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pipenv/resolver.py", line 807, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/pipenv/resolver.py", line 803, in main
    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/resolver.py", line 785, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/resolver.py", line 753, in resolve_packages
    requirements_dir=requirements_dir,
  File "/usr/local/lib/python2.7/dist-packages/pipenv/resolver.py", line 736, in resolve
    req_dir=requirements_dir
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 1386, in resolve_deps
    req_dir=req_dir,
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 1091, in actually_resolve_deps
    deps, index_lookup, markers_lookup, project, sources, req_dir, clear, pre
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 649, in create
    pre=pre, clear=clear
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 463, in get_metadata
    req, resolver=transient_resolver
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 540, in get_deps_from_req
    req_list, lockfile = get_vcs_deps(reqs=[req])
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 1874, in get_vcs_deps
    with temp_path(), locked_repository(requirement) as repo:
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pipenv/utils.py", line 2030, in locked_repository
    with requirement.req.locked_vcs_repo(src_dir=src_dir) as repo:
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/requirements.py", line 2210, in locked_vcs_repo
    self._parsed_line.vcsrepo = vcsrepo
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/requirements.py", line 914, in vcsrepo
    kwargs=wheel_kwargs,
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1960, in create
    created.get_initial_info()
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1790, in get_initial_info
    self.update_from_dict(self.parse_setup_py())
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1532, in parse_setup_py
    parsed = ast_parse_setup_py(self.setup_py.as_posix())
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1217, in ast_parse_setup_py
    ast_analyzer = ast_parse_file(path)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1211, in ast_parse_file
    ast_analyzer.visit(tree)
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 714, in generic_visit
    super(Analyzer, self).generic_visit(node)
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/ast.py", line 249, in generic_visit
    self.visit(item)
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 714, in generic_visit
    super(Analyzer, self).generic_visit(node)
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/ast.py", line 251, in generic_visit
    self.visit(value)
  File "/home/jmorgan/.pyenv/versions/2.7.17/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 707, in generic_visit
    self.function_map.update(ast_unparse(node, initial_mapping=True))
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1144, in ast_unparse
    unparsed[func_name].update(unparse(keyword))
AttributeError: 'Name' object has no attribute 'update'

@frostming
Copy link
Contributor

I can't reproduce either case with normal installation by pip. It may be a downstream packaging issue. You can try reporting it to Ubuntu.

@frostming frostming added Type: Vendored Dependencies This issue affects vendored dependencies within pipenv. and removed triage labels Aug 31, 2020
@the-moog
Copy link

the-moog commented Sep 2, 2020

What python 2 are you using? This was using the system python2 2.7.18 and a virtualenv 2.7.17

@uranusjr
Copy link
Member

uranusjr commented Sep 2, 2020

I traced the code and it seems like this can happen if both keywords and kwargs attributes are present on item, but points to different values:

https://github.com/sarugaku/requirementslib/blob/1.5.13/src/requirementslib/models/setup_info.py#L1135-L1144

the first iteration would set unparsed[func_name] = val (where val is a Name object), and the second tries to call unparsed[func_name].update() (and fails since unparsed[func_name] is now a Name object). I am not sure if this is Debian-specific.

@frostming
Copy link
Contributor

Fixed on v2021.11.5

prkumar added a commit to shadchin/uplink that referenced this issue Dec 31, 2021
prkumar added a commit to shadchin/uplink that referenced this issue Dec 31, 2021
prkumar added a commit to prkumar/uplink that referenced this issue Dec 31, 2021
* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add link to GitHub Discussions for repo in README

* Update "Question" GitHub issue template

* Fix @uplink.*Map to not throw error if converter is None

Fixes #221

* Fix B018 flake error

Flake is failing with "B018 Found useless expression."

https://app.travis-ci.com/github/prkumar/uplink/jobs/553555288

* Add 3.9 and 3.10.1 to travis build (#239)

* Add 3.9 and 3.10 to travis build

* Replace 3.10 with 3.10-dev

* Update travis to use Ubuntu 18.04

18.04 has 3.10.0 and 3.10.1 according to: 
https://docs.travis-ci.com/user/languages/python/

* Bump python 3.10 to 3.10.1 in travis

* Unpin pytest version

Travis build for 3.10.1 failed because of issue in pytest that was fixed in a later release: pytest-dev/pytest#8540

* Fix uplink with Python 2.7

* Switch on six.moves.collections_abc

* Add abc in __all__

* Add python 2.7 to travis build

* Omit "keywords" attribute when invoking setup for py2.7

Context: pypa/pipenv#4357 (comment)

* Pin pipenv==2018.11.26 for py2.7 travis build

Context: pypa/pipenv#4357 (comment)

* Fix syntax error in travis config file

* Try pinning pipenv version in tox.ini

* Make integration tests work with py2.7

* Make integration tests work with py2.7

* Fix flake8 E231 error

Co-authored-by: P. Raj Kumar <raj.pritvi.kumar@gmail.com>
Co-authored-by: Alexander Shadchinr <shadchin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Requirement Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.
Projects
None yet
Development

No branches or pull requests

6 participants