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

source_type is not assigned, regardless of virtual environment #2281

Closed
3 tasks done
Seanny123 opened this issue Apr 7, 2020 · 7 comments
Closed
3 tasks done

source_type is not assigned, regardless of virtual environment #2281

Seanny123 opened this issue Apr 7, 2020 · 7 comments
Labels
kind/bug Something isn't working as expected

Comments

@Seanny123
Copy link

Seanny123 commented Apr 7, 2020

  • 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: 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.

@Seanny123 Seanny123 added the kind/bug Something isn't working as expected label Apr 7, 2020
@Seanny123 Seanny123 changed the title Conda environment causes source_type to not be assigned. source_type is not assigned, regardless of virtual environment Apr 7, 2020
@Seanny123 Seanny123 changed the title source_type is not assigned, regardless of virtual environment source_type is not assigned, regardless of virtual environment Apr 7, 2020
@Seanny123
Copy link
Author

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

@Seanny123
Copy link
Author

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.

@Seanny123
Copy link
Author

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

@Seanny123
Copy link
Author

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.

@Seanny123
Copy link
Author

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

@Seanny123
Copy link
Author

Fully resolved in Poetry 1.1.0!

Copy link

github-actions bot commented Mar 3, 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 3, 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

1 participant