bwhmather / ssort

Tool for automatically sorting python statements within a module
MIT License
360 stars 10 forks source link

Should “from ssort._* import” be “from ._* import”? #109

Closed kseistrup closed 8 months ago

kseistrup commented 8 months ago

I am attempting to package ssort for ArchLinux User Repository (AUR), and building an importable package is relatively unproblematic. However, when I lint the package, the ArchLinux-specific namcap(1) complains that ssort._* is an uninstalled dependency. And indeed, the ssort module is not installed until I have installed the package that I just built (and haven't yet installed).

When I replace from ssort._* import with from ._* import in *.py the package linter is satisfied because it will find the necessary dependencies in the same directory, and the ssort CLI script seems to work as expected once the package has been installed.

Would such a change break other functionalities?

Disclaimer: I am definitely not a python module packager expert, so I am possibly misunderstanding something.

bwhmather commented 8 months ago

Might be a result of the python source files being wrapped in a src folder, assuming you are using the source package rather than the new wheel? Try stripping that. There might be a standard arch way to do it as it isn't that uncommon a pattern.

Thanks for giving this a go. If you are successful then I will probably end up using your PKGBUILD.

kseistrup commented 8 months ago

The PKGBUILD file is building a wheel, that is then installed. You can see the PKGBUILD here:

bwhmather commented 8 months ago

The output from your PKGBUILD looks good to me. I've run namcap on a few different python packages in my /var/cache/pacman/pkg directory and see many instances of the same error. I think it's a bug in namcap.

bwhmather commented 8 months ago

RE the PKGBUILD: might make more sense to build from the published packages rather than git. ssort is stable enough that new commits generally justify a new version. I very rarely merge anything without publishing to pypi.

kseistrup commented 8 months ago

I think it's a bug in namcap.

That's very possible. The namcap recent recived an update, and now it is complaining over things I wouldn't even know how to mitigate. The import issue here could very well be another one.

might make more sense to build from the published packages rather than git.

Thanks. I am a little ashamed (though only a little) to report that I'm lazy. Publishing stable releases often requires more work because I have to update the PKGBUILD file for every new release. In contrast, packages built from VCS checkouts often build like a charm commit after commit, version after version. :blush:

bwhmather commented 8 months ago

Thanks. I am a little ashamed (though only a little) to report that I'm lazy. Publishing stable releases often requires more work because I have to update the PKGBUILD file for every new release. In contrast, packages built from VCS checkouts often build like a charm commit after commit, version after version. 😊

Hah. Fair enough. ssort is stable enough that new commits are likely to correspond to the latest version. You're unlikely to get anything half baked.

bwhmather commented 8 months ago

Closing, tentatively, as false positive.