pipenv: Version of pipenv > 2020.11.15 will produce error AttributeError: 'JoinedStr' object has no attribute 's'

Issue description

Version of pipenv > 2020.11.15 will produce error AttributeError: 'JoinedStr' object has no attribute 's' when it installs a package from private repo that contains setup.py with dependencies from private repo.

Expected result

Packages and its dependencies should install from private repo (bitbucket)

Actual result

pipenv install --verbose
Installing dependencies from Pipfile.lock (19667c)...
/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py:226: PipDeprecationWarning: DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
 pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
  issue=7555
Traceback (most recent call last):
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/cli/command.py", line 215, in install
    site_packages=state.site_packages
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/core.py", line 2008, in do_install
    keep_outdated=keep_outdated
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/core.py", line 1269, in do_init
    pypi_mirror=pypi_mirror,
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/core.py", line 824, in do_install_dependencies
    project, normal_deps, procs, failed_deps_queue, requirements_dir, **install_kwargs
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/core.py", line 688, in batch_install
    dep for dep in deps_to_install if not project.environment.is_satisfied(dep)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/core.py", line 688, in <listcomp>
    dep for dep in deps_to_install if not project.environment.is_satisfied(dep)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/environment.py", line 776, in is_satisfied
    vcs_type == req.vcs and commit_id == req.commit_hash
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/cached_property.py", line 36, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 2491, in commit_hash
    with self.req.locked_vcs_repo() as repo:
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 2223, in locked_vcs_repo
    self._parsed_line.vcsrepo = vcsrepo
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 907, in vcsrepo
    kwargs=wheel_kwargs,
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1598, in create
    created.get_initial_info()
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1431, in get_initial_info
    parsed.update(self.parse_setup_py())
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 1162, in parse_setup_py
    parsed = ast_parse_setup_py(self.setup_py.as_posix())
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 880, in ast_parse_setup_py
    return SetupReader.read_setup_py(Path(path), raising)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 205, in read_setup_py
    "install_requires": caller(cls._find_install_requires, setup_call, body),
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 197, in caller
    return func(*args, **kwargs)
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 360, in _find_install_requires
    return [el.s for el in value.elts]
  File "/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 360, in <listcomp>
    return [el.s for el in value.elts]
AttributeError: 'JoinedStr' object has no attribute 's'

Steps to replicate

Pipfile:

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

[dev-packages]
pylint = "*"
autopep8 = "*"

[packages]
requests = "==2.*"
matplotlib = "*"
custom_lib = {git = 'git@bitbucket.org/org/custom_lib.git'}

[requires]
python_version = "3.7"

custom_lib -> setup.py:

'''
Custom Lib
'''

from setuptools import setup

HOST = 'git+ssh://git@bitbucket.org/org/'

setup(
    author='Team',
    name='custom_lib',
    version='2.0.4',
    description='Custom Lib',
    install_requires=['easysnmp', f'custom_lib@{HOST}custom_lib.git#egg=custom_lib'],
    py_modules=['custom_lib']
)

Steps:

  • pipenv install

pipenv --support

$ pipenv --support

Pipenv version: '2022.1.8'

Pipenv location: '/home/SYS/comp1/.pyenv/versions/3.7.13/lib/python3.7/site-packages/pipenv'

Python location: '/home/SYS/comp1/.pyenv/versions/3.7.13/bin/python3'

Python installations found:

  • 3.10.5: /home/SYS/comp1/.pyenv/versions/3.10.5/bin/python3
  • 3.10.4: /usr/bin/python3
  • 3.10.4: /usr/bin/python
  • 3.10.4: /bin/python3
  • 3.10.4: /bin/python
  • 3.9.13: /usr/bin/python3.9
  • 3.9.13: /bin/python3.9
  • 3.7.13: /home/SYS/comp1/.pyenv/versions/3.7.13/bin/python3
  • 3.7.13: /home/SYS/comp1/.pyenv/versions/3.7.13/bin/python
  • 3.7.13: /home/SYS/comp1/.pyenv/versions/3.7.13/bin/python3.7m
  • 3.7.13: /home/SYS/comp1/.pyenv/versions/3.7.13/bin/python3.7
  • 3.7.13: /home/SYS/comp1/.pyenv/versions/3.7.13/bin/python3
  • 3.7.9: /home/SYS/comp1/.pyenv/versions/3.7.9/bin/python3
  • 3.6.11: /home/SYS/comp1/.pyenv/versions/3.6.11/bin/python3
  • 3.6.9: /usr/bin/python3.6m
  • 3.6.9: /usr/bin/python3.6
  • 3.6.9: /bin/python3.6m
  • 3.6.9: /bin/python3.6
  • 3.5.10: /usr/bin/python3.5
  • 3.5.10: /usr/bin/python3.5m
  • 3.5.10: /bin/python3.5
  • 3.5.10: /bin/python3.5m
  • 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.7.13',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.15.0-39-generic',
 'platform_system': 'Linux',
 'platform_version': '#42-Ubuntu SMP Thu Jun 9 23:42:32 UTC 2022',
 'python_full_version': '3.7.13',
 'python_version': '3.7',
 'sys_platform': 'linux'}

