asus-linux-drivers / asus-numberpad-driver

Maintained feature-rich linux driver for NumberPad(2.0) on Asus laptops. NumberPad(2.0) is illuminated numeric keypad integrated to touchpad which appears when is done tap on top right corner of touchpad for atleast 1s by default (configurable) or slide gesture from top right/left corner to the center, the left shows calc app aswell (configurable).
GNU General Public License v2.0
257 stars 19 forks source link

[Bug]: Doesn't install properly on Arch due to non-existent package #156

Closed soleofthesea closed 8 months ago

soleofthesea commented 8 months ago

Describe the bug

The script attempts to install python3-smbus2 which does not exist in the Arch repos, instead it is found in the AUR (under python-smbus).

Also, despite pacman returning an error the script just continues.

Expected behavior

Either the script manages to auto-install the package or aborts with an error message

Relevant log output

No response

Desktop

ldrahnik commented 8 months ago

@soleofthesea Thank you for creating the issue. It is wrong dependency. It is not the equivalent package python-smbus2?

I use import:

from smbus2 import SMBus, i2c_msg
ldrahnik commented 8 months ago

Can be reopened

ghost commented 8 months ago

trying to run install.sh on my zenbook ux3404 q420v on arch gives the same error aforementioned. installing python-smbus2 manually and running the script again, results in the error once again.

ldrahnik commented 8 months ago

Please post here output of install attempt. Package does not exist python-smbus2? Or what an error do you mean?

soleofthesea commented 8 months ago

It's because pacman doesn't look at the AUR so as far as it's concerned python-smbus2 still doesn't exist.

Cleanest solution Temporary workaround; it is no longer recommended to use pip to install modules globally would probably be to build straight from source, something like

pacman -S git
git clone https://github.com/kplindegaard/smbus2
cd smbus2
python - pip install .
ghost commented 8 months ago

the error im referring to is the following

error: target not found: python-smbus2
Something went wrong when installing packages via package manager

also, i've tried building from source like @soleofthesea mentioned but it seems to bounce back an invalid syntax error.

soleofthesea commented 8 months ago

Might also need python-setuptools.

ldrahnik commented 8 months ago

@soleofthesea What about refactoring the code to the mentioned previous version? That is available on Arch without any obstructions? I mean python-smbus. The driver only needs to write to the i2c register, nothing else.

ldrahnik commented 8 months ago

The master branch has been hard reset.

ghost commented 8 months ago

the script seems to still give the error, but ignores it and continues on with the script. the script preforms normally and installs, but doesn't seem to work for me. (no backlighting & no numpad functions). might just be an issue on my end though, someone else should give it a try.

ldrahnik commented 8 months ago

@dvdoll Could you please follow up:

$ pacman -S git
$ git clone https://github.com/kplindegaard/smbus2
$ cd smbus2
$ python - pip install .

With current state of the master, whether it helps light up NumberPad.

ghost commented 8 months ago
>>> pip install .
  File "<stdin>", line 1
    pip install .
        ^^^^^^^
SyntaxError: invalid syntax
>>> 
soleofthesea commented 8 months ago

Ahem

So about that syntax error...apologies, typo. Correct command should be python -m pip install .

ghost commented 8 months ago

no worries. it happens. after running that command, it said pip wasn't found, so i ran sudo pacman -S python-pip, ran python -m pip install . and received the following.

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.

    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
ldrahnik commented 8 months ago

Yes, because of this pip is not the way how solve this problem. What about to use previous package? Can you confirm me the previous package can be installed? python-smbus

ghost commented 8 months ago

the only packages i can find are python-smbus2 and python-smbus-git which are both aur packages.

soleofthesea commented 8 months ago

What @dvdoll said. https://archlinux.org/packages/?sort=&q=smbus&maintainer=&flagged=

As I understand it error: externally-managed-environment is only of concern if there is an equivalent package in Arch's repos, because a pacman -Syu might override pip and vice versa. So while a bit alarmist it should be safe to ignore it for this instance... at least until a proper substitute can be found, anyway.

ldrahnik commented 8 months ago

@soleofthesea Could you please post here exactly the same commands what I can use? Or do not you want make PR? With pip solution.

soleofthesea commented 8 months ago

Well, about that... it might be OK to ignore the error for now just to get the driver to run but you're not really supposed to do that. (This is recent change in Linux so I forgot, so please ignore my earlier comment about it being a "solution")

ldrahnik commented 8 months ago

@dvdoll Could you please test whether this helps. Please try first way via yay, try driver then uninstall via yay -Rns python-smbus2, and please try even the second option via $ makepkg

ldrahnik commented 8 months ago

@dvdoll @soleofthesea Please, test the branch

ldrahnik commented 8 months ago

@soleofthesea @dvdoll How I can check whether $ yay (https://github.com/Jguer/yay) is installed? Is it possible like this $ yay 2>/dev/null? Then $ echo $? returns 0 in the case is installed and 1 when is not?

soleofthesea commented 8 months ago

Probably, but yay is not the only AUR helper, though. https://wiki.archlinux.org/title/AUR_helpers And what happens if the user does not have any of them?

I think it might be simpler to just create a Python venv at this point.

ldrahnik commented 8 months ago

And what happens if the user does not have any of them?

Is used makepkg -si

ldrahnik commented 8 months ago

Probably

Probably? Could you please open the terminal and try that? Thank you

ldrahnik commented 8 months ago

I think it might be simpler to just create a Python venv at this point.

Pull request is welcome

soleofthesea commented 8 months ago

Probably? Could you please open the terminal and try that? Thank you

If the script is going to manually build from AUR via makepkg -si then writing additional code to use yay is redundant. Like buying instant coffee when you already have a coffee maker.

ldrahnik commented 8 months ago

If the script is going to manually build from AUR via makepkg -si then writing additional code to use yay is redundant. Like buying instant coffee when you already have a coffee maker.

Did you check the code in the mentioned branch? yay is at this moment commited only as preferred variant over makepkg -si as using AUR helper has benefits. Please focus more on the topic or write nothing, thank you.

soleofthesea commented 8 months ago

Alright, fair point. But there should be handling for paru and pamac too; those are pretty popular helpers as well. Also I'm currently on mobile, so I'll respond later once I'm able to test the code.

ldrahnik commented 8 months ago

I have to agree with you, it looks like there is no obstacle why not use Python3 virtual environment. Init for you to test is pushed to this branch.

My insights:

$ virtualenv --python=$(python3 --version | cut -d" " -f2) /usr/share/asus-numberpad-driver/.env
# python3 -m venv /usr/share/asus-numberpad-driver/.venv (needs package python3.10-env and because of that was not used)

Side effects:

ldrahnik commented 8 months ago

@soleofthesea @dvdoll Merged to the master. Can be reopened.

EDIT: only pin the previous solution without Python3 virtual environment virtualenv


        # because package python3-smbus2 is available only on AUR
        #
        # https://github.com/asus-linux-drivers/asus-numberpad-driver/issues/156
        if [[ $(yay 2>/dev/null)]]; then
            yay -S python-smbus2
        else
            git clone https://aur.archlinux.org/python-smbus2.git ~/python-smbus2
            cd ~/python-smbus2
            # -i     it calls pacman -U <package>
            # -s     instructs pacman to resolve dependencies and install missing packages
            makepkg -si
        fi