DidYouMean-Python icon indicating copy to clipboard operation
DidYouMean-Python copied to clipboard

fixed paths for pip install

Open FedeClaudi opened this issue 3 years ago • 8 comments

Hi @SylvainDe,

I know you have another PR that fixes this module's imports to make it work with pip install (https://github.com/SylvainDe/DidYouMean-Python/issues/52), but it's a bit outdated so I thought I'd open a new one.

The fix is fairly simple, where before you had:

from didyoumean_common_tests import (
    TestWithStringFunction,
    get_exception,
    no_exception,
    NoFileIoError,
    unittest_module
    )

now it's

from .didyoumean_common_tests import (
    TestWithStringFunction,
    get_exception,
    no_exception,
    NoFileIoError,
    unittest_module
    )

notice the . before didyoumean_common_tests, that tells python's importer to import those functions from the didyoumean_common_tests of didyoumean.

Similarly:

import didyoumean_common_tests as common

becomes

from didyoumean import didyoumean_common_tests as common

Hope that this helps clarify things a little bit, it might take a bit to wrap your head around how to import stuff (I know it took me quite a while).


Btw I've moved readme_examples.py outside of the package's folder because generally code for examples and tests should be separate from the package's code (e.g. see folder structure here). Feel free to move it back if you prefer

FedeClaudi avatar Nov 01 '20 09:11 FedeClaudi

Bumped a new commit with fixes for those errors

FedeClaudi avatar Nov 01 '20 10:11 FedeClaudi

Wow, that was fast!

SylvainDe avatar Nov 01 '20 10:11 SylvainDe

Many thanks for the 3 iterations! Now, the CI is detecting more interesting issues... which may be caused by a few things that were done improperly in my original code. I'll try to get a better understanding of what we have... (Also, I guess I may have to drop support for older Python versions)

SylvainDe avatar Nov 01 '20 11:11 SylvainDe

mmm that's weird, I haven't run the tests but the package worked fine for me.. I've only used pytest for running tests though, so not sure what the problem is here.

FedeClaudi avatar Nov 01 '20 11:11 FedeClaudi

it might help to keep you test code and your package code separate, that might be the cause of error (it complains about relative imports)

FedeClaudi avatar Nov 01 '20 11:11 FedeClaudi

FYI, I've started to try out a few things on https://github.com/SylvainDe/DidYouMean-Python/tree/testingPr53 with very limited success. I'll keep you posted if I do thing something interesting in the future and merge your PR at that point.

SylvainDe avatar Nov 01 '20 14:11 SylvainDe

sounds good, good luck!

FedeClaudi avatar Nov 01 '20 20:11 FedeClaudi

@SylvainDe ping for this or any of the three PRs attacking the same problem

alexmojaki avatar Aug 27 '21 00:08 alexmojaki