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

Doesn't work with sqlalchemy 2 (2.0.30) #164

Open
marillat opened this issue Jun 29, 2024 · 12 comments · May be fixed by #179
Open

Doesn't work with sqlalchemy 2 (2.0.30) #164

marillat opened this issue Jun 29, 2024 · 12 comments · May be fixed by #179
Labels
bug Something isn't working dependencies urgent Issues that should be prioritized as they're breaking user experience

Comments

@marillat
Copy link
Contributor

As reported here 'Debian unstable)

https://bugs.debian.org/1074472

args = Namespace(db_url='', threads=False, gourmanddir='', thread_debug_interval=5.0, thread_debug=False, debug_file='', time=False, debug=None)
Plugin  html_plugin not found
Plugin  archive_plugin not found
Plugin  web_import_plugin not found
Plugin  website_import_plugins not found
Plugin  copy_paste_plugin not found
Traceback (most recent call last):
  File "/usr/bin/gourmand", line 33, in <module>
    sys.exit(load_entry_point('gourmand==1.0.0', 'gui_scripts', 'gourmand')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/main.py", line 624, in launch_app
    RecGui.instance()
  File "/usr/lib/python3/dist-packages/gourmand/main.py", line 848, in instance
    RecGui.__single = cls()
                      ^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/main.py", line 857, in __init__
    GourmandApplication.__init__(self)
  File "/usr/lib/python3/dist-packages/gourmand/main.py", line 72, in __init__
    self.setup_recipes() # Setup recipe database
    ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/main.py", line 149, in setup_recipes
    self.rd = recipeManager.default_rec_manager()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/recipeManager.py", line 82, in default_rec_manager
    return get_recipe_manager(**dbargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/recipeManager.py", line 79, in get_recipe_manager
    return RecipeManager.instance_for(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 1833, in instance_for
    cls._instance_by_db_url[url] = cls(file, custom_url)
                                   ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 1839, in __init__
    self.rd = get_database(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 2110, in get_database
    return RecData.instance_for(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 156, in instance_for
    cls._instance_by_db_url[url] = cls(file, url)
                                   ^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 175, in __init__
    self.initialize_connection()
  File "/usr/lib/python3/dist-packages/gourmand/backends/db.py", line 216, in initialize_connection
    self.metadata = sqlalchemy.MetaData(self.db)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/sqlalchemy/sql/schema.py", line 5470, in __init__
    raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: expected schema argument to be a string, got <class 'sqlalchemy.engine.base.Engine'>.
@pled
Copy link

pled commented Aug 1, 2024

Same issue here. Cannot launch Gourmand anymore.

I am afraid the project is no more maintained, as I don't see anything new since a long time.
Does anybody knows something about it ?

@bkmgit
Copy link
Contributor

bkmgit commented Nov 27, 2024

@marillat
Copy link
Contributor Author

@bkmgit Yes do you have a patch ?

@bkmgit
Copy link
Contributor

bkmgit commented Dec 1, 2024

@marillat May take a bit of time. It runs with Sqlalchemy 1.4. For linux desktop, other alternatives are

Recipe import and export functionality makes the applications quite sticky. The mealmaster format and JSON are the two most widespread formats. RecipeML is another alternative.

@marillat
Copy link
Contributor Author

marillat commented Dec 2, 2024

Sqlalchemy 1.4 is not packaged with the next Debian 13 release.

@FriedrichFroebel
Copy link
Contributor

Our tests already show a similar behavior. For now, main is pinned to version < 2.0. If someone wants to dig deeper here and propose a corresponding PR, I am open to merging it to continue supporting the latest versions.

src/gourmand/backends/db.py:216
  /home/runner/work/gourmand/gourmand/src/gourmand/backends/db.py:216: RemovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.  Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    self.metadata = sqlalchemy.MetaData(self.db)

@FriedrichFroebel FriedrichFroebel added bug Something isn't working urgent Issues that should be prioritized as they're breaking user experience dependencies labels Dec 28, 2024
@marillat
Copy link
Contributor Author

Why to not put sqlalchemy 1.x in a vendor directory as php or Node.js do ?

https://stackoverflow.com/questions/18812614/embedding-a-python-library-in-my-own-package

@bkmgit
Copy link
Contributor

bkmgit commented Dec 29, 2024

It will not get updates. It is a well documented and well maintained project, maintenance cost should be low after update.

@FriedrichFroebel
Copy link
Contributor

Additionally, it contains native code. This means that we would have to ship the third-party wheel for every combination of OS, architecture and Python minor version. Requesting the user to compile the code manually is not suitable.

For now, everyone should be able to install Gourmand from Git where we pin SQLAlchemy accordingly - at least with Python < 3.13.

@marillat
Copy link
Contributor Author

Additionally, it contains native code. This means that we would have to ship the third-party wheel for every combination of OS, architecture and Python minor version. Requesting the user to compile the code manually is not suitable.

No, python3-sqlalchemy in Debian is architecture all and doesn't contains native code.

For now, everyone should be able to install Gourmand from Git where we pin SQLAlchemy accordingly - at least with Python < 3.13.

But sqlalchemy <= 2 isn't available in distribution based on Debian...

@FriedrichFroebel
Copy link
Contributor

FriedrichFroebel commented Dec 29, 2024

I cannot speak for Debian, but the official wheel distribution of SQLAlchemy on PyPI has native components, although they might just be used for speeding up code. Personally, I still do not think Gourmand should ship this dependency itself as there are working solutions. Additionally, distributing the code ourselves might lead to further obligations.

Downstream packagers can still employ their own methods to solve this issue - there regularly are patches which are irrelevant for upstream. If really required, bundling SQLAlchemy there would still be possible if it is relevant.

Alternatively, everyone is still invited to have a look at the code and perform the actual migration.

@bkmgit bkmgit linked a pull request Jan 3, 2025 that will close this issue
6 tasks
@thomasgoirand
Copy link

Upgrading to SQLAlchemy 2.x is a pain, so I'm really sorry to read another bad story about it... :(

Though, please don't make this a debate about downstream distributions. The issue is in Gourmand that should be accepting the latest version of its dependencies, here SQLAlchemy. If Gourmand isn't fixed, sooner or later, it is going to be declared unmaintained, and will be gone. It is very unfortunate, but that's how it works, and this isn't specific to Debian or SQLAlchemy: dependency management is a pain, for any given software.

Hopefully, someone will contribute fixes to Gourmand, and everyone will be happy !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies urgent Issues that should be prioritized as they're breaking user experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants