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

'NoneType' object has no attribute 'to_dependency' #16

Closed
breitburg opened this issue Oct 12, 2020 · 6 comments
Closed

'NoneType' object has no attribute 'to_dependency' #16

breitburg opened this issue Oct 12, 2020 · 6 comments

Comments

@breitburg
Copy link

I tried to deploy my app that uses Poetry, but got an error:

-----> Patch Poetry export file
-----> Export requirements.txt from Poetry
  AttributeError
  'NoneType' object has no attribute 'to_dependency'
  at ~/.poetry/lib/poetry/packages/locker.py:234 in get_project_dependencies
      230│                     # project level dependencies take precedence
      231│                     continue
      232│ 
      233│                 # we make a copy to avoid any side-effects
    → 234│                 requirement = deepcopy(__get_locked_package(requirement).to_dependency())
      235│                 requirement._category = pkg.category
      236│ 
      237│                 if pinned_versions:
      238│                     requirement.set_constraint(
-----> Export Python version from Poetry to Heroku runtime.txt file
-----> Write 3.8.6 into runtime.txt
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
       More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

My poetry.lock file:

[[package]]
category = "main"
description = "Fast and simple WSGI-framework for small web-applications."
name = "bottle"
optional = false
python-versions = "*"
version = "0.12.18"

[[package]]
category = "main"
description = "WSGI HTTP Server for UNIX"
name = "gunicorn"
optional = false
python-versions = ">=3.4"
version = "20.0.4"

[package.dependencies]
setuptools = ">=3.0"

[package.extras]
eventlet = ["eventlet (>=0.9.7)"]
gevent = ["gevent (>=0.13)"]
setproctitle = ["setproctitle"]
tornado = ["tornado (>=0.2)"]

[[package]]
category = "main"
description = "Python client for Redis key-value store"
name = "redis"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "3.5.3"

[package.extras]
hiredis = ["hiredis (>=0.1.3)"]

[metadata]
content-hash = "184994068e190b2720ed44423cc8673e8300ceae582e90301adbe7502e598b42"
lock-version = "1.0"
python-versions = "3.8.6"

[metadata.files]
bottle = [
    {file = "bottle-0.12.18-py3-none-any.whl", hash = "sha256:43157254e88f32c6be16f8d9eb1f1d1472396a4e174ebd2bf62544854ecf37e7"},
    {file = "bottle-0.12.18.tar.gz", hash = "sha256:0819b74b145a7def225c0e83b16a4d5711fde751cd92bae467a69efce720f69e"},
]
gunicorn = [
    {file = "gunicorn-20.0.4-py2.py3-none-any.whl", hash = "sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"},
    {file = "gunicorn-20.0.4.tar.gz", hash = "sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626"},
]
redis = [
    {file = "redis-3.5.3-py2.py3-none-any.whl", hash = "sha256:432b788c4530cfe16d8d943a09d40ca6c16149727e4afe8c2c9d5580c59d9f24"},
    {file = "redis-3.5.3.tar.gz", hash = "sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2"},
]
@zyv
Copy link
Contributor

zyv commented Oct 12, 2020

Caused by #13.

@zyv
Copy link
Contributor

zyv commented Oct 12, 2020

Well, this really sucks - our patch for poetry 1.1.2 brokenness apparently broke something that was working before - sorry about that. Could you please in the meantime just pin the poetry version to 1.1.1?

@zyv
Copy link
Contributor

zyv commented Oct 12, 2020

@marns93 could you please add an if-else here:

sed -i '234s/deepcopy(requirement)/deepcopy(__get_locked_package(requirement).to_dependency())/' $HOME/.poetry/lib/poetry/packages/locker.py

- deepcopy(__get_locked_package(requirement).to_dependency())
+ deepcopy(__get_locked_package(requirement).to_dependency()) if __get_locked_package(requirement) else deepcopy(requirement)

@marns93
Copy link
Contributor

marns93 commented Oct 12, 2020

@breitburg Could you please try again? The fix should solve your problem.

@zyv
Copy link
Contributor

zyv commented Oct 12, 2020

@breitburg would be awesome if you could provide you pyproject.toml for regression tests as well.

@breitburg
Copy link
Author

breitburg commented Oct 12, 2020

Yep! The issue was fixed! Thank you!

My pyproject.toml file:

[tool.poetry]
name = "bruh"
version = "0.1.0"
description = "Service that implements REST-ful API service"
authors = ["Ilya Breitburg <me@breitburg.com>"]

[tool.poetry.dependencies]
python = "3.8.6"
redis = "^3.5.3"
bottle = "^0.12.18"
gunicorn = "^20.0.4"

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants