nix-community / poetry2nix

Convert poetry projects to nix automagically [maintainer=]
MIT License
892 stars 451 forks source link

Unable to parse poetry.lock file with greenlet: invalid literal #360

Closed lunik1 closed 3 years ago

lunik1 commented 3 years ago

My poetry.lock file has been generated with the line

greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32\""}

This is listed as a dependency of sqlalchemy:

[[package]]
name = "sqlalchemy"
version = "1.4.23"
description = "Database Abstraction Library"
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7"

[package.dependencies]
greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32\""}

[package.extras]
aiomysql = ["greenlet (!=0.4.17)", "aiomysql"]
aiosqlite = ["greenlet (!=0.4.17)", "aiosqlite"]
asyncio = ["greenlet (!=0.4.17)"]
mariadb_connector = ["mariadb (>=1.0.1)"]
mssql = ["pyodbc"]
mssql_pymssql = ["pymssql"]
mssql_pyodbc = ["pyodbc"]
mypy = ["sqlalchemy2-stubs", "mypy (>=0.910)"]
mysql = ["mysqlclient (>=1.4.0,<2)", "mysqlclient (>=1.4.0)"]
mysql_connector = ["mysqlconnector"]
oracle = ["cx_oracle (>=7,<8)", "cx_oracle (>=7)"]
postgresql = ["psycopg2 (>=2.7)"]
postgresql_asyncpg = ["greenlet (!=0.4.17)", "asyncpg"]
postgresql_pg8000 = ["pg8000 (>=1.16.6)"]
postgresql_psycopg2binary = ["psycopg2-binary"]
postgresql_psycopg2cffi = ["psycopg2cffi"]
pymysql = ["pymysql (<1)", "pymysql"]
sqlcipher = ["sqlcipher3-binary"]

When trying to build this with nix I get the error

error: [json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: '32 W'; expected end of input
l0b0 commented 3 years ago

When parsing

greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32\""}

I get a similar message:

error: expected end-of-string while parsing JSON value: WIN32"

Workaround: Remove that line from poetry.lock.

neumantm commented 3 years ago

I have the same problem. I don't think just deleting the dependency is a good workaround. Better just remove the markers attribute, but even then I don't think manually editing the poetry.lock can be the solution. Poetry can parse this line, and therefore poetry2nix should as well be able.

l0b0 commented 3 years ago

Definitely @neumantm, that's why I only suggested it as a workaround to be able to continue working.

l0b0 commented 3 years ago

OK, this is very interesting: the minimal fix is to remove just the "win32" part of that string! That is, changing

greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 win32 WIN32\""}

to

greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine in \"x86_64 X86_64 aarch64 AARCH64 ppc64le PPC64LE amd64 AMD64 WIN32\""}

makes poetry2nix build. Why is "win32" a special value? I can't see any reference to this specific token in the code.

adisbladis commented 3 years ago

I believe this issue was fixed in 203fb43910143e926ad80e08a3d0bb46130c49ec and shouldn't be a problem in Poetry2nix on master or in a Poetry2nix release past 1.18.0.

With that commit reverted I can reproduce the exact issue on master, so I will consider it fixed unless I can get a minimal reproduction case that fails against master.

l0b0 commented 3 years ago

Thank you for the info @adisbladis - looking forward to the release!

l0b0 commented 3 years ago

PS: Would you be interested in a minimal test case, trying to install SQLAlchemy?

adisbladis commented 3 years ago

PS: Would you be interested in a minimal test case, trying to install SQLAlchemy?

Sure, why not?