by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    be able to unregister dependendee plugins iiuc
    i think at the end of the day though we'll need to add something of our own since plugins don't have to be registered via the setuptools entry point api
    Alex Grönholm
    @agronholm
    there is no other mechanism available AFAIK for them to be auto-activated though
    goodboy
    @goodboy
    then entry points?
    anyway gotta run but i'll be back later if you've got any insights
    goodboy
    @goodboy
    @agronholm also, sweet, that seems to have worked
    thanks again for the tip
    Alex Grönholm
    @agronholm
    :ok_hand:
    Axel Huebl
    @ax3l
    Hi, am looking at the latest python 3.8 changes in pypa/manylinux and noticed that the cpython abi tag has changed from cp37m to cp38 (without the m) in the latest images. According to google this means Python 3.8 is not using pymalloc, should I be concerned?
    Axel Huebl
    @ax3l
    hm, one month silence in this channel. posted in pypa/manylinux#393
    Alex Grönholm
    @agronholm
    @ax3l there is no separate m variant anymore
    Axel Huebl
    @ax3l
    thanks! Yes found out that with and without pymalloc is now binary compatible, very nice
    Axel Huebl
    @ax3l

    Urgh, I posted this in pypa/setuptools but it probably belongs here.
    This confuses me a lot:

    $ python3 -m pip install -U pip setuptools wheel cmake --user
    Collecting pip ... 
    Collecting setuptools ...
    Collecting wheel ...
    Collecting cmake ...
          File "<string>", line 1, in <module>
        ModuleNotFoundError: No module named 'setuptools'

    As seen on Azure CI for Ubuntu 18.04. Why can't pip figure out to install setuptools first?
    As a work-around, I install this now in two steps...

    Or is this just a bug in the cmake package and it does not declare its setuptools dependency properly?
    mroavi
    @mroavi
    I created a package that needs to be run under root permission to function properly. The reason why it needs root permissions is that it uses evdev under the hood to remap keyboard strokes. I used cookiecutter to create the skeleton of my package. I registered in PyPI and was able to publish my package.
    Now, when I install my package using pip install onthefly I get this message:
    Defaulting to user installation because normal site-packages is not writeable
    So it installs the package somwehre inside my user's .local directory.
    The problem is that now I can't run my executable with sudo permissions:
    ❯ sudo onthefly
    sudo: onthefly: command not found
    How can I install the package using pip at a system level so that the command above doesn't fail?
    This is my first Python package by the way. I'm very new to Python.
    mroavi
    @mroavi
    I have the feeling that the proper way to do this is modifyiing my project's setup.py.
    But I haven't been able to find clear info on what I have to do.
    Alex Grönholm
    @agronholm
    @mroavi if you try it without sudo, do you still get "command not found"?
    mroavi
    @mroavi
    @agronholm No, without sudo I am able to run the binary but the program fails since it doesn't have rights to see the devices (Ubuntu) in my system. The binary is located inside my home folder: /home/mroavi/.local/bin/onthefly
    Alex Grönholm
    @agronholm
    @mroavi I'm guessing that with sudo, that directory is no longer on the path
    is your script needs sudo, I advise you to make it re-run itself with sudo if it doesn't have root privileges
    mroavi
    @mroavi

    @agronholm I googled "re-running python script with sudo" to see if I could find some an example of what you mean. I found this stackoverflow question: https://stackoverflow.com/questions/5191878/change-to-sudo-user-within-a-python-script . Is that what you mean?

    Use Tcl and Expect, plus subprocess to elevate yourself. So basica ...

    Alex Grönholm
    @agronholm
    no, I'm talking about using one of the os.exec* functions to replace the current process with a new one with "sudo" added
    I did that not too long ago myself, let me see if I can find it
    Alex Grönholm
    @agronholm
    @mroavi I had this in my script: os.execlp('sudo', sys.executable, sys.executable, os.path.abspath(__file__))
    you'd need to add command line arguments to the mix if your script supports those
    mroavi
    @mroavi
    @agronholm thanks! I will give it a try this afternoon.
    mroavi
    @mroavi
    I found a simpler solution that I will leave here for reference. Using sudo python -m pip install onthefly correctly installs my package at system level in /usr/local/lib/python3.6/dist-packages. Now I can call my program with sudo and it works.
    Alex Grönholm
    @agronholm
    your users will have to know that as well, that is why I didn't suggest that
    mroavi
    @mroavi
    @agronholm Yeah. Your approach does seem better. I have a question, will the users still be prompted to enter the sudo password with your approach?
    mroavi
    @mroavi
    And is this approach cross platform?
    I found this package https://pypi.org/project/elevate/ which claims to elevate user rights.. I might try that one as well..
    And yeah, my application does have command line arguments.. I used Click to implement it. I don't really understand how to fit those in the line of code you showed me.
    I'm gonna try the elevate project. The only thing i'm not sure of is if it is safe.
    Alex Grönholm
    @agronholm
    is the "elevate" package safe you mean?
    mroavi
    @mroavi
    yes.. that's what I mean.
    The question that I still have is, how do some packages get installed by default at system level. For example, if I use pip install evdev it gets installed in /usr/local/lib/python3.6/dist-packages. Is there a way to configure this for example inside setup.py?
    On the other hand, if I use pip install onthefly it gets installed inside my home dir: /home/mroavi/.local/bin/onthefly
    Alex Grönholm
    @agronholm
    pip tries to install it to the global site-packages, and if it finds it doesn't have the permissions, it installs to ~/.local.bin instead
    I dare you to try and uninstall evdev as root and then reinstall it as a normal user
    mroavi
    @mroavi
    you are completely right...
    I'm gonna give the elevate package a try, which seems to be designed exactly for the use-case I'm having now.
    mroavi
    @mroavi
    elevate works great. Hey @agronholm thanks a lot for your time. Really appreciate it.
    Alex Grönholm
    @agronholm
    :ok_hand: