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"
Issue description
With pipenv >= 2023.8.19,
pipenv installfails 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:
With a folder:
Steps to replicate
pipenv install <package>orpipenv installwith 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:
System environment variables:
HOSTNAMEPWDHOMETERMSHLVLPATHOLDPWD_LC_CTYPEPIP_DISABLE_PIP_VERSION_CHECKPYTHONDONTWRITEBYTECODEPYTHONFINDER_IGNORE_UNSUPPORTEDPipenv–specific environment variables:
Debug–specific environment variables:
PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binPWD:/buildContents of
Pipfile('/build/Pipfile'):