System environment variables:

  • SHELL
  • PYENV_HOOK_PATH
  • PYENV_SHELL
  • NVM_INC
  • PKG_CONFIG_PATH
  • LANGUAGE
  • LC_ADDRESS
  • LC_NAME
  • LC_MONETARY
  • CONNECT_FB_PASSWORD
  • PYENV_VERSION
  • KRB5CCNAME
  • PWD
  • PYENV_VIRTUALENV_INIT
  • LOGNAME
  • XDG_SESSION_TYPE
  • MOTD_SHOWN
  • HOME
  • LANG
  • LC_PAPER
  • LS_COLORS
  • SSH_CONNECTION
  • PYENV_DIR
  • CONNECT_UI_PASSWORD
  • NVM_DIR
  • CONNECT_YT_USER
  • LESSCLOSE
  • XDG_SESSION_CLASS
  • TERM
  • LC_IDENTIFICATION
  • LESSOPEN
  • LIBVIRT_DEFAULT_URI
  • USER
  • CONNECT_UI_URL
  • SHLVL
  • NVM_CD_FLAGS
  • LC_TELEPHONE
  • LC_MEASUREMENT
  • XDG_SESSION_ID
  • PAPERSIZE
  • XDG_RUNTIME_DIR
  • SSH_CLIENT
  • PYENV_ROOT
  • LC_TIME
  • XDG_DATA_DIRS
  • PATH
  • DBUS_SESSION_BUS_ADDRESS
  • NVM_BIN
  • SSH_TTY
  • LC_NUMERIC
  • OLDPWD
  • PIP_SHIMS_BASE_MODULE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/SYS/comp1/.pyenv/versions/3.7.13/bin:/home/SYS/comp1/.pyenv/libexec:/home/SYS/comp1/.pyenv/plugins/python-build/bin:/home/SYS/comp1/.pyenv/plugins/pyenv-virtualenv/bin:/home/SYS/comp1/.pyenv/shims:/home/SYS/comp1/.pyenv/versions:/home/SYS/comp1/.pyenv/bin:/home/SYS/comp1/.pyenv/plugins/pyenv-virtualenv/shims:/home/SYS/comp1/.pyenv/bin:/home/SYS/comp1/.local/bin:/home/SYS/comp1/.pyenv/versions:/home/SYS/comp1/.pyenv/bin:/shims:/home/SYS/comp1/.nvm/versions/node/v16.13.0/bin:/home/SYS/comp1/.pyenv/plugins/pyenv-virtualenv/shims:/home/SYS/comp1/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /home/SYS/comp1/git/project/pytest

Contents of Pipfile (‘/home/SYS/comp1/git/project/pytest/Pipfile’):

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

[dev-packages]
pylint = "*"
autopep8 = "*"

[packages]
pytest = "==7.*"
pytest-env = "*"
requests = "==2.*"
configparser = "*"
pytest-repeat = "*"
chromedriver-binary = "*"
pytest-instafail = "*"
mdv = "*"
pyinstaller = "*"
pytest-html-reporter= "*"
matplotlib = "*"
openpyxl = "*"
pytest-html = "==2.1.1"
custom-lib-helpers = {git = 'git@bitbucket.org/org/custom-lib-helpers.git'}
custom-lib-rest-api = {git = 'git@bitbucket.org/org/custom-lib-rest-api.git'}

[requires]
python_version = "3.10"

comp1@sys:~/git/project/pytest$

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I just ran into the same kind of issue as described here with:

AttributeError: 'JoinedStr' object has no attribute 's'

As a workaround, I found that you can wrap your install_requires in a list, which does not really do anything since it is already a list, but it fixes the issue. I assume it just evaluates the list items before the error occurs.

setup(
    ...
    install_requires=list(['easysnmp', f'custom_lib@{HOST}custom_lib.git#egg=custom_lib']),
    ...
)

I initially had an issue with using if-else within install_requires, which resulted in the following error:

AttributeError: 'IfExp' object has no attribute 's'

The workaround also fixes this issue. Example:

TF_VERSION = '2.3.0'

setup(
    ...
    install_requires = list([
    f'tensorflow-macos>={TF_VERSION}' if sys.platform == 'darwin' and platform.machine() == 'arm64' else f'tensorflow>={TF_VERSION}']),
    ...
)

@alexanderdevm Thanks for checking that, it will have to be investigated further where the code issue may be.