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

File exists error when symlinking (namespace packages) #820

Closed
1 task done
pawamoy opened this issue Dec 27, 2021 · 2 comments · Fixed by #822
Closed
1 task done

File exists error when symlinking (namespace packages) #820

pawamoy opened this issue Dec 27, 2021 · 2 comments · Fixed by #822
Labels
🐛 bug Something isn't working

Comments

@pawamoy
Copy link
Contributor

pawamoy commented Dec 27, 2021

  • I have searched the issue tracker and believe that this is not a duplicate.

Related to #817

Steps to reproduce

pdm install -v with cache feature enabled.

add sphinxcontrib-serializinghtml failed:
Traceback (most recent call last):
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.9.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/installers/synchronizers.py", line 190, in install_candidate
    self.manager.install(can)
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/installers/manager.py", line 38, in install
    installer(candidate.build(), self.environment, candidate.direct_url())
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/installers/installers.py", line 160, in install_wheel_with_cache
    dist_info_dir = _install_wheel(
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/installers/installers.py", line 259, in _install_wheel
    destination.finalize_installation(
  File "/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.9/site-packages/pdm/installers/installers.py", line 83, in finalize_installation
    target.symlink_to(child)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.9.9/lib/python3.9/pathlib.py", line 1403, in symlink_to
    self._accessor.symlink(target, self, target_is_directory)
  File "/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.9.9/lib/python3.9/pathlib.py", line 456, in symlink
    return os.symlink(a, b)
FileExistsError: [Errno 17] File exists: '/home/pawamoy/.cache/pdm/packages/sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any/lib/sphinxcontrib' -> '/media/data/dev/mkdocstrings/__pypackages__/3.7/lib/sphinxcontrib'

Actual behavior

Namespace packages expose directories with the same name. If namespace package N.A is already installed, trying to install N.B fails, because directory N already exists.

Expected behavior

In the case of namespace packages, instead of symlinking the top directory, it should mkdir the top directory and symlink the namespace packages instead. Probably edgy.

An alternative would be to provide a configuration option to disable symlinks (pth files seemed to work better).

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:        1.12.1
Python Interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.12/bin/python3.7 (3.7)
Project Root:       /media/data/dev/mkdocstrings
Project Packages:   /media/data/dev/mkdocstrings/__pypackages__/3.7
{
  "implementation_name": "cpython",
  "implementation_version": "3.7.12",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.11-arch2-1",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT Wed, 22 Dec 2021 09:23:54 +0000",
  "python_full_version": "3.7.12",
  "platform_python_implementation": "CPython",
  "python_version": "3.7",
  "sys_platform": "linux"
}
@pawamoy pawamoy added the 🐛 bug Something isn't working label Dec 27, 2021
@frostming
Copy link
Collaborator

Since namespace packages can be nested, providing a configuration would be better.

@frostming
Copy link
Collaborator

Finally, I took both 😃 , namespace packages of all kinds(PEP 420, pkgutil, pkg_resources) should work fine with symlinks, and also provide a configuration for rare cases that don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants