python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.08k stars 2.26k forks source link

'NoneType' object has no attribute '_source_type' #3362

Closed lazka closed 3 years ago

lazka commented 3 years ago

Poetry 1.1.4 on Debian sid and Ubuntu 20.10:

  AttributeError

  'NoneType' object has no attribute '_source_type'

  at ~/.local/lib/python3.8/site-packages/poetry/inspection/info.py:548 in from_directory
      544│                         raise
      545│ 
      546│                     # we discovered PkgInfo but no requirements were listed
      547│ 
    → 548│         info._source_type = "directory"
      549│         info._source_url = path.as_posix()
      550│ 
      551│         return info
      552│ 
lazka commented 3 years ago

Downgrading to 1.0.10 makes things work again

finswimmer commented 3 years ago

Hello @lazka,

I'm unable to reproduce it. So let's start with the default questions: How have you installed poetry? Can you show the output of poetry config --list?

fin swimmer

lazka commented 3 years ago
> poetry config --list
cache-dir = "/home/lazka/.cache/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/lazka/.cache/pypoetry/virtualenvs
lazka commented 3 years ago

@finswimmer try clearing your poetry cache. If pyyaml got installed with an older poetry before then it also works with the newer one because it doesn't download the sdist.

I've tried on a different machine with Ubuntu 20.10 now, same problem.

lazka commented 3 years ago

It seems to fail deliberately because requires_dist is None, but the package has no dependencies, so that seems.. expected?

lazka commented 3 years ago

I've created #3381 as a start

lazka commented 3 years ago

ok, turns out updating all dependencies of poetry fixes it somehow.

Imo my fix is still valid, but I have no way to reproduce anymore.

agatti commented 3 years ago

For what it's worth, I can reproduce this on macOS and Python 3.8 with aiohttp as a failng dependency - starting from a newly created project. Using Poetry version 1.1.4, with just poetry init and poetry add "aiohttp[speedups]" (or just poetry add aiohttp) I get the very same error.

Just in case, my configuration looks like this:

❯ poetry config --list
cache-dir = "/Users/agatti/Library/Caches/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/agatti/Library/Caches/pypoetry/virtualenvs

removing /Users/agatti/Library/Caches/pypoetry does not seem to change anything, it seems.

lazka commented 3 years ago

yeah, I've also had it on another machine again. I can't figure out which dependency update "fixes" it.

agatti commented 3 years ago

For aiohttp the problem is triggered by multidict, according to poetry install <package> -vvv. But then I had this happen on other dependencies that share nothing with aiohttp, with the only common bit across the board being that the error shows up when a dependency needs to fetch a sdist package.

agatti commented 3 years ago

This is getting weird, apparently this is blocking installation of "mainstream" dependencies like flask, pandas, psycopg2 and the like. Did anything change on pypi side to trigger this error?

Killerjay666 commented 3 years ago

Hi guys, running into the same issue in bitbucket pipelines: Ubuntu 18.04 Poetry version 1.0.5

Packages to install include similar ones mentioned above; flask, pandas, aiohttp Trying to update poetry to see if that resolves it

grucha commented 3 years ago

I've encountered the same problem: installing couchbase ^3.0.7 fails exactly the same way.

I'm using poetry 1.1.4

erronppl commented 3 years ago

I got the same problem. I replicated the issue by running poetry new 3362, cd 3362 and poetry add -vvv ujson. Other packages, such as black, were fine.

I use Guix OS v1.2.0 which is atypical compare to other Linux distros. It includes a functional package manager which builds every packages from sources.

As a solution, I rebuilt Guix's Poetry package to depend on python-pkginfo v1.6.1.

I noticed the error when I git clone Poetry and ran the tests. All the tests were passing, but the ones below.

tests/inspection/test_info.py::test_info_setup_complex
tests/inspection/test_info.py::test_info_setup_complex_pep517_error
tests/inspection/test_info.py::test_info_setup_complex_pep517_legacy
tests/inspection/test_info.py::test_info_setup_complex_disable_build
tests/inspection/test_info.py::test_info_setup_missing_mandatory_should_trigger_pep517[version]
tests/inspection/test_info.py::test_info_setup_missing_mandatory_should_trigger_pep517[name]
tests/inspection/test_info.py::test_info_setup_missing_mandatory_should_trigger_pep517[install_requires]

I hope this helps.

finswimmer commented 3 years ago

Very strange. I'm still not able to reproduce it :thinking:

agatti commented 3 years ago

Tried just now:

❯ poetry new bug -n
Created package bug in bug
❯ cd bug
❯ poetry add pyinstaller
Creating virtualenv bug-3G4Pdgi1-py3.8 in /Users/agatti/Library/Caches/pypoetry/virtualenvs
Using version ^4.1 for pyinstaller

Updating dependencies
Resolving dependencies... (13.9s)

  AttributeError

  'NoneType' object has no attribute '_source_type'

  at /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/poetry/inspection/info.py:548 in from_directory
      544│                         raise
      545│
      546│                     # we discovered PkgInfo but no requirements were listed
      547│
    → 548│         info._source_type = "directory"
      549│         info._source_url = path.as_posix()
      550│
      551│         return info
      552│
grucha commented 3 years ago

I have the same error with poetry 1.1.4 installed from macports on macOS 11.1. Uninstalled that poetry port, installed it via install script and it works fine now.

guybogaarts commented 3 years ago

I can confirm that what @grucha suggested solved the problem for me as well: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

agatti commented 3 years ago

@grucha I've been using macports as well, but unless the tarball used by macports differs from what's on the poetry releases page then what could change? The interpreter (and therefore all system and extra dependencies added) still comes from macports and would still be the same in both cases.

neverpanic commented 3 years ago

@agatti I'm guessing some dependency version differs subtly. Help welcome in figuring out which one.

neverpanic commented 3 years ago

I think I figured it out, poetry relies on this commit in pkginfo, i.e. at least pkginfo >= 1.5.0.

lazka commented 3 years ago

I can confirm that updating pkginfo from 1.4.2 to 1.5.0 fixes the issue for me.

lazka commented 3 years ago

I've created #3614

tlc28 commented 3 years ago

Hi @lazka

I can confirm that updating pkginfo from 1.4.2 to 1.5.0 fixes the issue for me.

It also solves the problem for me! Thanks!

abn commented 3 years ago

Executing the following will reproduce the issue.

podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -xe
python -m pip install -q poetry
# install latest 1.5 version
python -m pip install -q pkginfo==1.4.2
python -m poetry new issue
pushd issue
python -m poetry add pyyaml==5.3.1 || true

# try with 1.5.0
python -m pip install -q pkginfo==1.5.0
python -m poetry add pyyaml==5.3.1
EOF

Output:

+ python -m pip install -q poetry
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
+ python -m pip install -q pkginfo==1.4.2
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
+ python -m poetry new issue
Created package issue in issue
+ pushd issue
/issue /
+ python -m poetry add pyyaml==5.3.1
Creating virtualenv issue-XfWtZh9W-py3.8 in /root/.cache/pypoetry/virtualenvs

Updating dependencies
Resolving dependencies...

  AttributeError

  'NoneType' object has no attribute '_source_type'

  at /usr/local/lib/python3.8/site-packages/poetry/inspection/info.py:548 in from_directory
      544│                         raise
      545│ 
      546│                     # we discovered PkgInfo but no requirements were listed
      547│ 
    → 548│         info._source_type = "directory"
      549│         info._source_url = path.as_posix()
      550│ 
      551│         return info
      552│ 
+ true
+ python -m pip install -q pkginfo==1.5.0
WARNING: You are using pip version 20.2.4; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
+ python -m poetry add pyyaml==5.3.1

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 9 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing attrs (20.3.0)
  • Installing more-itertools (8.7.0)
  • Installing packaging (20.9)
  • Installing pluggy (0.13.1)
  • Installing py (1.10.0)
  • Installing wcwidth (0.2.5)
  • Installing pytest (5.4.3)
  • Installing pyyaml (5.3.1)
gruns commented 3 years ago

confirming this fix: upgrading from pkginfo==1.4.2 to pkginfo==1.7.0 fixes the problem

Resolving dependencies... (5.5s)

  AttributeError

  'NoneType' object has no attribute '_source_type'

  at /usr/local/lib/python3.6/dist-packages/poetry/inspection/info.py:548 in from_directory
      544│                         raise
      545│ 
      546│                     # we discovered PkgInfo but no requirements were listed
      547│ 
    → 548│         info._source_type = "directory"
      549│         info._source_url = path.as_posix()
      550│ 
      551│         return info
      552│ 

with poetry v1.1.4

hansharhoff commented 2 years ago

Be aware that this bug is still present in the current release version of poetry (1.1.10). Fix is in master branch but has not been released yet.

If you hit the issue you can manually upgrade pkginfo to latest version with e.g.

pip install --upgrade pkginfo

Fix line in master

github-actions[bot] commented 6 months ago

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.