pleiszenburg / zugbruecke

Calling routines in Windows DLLs from Python scripts running under Linux, MacOS or BSD
https://zugbruecke.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
108 stars 11 forks source link

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.local/lib/python3.11/site-packages' #101

Open milahu opened 2 months ago

milahu commented 2 months ago

https://github.com/pleiszenburg/zugbruecke/blob/3cf84f9a27941de066e90944f5160c4fe77e4936/src/zugbruecke/core/wenv.py#L120-L121

fix:

            if not os.path.exists(sitepackages):
                continue

edit: no, that only hides the issue, when zugbruecke is not installed to /home/user/.local/lib/python3.11/site-packages

ValueError: ('dist-info for package could not be found', 'zugbruecke')

instead, zugbruecke should use __file__ to find zugbruecke-0.2.1.dist-info wenv.__file__ to find wenv-0.5.1.dist-info etc

    def _setup_package(self, name: str, version: str):
        # ...
        if name == "zugbruecke":
            unix_dist_path = os.path.realpath(os.path.dirname(__file__) + "../../../" + dist_name)
        elif name == "wenv":
            import wenv
            unix_dist_path = os.path.realpath(os.path.dirname(wenv.__file__) + "/../" + dist_name)
        else:
            raise Exception(f"FIXME find dist path of package {name}")
s-m-e commented 2 months ago

A variation of this bug blobbed up before a few years ago - though I found it hard to add a proper test for it. PR highly welcome.