Hi, First of all, sorry if this is a really stupid question, but I've been trying to search for a while and I couldn't find an answer. Is the python module 'cmake' provided in some package in Arch? I mean, I know that there is the cmake package in [extra] but there is no python-cmake, and when I try 'import cmake' of course the module is not found. This works if I install cmake with pip: $ python -m env test $ source test/bin/activate $ (test) pip install cmake $ (test) python $>>> import cmake Thanks, Iyán
El jueves, 28 de noviembre de 2019 17:26:28 (CET) usted escribió:
In such cases I just use pip to install package at system level (without venv). If something gets packaged later I just do pip uninstall and install arch package instead.
Regards, Łukasz
If you do that, pip will overwrite /usr/bin/cmake, right? Besides, I don't want just to install it in my system, but write a PKGBUILD and probably share it in AUR. Thanks, Iyán
For those who don't know, command $ sudo pip install <pypi_package_name> opens DOOM's gate. [ https://open.spotify.com/track/2UKgx2oba7CltHLACr3xdT?si=1XKkDJXZTDK2N-M-W-8... ] It's not a good idea to do that if you don't want to destroy your package integrity. On Thu, Nov 28, 2019 at 1:32 PM Iyán Méndez Veiga <me@iyanmv.com> wrote:
El jueves, 28 de noviembre de 2019 17:26:28 (CET) usted escribió:
In such cases I just use pip to install package at system level (without venv). If something gets packaged later I just do pip uninstall and install arch package instead.
Regards, Łukasz
If you do that, pip will overwrite /usr/bin/cmake, right? Besides, I don't want just to install it in my system, but write a PKGBUILD and probably share it in AUR.
Thanks, Iyán
Though in this case OP is in a venv, so that's fine, it's only at the system level where it's a bad idea. Having said that, I do use pip outside of venvs a little bit, it can be done somewhat safely, but you have to know what you're doing, such as installing everything to /usr/local so it doesn't collide with pacman-managed files and can be just deleted if you run into any issues: $ cat /usr/lib/python3.8/site-packages/sitecustomize.py import site from sys import version_info as v # Add /usr/local/lib/pythonx.y/site-packages as a site dir: site.addsitedir('/usr/local/lib/python{}.{}/site-packages'.format(v.major, v.minor)) $ sudo cat /root/.config/pip/pip.conf [install] install-option=--prefix=/usr/local Main remaining issue is that unmet dependencies pulled in by pip might be unnecessary if they are available in the Arch repos or AUR - though since /usr/local/lib/pythonx.y/site-packages is added at the end of sys.path, those packages won't shadow /usr/lib/pythonx.y/site-packages - they will just be redundant and at worst break the pip-installed packages who expected a different version and get the pacman-managed one instead. -Chris On Thu, Nov 28, 2019 at 1:50 PM Dmitry Yershov via arch-general < arch-general@archlinux.org> wrote:
For those who don't know, command $ sudo pip install <pypi_package_name> opens DOOM's gate. [
https://open.spotify.com/track/2UKgx2oba7CltHLACr3xdT?si=1XKkDJXZTDK2N-M-W-8... ]
It's not a good idea to do that if you don't want to destroy your package integrity.
On Thu, Nov 28, 2019 at 1:32 PM Iyán Méndez Veiga <me@iyanmv.com> wrote:
El jueves, 28 de noviembre de 2019 17:26:28 (CET) usted escribió:
In such cases I just use pip to install package at system level (without venv). If something gets packaged later I just do pip uninstall and install arch package instead.
Regards, Łukasz
If you do that, pip will overwrite /usr/bin/cmake, right? Besides, I don't want just to install it in my system, but write a PKGBUILD and probably share it in AUR.
Thanks, Iyán
Another option is use `pip install --user`, in which case the packages are installed in `{$HOME}/.local/`. You need to set various environment paths. On Thu, Nov 28, 2019 at 2:02 PM Chris Billington <chrisjbillington@gmail.com> wrote:
Though in this case OP is in a venv, so that's fine, it's only at the system level where it's a bad idea.
Having said that, I do use pip outside of venvs a little bit, it can be done somewhat safely, but you have to know what you're doing, such as installing everything to /usr/local so it doesn't collide with pacman-managed files and can be just deleted if you run into any issues:
$ cat /usr/lib/python3.8/site-packages/sitecustomize.py import site from sys import version_info as v # Add /usr/local/lib/pythonx.y/site-packages as a site dir: site.addsitedir('/usr/local/lib/python{}.{}/site-packages'.format(v.major, v.minor))
$ sudo cat /root/.config/pip/pip.conf [install] install-option=--prefix=/usr/local
Main remaining issue is that unmet dependencies pulled in by pip might be unnecessary if they are available in the Arch repos or AUR - though since /usr/local/lib/pythonx.y/site-packages is added at the end of sys.path, those packages won't shadow /usr/lib/pythonx.y/site-packages - they will just be redundant and at worst break the pip-installed packages who expected a different version and get the pacman-managed one instead.
-Chris
On Thu, Nov 28, 2019 at 1:50 PM Dmitry Yershov via arch-general < arch-general@archlinux.org> wrote:
For those who don't know, command $ sudo pip install <pypi_package_name> opens DOOM's gate. [
https://open.spotify.com/track/2UKgx2oba7CltHLACr3xdT?si=1XKkDJXZTDK2N-M-W-8... ]
It's not a good idea to do that if you don't want to destroy your package integrity.
On Thu, Nov 28, 2019 at 1:32 PM Iyán Méndez Veiga <me@iyanmv.com> wrote:
El jueves, 28 de noviembre de 2019 17:26:28 (CET) usted escribió:
In such cases I just use pip to install package at system level (without venv). If something gets packaged later I just do pip uninstall and install arch package instead.
Regards, Łukasz
If you do that, pip will overwrite /usr/bin/cmake, right? Besides, I don't want just to install it in my system, but write a PKGBUILD and probably share it in AUR.
Thanks, Iyán
Thanks for all the answers. So, yes, it is clear that installing cmake with pip is a bad idea. By the way, I only use pip in virtualenvs and install packages for the whole system with pacman or from PKGBUILDs from AUR. But let me explain a little bit more the origin of this question, because maybe you can also find the problem faster than me. I was trying to find an issue trying to compile python-scikit-build. Note in that the current PKGBUILD in AUR fails because there are some missing python2 packages that were removed from official repos. But in the comments, @bnavigator left a fixed PKGBUILD. I leave the link here: https://build.opensuse.org/package/show/home:bnavigator:archlinux/python-sci... Note also that he included a patch from upstream to modify platform.linux_distribution() (which was removed in python 3.8) to distro.id(). However, when trying to build this package we both get the same error: TypeError: dist must be a Distribution instance This is solved, however, when using cmake from pip in a virtualenv. So maybe this is some issue related to python-setuptools, cmake (or other package) from official repos? Again, thanks for all the answers. Best wishes, Iyán
On November 28, 2019 9:31:19 AM EST, "Iyán Méndez Veiga" <me@iyanmv.com> wrote:
Hi,
First of all, sorry if this is a really stupid question, but I've been trying to search for a while and I couldn't find an answer.
It's a confusing question, because it is a confusing module. :) I'll try to clarify your confusion below.
Is the python module 'cmake' provided in some package in Arch? I mean, I know that there is the cmake package in [extra] but there is no python-cmake, and when I try 'import cmake' of course the module is not found.
This works if I install cmake with pip:
$ python -m env test $ source test/bin/activate $ (test) pip install cmake $ (test) python $>>> import cmake
Thanks, Iyán
What you installed is a bundled, prebuilt copy of cmake stuffed into $venv/lib/python3.8/site-packages/cmake/data/ This data directory contains the same hierarchy of bin/ lib/ and share/ that pacman -S cmake would install to /usr instead. There is also a $venv/lib/python3.8/site-packages/cmake/__init__.py which contains a single set of functions, cmake() cpack() and ctest(), which search for the hidden binaries in $venv/lib/python3.8/site-packages/cmake/data/bin/ and execute them using subprocess.call() You're not supposed to use these functions at all. They only exist so that pip can install a setuptools entry point, which allows you to source $venv/bin/activate and then be able to run `cmake` in a command prompt, which will run $venv/bin/cmake, which imports python, uses it to find the hidden data directory, and finally executes the cmake binary. You cannot even additionally use the module as a shortcut to subprocess.call within your own python-based project, since it hardcodes sys.argv[1:] as the arguments to pass to cmake. The PyPI package "cmake" is *not* meant to be used in python scripts, and its only purpose is to very inefficiently abuse PyPI as a distribution mechanism that is easier to use than flatpak or snapd, because people are more likely to have pip installed than either of those, and because their Linux distro is probably named "Ubuntu" so they cannot otherwise easily get a modern version of cmake. Similar modules exist in the NodeJS ecosystem that abuse npmjs.org to install nom modules that contain no JavaScript, but do contain a bash script. Because downloading bash scripts into $HOME/bin/ is hard, but npm install mycoolscript is "easy". tl;dr Wherever you saw the advice to pip install cmake was probably misinformed. This does not provide python bindings to cmake. -- Eli Schwartz Bug Wrangler and Trusted User
El jueves, 28 de noviembre de 2019 18:39:01 (CET) Eli Schwartz via arch- general escribió:
Wherever you saw the advice to pip install cmake was probably misinformed. This does not provide python bindings to cmake.
So do you know how could I avoid pip from downloading cmake when using python setup.py build in a PKGBUILD? Or do you know any example of a official package in Arch that handle this correctly?
El viernes, 29 de noviembre de 2019 10:24:50 (CET) Iyán Méndez Veiga escribió:
El jueves, 28 de noviembre de 2019 18:39:01 (CET) Eli Schwartz via arch-
general escribió:
Wherever you saw the advice to pip install cmake was probably misinformed. This does not provide python bindings to cmake.
So do you know how could I avoid pip from downloading cmake when using python setup.py build in a PKGBUILD? Or do you know any example of a official package in Arch that handle this correctly?
Ok, so apparently just by removing cmake from the setup_requires list in the setup.py does the trick. If anyone knows a better solution, please let me know. For the moment I will add a sed to remove that mention to cmake in prepare(). Thanks, Iyán
participants (4)
-
Chris Billington
-
Dmitry Yershov
-
Eli Schwartz
-
Iyán Méndez Veiga