Poetry: source_type is not assigned, regardless of virtual environment

Created on 7 Apr 2020  路  6Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Fedora 31
  • Poetry version: 1.1.0a1

Issue

Summary

Inside of a conda environment or a virtualenv, packages are discovered, but are not assigned a source_type attribute.

To reproduce the issue with conda:

  1. Create a new conda environment, for example conda create --name poetry-fail-env python=3.7. Note I'm using the most recent release of conda which is 4.8.3
  2. Activate the environment, conda activate poetry-fail-env
  3. Make the poetry project poetry new poetry-fail-proj
  4. Inside poetry-fail-proj run poetry install

Note that already packages are being updated despite being the most recent version:

Updating dependencies
Resolving dependencies... (0.2s)

Writing lock file


Package operations: 0 installs, 11 updates, 0 removals

  - Updating zipp (3.1.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 3.1.0)
  - Updating importlib-metadata (1.6.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.6.0)
  - Updating pyparsing (2.4.7 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 2.4.7)
  - Updating six (1.14.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.14.0)
  - Updating attrs (19.3.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 19.3.0)
  - Updating more-itertools (8.2.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 8.2.0)
  - Updating packaging (20.3 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 20.3)
  - Updating pluggy (0.13.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 0.13.1)
  - Updating py (1.8.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.8.1)
  - Updating wcwidth (0.1.9 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 0.1.9)
  - Updating pytest (5.4.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 5.4.1)
  - Installing poetry-fail-proj (0.1.0)
  1. Run poetry update --dry-run

The packages are still marked for update:

Updating dependencies
Resolving dependencies... (0.2s)


Package operations: 0 installs, 11 updates, 0 removals, 2 skipped

  - Updating zipp (3.1.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 3.1.0)
  - Updating importlib-metadata (1.6.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.6.0)
  - Updating pyparsing (2.4.7 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 2.4.7)
  - Updating six (1.14.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.14.0)
  - Skipping atomicwrites (1.3.0) Not needed for the current environment
  - Updating attrs (19.3.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 19.3.0)
  - Skipping colorama (0.4.3) Not needed for the current environment
  - Updating more-itertools (8.2.0 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 8.2.0)
  - Updating packaging (20.3 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 20.3)
  - Updating pluggy (0.13.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 0.13.1)
  - Updating py (1.8.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 1.8.1)
  - Updating wcwidth (0.1.9 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 0.1.9)
  - Updating pytest (5.4.1 /home/sean/.conda/envs/poetry-fail/lib/python3.7/site-packages -> 5.4.1)

Poetry debug info:

Poetry
Version: 1.1.0a1
Python:  3.7.6

Virtualenv
Python:         3.7.6
Implementation: CPython
Path:           /home/sean/.conda/envs/poetry-fail
Valid:          True

System
Platform: linux
OS:       posix
Python:   /home/sean/.conda/envs/poetry-fail

To reproduce the issue with virtualenv:

Same process as conda but use virtualenv instead.

  1. poetry install
Installing dependencies from lock file


Package operations: 11 installs, 0 updates, 0 removals

  - Installing zipp (3.1.0)
  - Installing importlib-metadata (1.6.0)
  - Installing pyparsing (2.4.7)
  - Installing six (1.14.0)
  - Installing attrs (19.3.0)
  - Installing more-itertools (8.2.0)
  - Installing packaging (20.3)
  - Installing pluggy (0.13.1)
  - Installing py (1.8.1)
  - Installing wcwidth (0.1.9)
  - Installing pytest (5.4.1)
  - Installing poetry-fail-proj (0.1.0)
  1. poetry update --dry run
Updating dependencies
Resolving dependencies... (0.6s)


Package operations: 0 installs, 11 updates, 0 removals, 2 skipped

  - Updating zipp (3.1.0 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 3.1.0)
  - Updating importlib-metadata (1.6.0 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 1.6.0)
  - Updating pyparsing (2.4.7 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 2.4.7)
  - Updating six (1.14.0 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 1.14.0)
  - Skipping atomicwrites (1.3.0) Not needed for the current environment
  - Updating attrs (19.3.0 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 19.3.0)
  - Skipping colorama (0.4.3) Not needed for the current environment
  - Updating more-itertools (8.2.0 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 8.2.0)
  - Updating packaging (20.3 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 20.3)
  - Updating pluggy (0.13.1 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 0.13.1)
  - Updating py (1.8.1 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 1.8.1)
  - Updating wcwidth (0.1.9 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 0.1.9)
  - Updating pytest (5.4.1 /home/sean/.virtualenvs/poetry-test/lib/python3.7/site-packages -> 5.4.1)

Poetry debug info:

Poetry
Version: 1.1.0a1
Python:  3.7.6

Virtualenv
Python:         3.7.6
Implementation: CPython
Path:           /home/sean/.virtualenvs/poetry-test
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

Investigation

Digging through the code, I found these line was triggering the updates:

                    elif package.source_type != pkg.source_type:
                        operations.append(Update(pkg, package))

where package.source_type is an empty string, but pkg.source_type is directory.

I'm not sure why the solver never assigns a value to source_type, but am happy to debug further asynchronously or via a video chat.

Unlike #1612, reverting to poetry 1.0.0 does not solve this problem.

Bug

Most helpful comment

For my own reference, this is not resolved in the 1.0.9

All 6 comments

Probably a duplicate of #1612 and almost definitely a duplicate of #2225. When #2225 is addressed, I will test and report back.

Currently can't figure out how to install Poetry from master, so I'm not yet able to test it until a new release is created.

Installing Poetry from master does indeed solves my problem when using virtualenv, but somehow fails when using conda. I'll make a new issue.

Somehow, when I install poetry from master by doing:
poetry install

Then activate it:
poetry shell

Which I verify with:
which poetry

Which gives:
/home/sean/.cache/pypoetry/virtualenvs/poetry-Y5_HnyyO-py3.8/bin/poetry

The bug is resolved. However, if I install poetry in any other manner, such as in an existing conda environment or virtualenv, I get the same update error.

But also, with conda, I sometimes get the error:

sean@carbon75 ~/g/poetryfailproj [1]> poetry install -vvv                                                                                                                                          (py37) 
Using virtualenv: /home/sean/.conda/envs/py37

[TypeError]
expected string or bytes-like object

Traceback (most recent call last):
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/console/commands/install.py", line 48, in handle
    self.io, self.env, self.poetry.package, self.poetry.locker, self.poetry.pool
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/installation/installer.py", line 55, in __init__
    installed = self._get_installed()
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/installation/installer.py", line 488, in _get_installed
    return InstalledRepository.load(self._env)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/repositories/installed_repository.py", line 28, in load
    package = Package(name, version, version)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/packages/package.py", line 43, in __init__
    self._name = canonicalize_name(name)
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/poetry/utils/helpers.py", line 26, in canonicalize_name
    return _canonicalize_regex.sub('-', name).lower()

I guess the conclusion is that I should wait for a new version of poetry, so I can install it with pipx and it will resolve the errors I'm having.

For my own reference, this is not resolved in the 1.0.9

Fully resolved in Poetry 1.1.0!

Was this page helpful?
0 / 5 - 0 ratings