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

Poetry Never Updates pywin32 #3077

Closed
2 tasks done
adam-grant-hendry opened this issue Oct 5, 2020 · 25 comments
Closed
2 tasks done

Poetry Never Updates pywin32 #3077

adam-grant-hendry opened this issue Oct 5, 2020 · 25 comments
Labels
kind/bug Something isn't working as expected

Comments

@adam-grant-hendry
Copy link

adam-grant-hendry commented Oct 5, 2020

  • [x ] I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10, version 1909
  • Poetry version: 1.1.0
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

poetry update always attempts to update pywin32, but never does. Every new install lists pywin32 as requiring update

>>> poetry update
Updating dependencies
Resolving dependencies...

Package operations: 0 installs, 1 update, 0 removals

  • Updating pywin32 (228 C:/Code/project/.venv/Lib/site-packages/pythonwin -> 228)

The pyproject.toml file is as follows:

[tool.poetry]
name = "project"
version = "0.1.0"
description = "test"
license = "Apache-2.0"

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.19.2"
matplotlib = "^3.3.2"
pywin32 = "^228"

[tool.poetry.dev-dependencies]
black = "^20.8b1"
flake8 = "^3.8.4"
pytest = "^6.1.1"
pylint = "^2.6.0"
jupyter = "^1.0.0"
notebook = "^6.1.4"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

I am running Python 3.8.6.

@adam-grant-hendry adam-grant-hendry added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 5, 2020
@adam-grant-hendry
Copy link
Author

Reverting poetry to version 1.0.10 resolves this issue, but it is still uncertain to me why this occurs with version 1.1.0.

@abn
Copy link
Member

abn commented Oct 5, 2020

Have you tried re-creating the virtual environment?

@adam-grant-hendry
Copy link
Author

Recreating the venv, I still have the error. Not working now with 1.0.10 either.

@adam-grant-hendry
Copy link
Author

Occurs in version 1.1.1 as well.

@akhileshraju
Copy link
Contributor

I see this as well starting with version 1.1.0
Updating to 1.1.1 didnt resolve the issue

@jgentil
Copy link

jgentil commented Oct 7, 2020

I have this same problem. Following for solution...

@jgentil
Copy link

jgentil commented Oct 7, 2020

Actually mine is slightly different. It always tries to upgrade it, even if it's the same version. I see the same thing you do though, and I feel like that's also what you're experiencing. It has version 228 installed, but tries to update to version 228 for some reason.

@absassi
Copy link

absassi commented Oct 8, 2020

It seems this is due to pywin32 installing a pywin32.pth file in site-packages, which causes Poetry to think it is installed in develop mode (and also that's why the "Updating" line it prints has a path) and thus needs to be reinstalled in non-develop mode.

@adam-grant-hendry
Copy link
Author

@jgentil Yes, you are correct. My error is the same as yours. It always tries to "update" from 228 to 228, but nothing ever seems to get resolved (it continues to do this every time I run poetry install or poetry update).

@absassi Is the pywin32.pth file necessary? I could delete the file locally and see if this resolves the issue, but then somone would need to create a pull request to pywin32 to remove the file from being downloaded. Is it needed for anything else?

@wlievens
Copy link

I get this issue too.

@abn
Copy link
Member

abn commented Oct 12, 2020

@absassi @adam-grant-hendry can one of you give me a tree listing of your site-packages directory where pywin32 gets installed please?

My guess is that this check is incomplete somehow.

if is_standard_package:
if path.name.endswith(".dist-info"):
paths = cls.get_package_paths(env=env, name=package.pretty_name)
if paths:
for src in paths:
if cls.is_vcs_package(src, env):
cls.set_package_vcs_properties(package, env)
break
else:
# TODO: handle multiple source directories?
package._source_type = "directory"
package._source_url = paths.pop().as_posix()
continue

@haenry
Copy link

haenry commented Oct 12, 2020

There are quite a few folders. The actual one should be the last I guess.

~~win32_system32
~-win32_system32
~ywin32_system32

pywin32_system32

all contain

pythoncom37.dll
pywintypes37.dll

This is the error-message

Installing collected packages: pywin32
    Attempting uninstall: pywin32
      Found existing installation: pywin32 228
      Uninstalling pywin32-228:
        Successfully uninstalled pywin32-228
  ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access denied: 'c:\\users\\me\\\appdata\\local\\pypoetry\\cache\\virtualenvs\\project-5vzw2i23-py3.7\\lib\\site-packages\\~ywin32_system32\\pythoncom37.dll'
  Consider using the `--user` option or check the permissions.



  at ~\.poetry\lib\poetry\utils\env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│
       950│         return decode(output)
       951│
       952│     def execute(self, bin, *args, **kwargs):```

@abn
Copy link
Member

abn commented Oct 12, 2020

@haenry the error message is interesting. So it seems pip is unable uninstall the existing packages. I believe this is a seperate issue to the one reported (albeit definitely related).

Is the file pythoncom37.dll link? Or does it have any permissions set? Also, can you try manually removing the package? poetry run pip uninstall pywin32 ?

@haenry
Copy link

haenry commented Oct 12, 2020

No, they are regular files. Permissions are

Path                     Owner         Access
----                      -----           ------
pythoncom37.dll  ME             NT-AUTHORITY\SYSTEM Allow  FullControl...
pywintypes37.dll  ME             NT-AUTHORITY\SYSTEM Allow  FullControl...

same as other files in site-packages

poetry run pip uninstall pywin32 removes the package but cannot remove the pythoncom37.dll ( Successfully uninstalled pywin32-228 and then the Acces denied is thrown)
Afterwards the poetry install runs normally once and installs pywin32 again. Then it returns to the loop updating 228 -> 228.

@alimantu
Copy link

Same issue here.

OS version and name: Windows 10 Pro, Build 19041
Poetry version: 1.1.2

@jgentil
Copy link

jgentil commented Oct 14, 2020

Something to try: Make sure you aren't running poetry install from inside a poetry shell or have an active poetry shell running.

Moving out of the shell fixed it for me. I had to stop all instances of the shell though.

@abn
Copy link
Member

abn commented Oct 14, 2020

Dug into this a further. Found the root cause.

for src in paths:
if cls.is_vcs_package(src, env):
cls.set_package_vcs_properties(package, env)
break
else:
# TODO: handle multiple source directories?
package._source_type = "directory"
package._source_url = paths.pop().as_posix()

We seem to be assuming that a package is a "path" package because the .pth file lists multiple paths but none of them are vcs pakcages. The else block should only set source_type = "directory" if at least one of the paths listed is outside the site package directories (ie. editable package).

abn added a commit to abn/poetry that referenced this issue Oct 14, 2020
When detecting installed packages, this change ensures that packages
with .pth files are not incorrectly marked as editable. A package is
considered editable only if at least one of the paths detected is
not in the environment site.

Resolves: python-poetry#3077
abn added a commit to abn/poetry that referenced this issue Oct 14, 2020
When detecting installed packages, this change ensures that packages
with .pth files are not incorrectly marked as editable. A package is
considered editable only if at least one of the paths detected is
not in the environment site.

Resolves: python-poetry#3077
@abn
Copy link
Member

abn commented Oct 14, 2020

Can you please try the fix at #3210.

Using pipx

pipx install --suffix=@3210 'poetry @ git+https://github.com/python-poetry/poetry.git@refs/pull/3210/head'

@abn abn removed the status/triage This issue needs to be triaged label Oct 15, 2020
abn added a commit to abn/poetry that referenced this issue Oct 23, 2020
When detecting installed packages, this change ensures that packages
with .pth files are not incorrectly marked as editable. A package is
considered editable only if at least one of the paths detected is
not in the environment site.

Resolves: python-poetry#3077
@abn abn closed this as completed in 68f2cc7 Oct 23, 2020
@natehawkboss
Copy link

I am still seeing this issue in 1.1.4.

I will point out that it is when I have this line in the file:
pywin32 = {version = "^228", platform = "win32"}

Every single time it updates or installs a package, it then tries to update this one which it cannot because it runs into that permission error.

@wlievens
Copy link

Same here, still seeing this issue, is there a workaround?
I also get all sorts of spurious acess denied errors in windows from poetry which seem to be related...

@abersheeran
Copy link

WSL and Windows10, poetry 1.1.4. Same bug.

@sinoroc
Copy link

sinoroc commented Jan 19, 2021

WSL

WSL? You can not install pywin32 on WSL, can you?

@abersheeran
Copy link

abersheeran commented Jan 20, 2021 via email

@jaepil-choi
Copy link

The issue still persists. I should not have updated poetry.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests