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

Pipenv tries to include a local file at install #5885

Closed
jbe-dw opened this issue Aug 28, 2023 · 8 comments
Closed

Pipenv tries to include a local file at install #5885

jbe-dw opened this issue Aug 28, 2023 · 8 comments
Labels
Type: Regression This issue is a regression of a previous behavior.

Comments

@jbe-dw
Copy link

jbe-dw commented Aug 28, 2023

Issue description

With pipenv >= 2023.8.19, pipenv install fails when a file or a folder named after a target package exists in the Pipfile directory with the following messages: ValueError: Could not determine package name from file:///file:///build/molecule (when it is a folder) / NotADirectoryError: [Errno 20] Not a directory: '/build/molecule' (when it is a file)

As the use case, we run Ansible molecule in a dockerized CI runner to test our roles. The project needs to install Python molecule package, and a molecule folder is required in the role. We need the package and can't rename the folder.

Expected result

pipenv installs molecule.

Actual result

With a file:

root@b88ff340ebe6:/build# pipenv install -d --verbose
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 678, in <module>
    main()
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 664, in main
    _main(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 651, in _main
    resolve_packages(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 618, in resolve_packages
    results, resolver = resolve(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 598, in resolve
    return resolve_deps(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 841, in resolve_deps
    results, hashes, internal_resolver = actually_resolve_deps(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 603, in actually_resolve_deps
    resolver = Resolver.create(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 206, in create
    package_name = determine_package_name(install_req)
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/dependencies.py", line 741, in determine_package_name
    req_name = find_package_name_from_directory(package.link.file_path)
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/dependencies.py", line 620, in find_package_name_from_directory
    os.listdir(directory),
NotADirectoryError: [Errno 20] Not a directory: '/build/molecule'

With a folder:

root@b88ff340ebe6:/build# pipenv install -d
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
⠸ Locking...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 678, in <module>
    main()
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 664, in main
    _main(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 651, in _main
    resolve_packages(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 618, in resolve_packages
    results, resolver = resolve(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/resolver.py", line 598, in resolve
    return resolve_deps(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 841, in resolve_deps
    results, hashes, internal_resolver = actually_resolve_deps(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 603, in actually_resolve_deps
    resolver = Resolver.create(
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/resolver.py", line 206, in create
    package_name = determine_package_name(install_req)
  File "/usr/local/lib/python3.9/dist-packages/pipenv/utils/dependencies.py", line 745, in determine_package_name
    raise ValueError(f"Could not determine package name from {package}")
ValueError: Could not determine package name from file:///file:///build/molecule

Steps to replicate

  • Create a file or folder named after a package
  • Run pipenv install <package> or pipenv install with the package listed in the Pipfile

$ pipenv --support

Pipenv version: '2023.8.19'

Pipenv location: '/usr/local/lib/python3.9/dist-packages/pipenv'

Python location: '/usr/bin/python3'

OS Name: 'posix'

User pip version: '23.2.1'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.9.2',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.15.0-78-generic',
 'platform_system': 'Linux',
 'platform_version': '#85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023',
 'python_full_version': '3.9.2',
 'python_version': '3.9',
 'sys_platform': 'linux'}

System environment variables:

  • HOSTNAME
  • PWD
  • HOME
  • TERM
  • SHLVL
  • PATH
  • OLDPWD
  • _
  • LC_CTYPE
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • PWD: /build

Contents of Pipfile ('/build/Pipfile'):

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

[dev-packages]
python-ldap = "*"

[packages]
ansible = "~=4.10"
ansible-lint = "*"
yamllint = "*"
molecule = "*"
molecule-docker = "*"
flake8 = "*"
pytest-testinfra = "*"

[requires]
python_version = "3"
@matteius matteius added the Type: Regression This issue is a regression of a previous behavior. label Aug 28, 2023
@matteius
Copy link
Member

@jbe-dw I assume you have checked with 2023.826 and had the same issue?

@jbe-dw
Copy link
Author

jbe-dw commented Aug 28, 2023

Sure, it happened with the latest first, and I tried several versions to see which version broke our setup. 2023.7.23 works fine.

@aradkdj
Copy link

aradkdj commented Aug 28, 2023

Got bitten by this while installing in a project with alembic.

@matteius
Copy link
Member

2023.8.28 has been released with fix for this issue.

@jbe-dw
Copy link
Author

jbe-dw commented Aug 29, 2023

Thank you !

@korsunov-prosperity
Copy link

Hi, same error here on 2023.9.8. For me 2023.6.26 works just fine.

@matteius matteius reopened this Sep 24, 2023
@matteius
Copy link
Member

matteius commented Oct 3, 2023

@korsunov-prosperity Can you check 2023.10.3?

@korsunov-prosperity
Copy link

hi, new version works. Thanks!

@matteius matteius closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Regression This issue is a regression of a previous behavior.
Projects
None yet
Development

No branches or pull requests

4 participants