mmatuson / SchemaSync

A MySQL Schema Versioning and Migration Utility
http://mmatuson.github.io/SchemaSync/
Other
337 stars 110 forks source link

Cannot run via `pipx` #69

Open stephenreay opened 5 months ago

stephenreay commented 5 months ago

After the 'simple' fixes in #68 schemasync seems to run properly under python3 again, but when trying to install it as a global tool we're advised to no longer use sudo pip install but instead to use pipx (with some other hoop jumping to get a truly global install).

However something isn't quite right when it's installed this way, but I can't quite tell what.

Using schemasync from a pipx install (using a local copy of the repo with the fixes applied in #68 as the source) gives:

Traceback (most recent call last):
  File "/home/vagrant/.local/bin/schemasync", line 5, in <module>
    from schemasync.schemasync import main
  File "/home/vagrant/.local/pipx/venvs/schemasync/lib/python3.11/site-packages/schemasync/schemasync.py", line 9, in <module>
    import syncdb
ModuleNotFoundError: No module named 'syncdb'

The schemasync executable at /home/vagrant/.local/bin/schemasync contains this:

#!/home/vagrant/.local/pipx/venvs/schemasync/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from schemasync.schemasync import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Even weirder, if I just execute the main schemasync.py file directly using that env's python, it works fine:

/home/vagrant/.local/pipx/venvs/schemasync/bin/python /home/vagrant/.local/pipx/venvs/schemasync/lib/python3.11/site-packages/schemasync/schemasync.py 

Python isn't really my deal, I'm just trying to make this tool work for a client's project. It'd be great if someone a little more knowledgeable in Python could look into this. I don't have unlimited time to mess around with it, but if there are suggestions of what to try, I can do so, within reason.

mitsh commented 5 months ago

I'll check it in a days maybe but if you fix it and make PR I'll accept it.