patri9ck / a2ln-server

A way to display Android phone notifications on Linux (Server)
GNU General Public License v3.0
97 stars 7 forks source link

Package it for pip #25

Closed Jan9103 closed 1 year ago

Jan9103 commented 1 year ago

It is now possible to package it and distribute it as python package:

Resources:

patri9ck commented 1 year ago

Thanks for your PR. Submitting it to PyPI is a step into the right direction I guess. Right now there are some problems that come with it and I'm not sure how to go with them.

Especially the first problems basically breaks every distribution that isn't pip. To avoid those problems that come up with Python, I always tried to avoid A2LN becoming more than a simple script consisting of one file but that won't work in this case anymore of course.

I guess the only solution to this is to copy a file from the source directory the way you intended it or to switch to another programming language where you can just compile your source code files into a single binary.

Jan9103 commented 1 year ago

Users that installed A2LN through pip will not have access to the systemd unit. It is not a big deal but something to keep in mind.

I'm aware, but we can't fix it - allowing pip installation however still makes it easier to install and makes packaging for other formats easier (i think), which could ship it.

Make: We shouldn't just copy a file from the source code somewhere to /usr/bin. It is very bad practice in my opinion and won't scale up in the future.

i agree. i just wanted to touch the existing systems as little as possible. pip without root permissions should install it to ~/.local/bin, but for installing it as root you should not use pip i think (once again: more packaging options and its currently the same).

Uninstalling won't work that easy

For me pip3 uninstall a2ln-server removed every file it created (sudo updatedb && locate a2ln didn't find any traces)

Especially the first problems basically breaks every distribution that isn't pip.

since even debian does not include all dependencies in their repositories pip is our best bet to make it compatible with as many distros as we can i think.
we can still package it as appimage (btw: i tried doing it using the python-appimage tool, but encountered a few issues)

I always tried to avoid A2LN becoming more than a simple script

yes. i agree, but as far as I'm aware you have to add such a structure if you want to package it for pip.

a big issue with packaging this project is its dependencies - i spend a bit of time trying to create a distroless docker image from it, but gave up after having to manually add a lot of libraries to it (i think the graphics-library for the qr-code-generation pulls in a lot of stuff). this probably makes creating small appimages (aka not having a entire distro in it) a real chore.

switch to another programming language where you can just compile your source code files into a single binary.

The question is: which language?

I might take a look at porting it to rust to learn a bit more about networking in rust, but i assume it won't get to a usable state.

i didn't create this MR with the expectation to have it merged - i just wanted to try packaging it and show whats necessary

patri9ck commented 1 year ago

For a rewrite, C, Rust and Go would probably be the only options, though I cannot use any of them. I initially chose Python because it gets you the job done quite easily. I will try my best to get a working pip installation.

patri9ck commented 1 year ago

@Jan9103 After running python3 -m build and python3 -m pip install ./dist/a2ln_server-1.1.4.tar.gz, how do you start the server?

Jan9103 commented 1 year ago

python3 -m pip install ./dist/a2ln_server-1.1.4.tar.gz installs it and puts a binary, which launches it into ~/.local/bin/a2ln -> just running a2ln does the job if its in your path (export PATH="$PATH:$HOME/.local/bin")

EDIT: in case it is different and where a2ln doesn't show anything you can do pip3 uninstall a2ln-server and it will show you the location of all files it will remove (including one of a files just called a2ln, which is the executable)

EDIT2: you commit broke it a bit - i wrote a small fixup commit -> it should work again. btw: i left if __name__ == "__main__" in there intentionally since it doesn't break anything and makes it easier to install without pip

patri9ck commented 1 year ago

@Jan9103 Can you maybe update your main branch on your fork so I can merge it into this branch and fix the merge conflicts?

I think everything else looks fine so far.

patri9ck commented 1 year ago

In the next few days, I will create an account on PyPI and submit the package there.

patri9ck commented 1 year ago

It is finally available at https://pypi.org/project/a2ln/.