[Python] installation module (résolu)

Questions et astuces concernant l'installation et la configuration d'archlinux
Avatar de l’utilisateur
lesebas
Chu Ko Nu
Messages : 330
Inscription : ven. 01 févr. 2013, 19:16

[Python] installation module (résolu)

Message par lesebas »

Bonjour,

J'ai un paquet AUR qui installe le module python hurry.filesize. Depuis quelques jours le module ne s'installe plus.

A l'origine j'utilisais python setup.py install :

Code : Tout sélectionner

[sebastien@Aquilam hurry.filesize-0.9]$ sudo python setup.py install --root="python-hurry-filesize/" --optimize=1
running install
/usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running build
running build_py
running egg_info
writing src/hurry.filesize.egg-info/PKG-INFO
writing dependency_links to src/hurry.filesize.egg-info/dependency_links.txt
writing namespace_packages to src/hurry.filesize.egg-info/namespace_packages.txt
writing requirements to src/hurry.filesize.egg-info/requires.txt
writing top-level names to src/hurry.filesize.egg-info/top_level.txt
reading manifest file 'src/hurry.filesize.egg-info/SOURCES.txt'
writing manifest file 'src/hurry.filesize.egg-info/SOURCES.txt'
running install_lib
Skipping installation of python-hurry-filesize/usr/lib/python3.10/site-packages/hurry/__init__.py (namespace package)
copying hurry/filesize/__init__.py -> python-hurry-filesize/usr/lib/python3.10/site-packages/hurry/filesize
copying hurry/filesize/tests.py -> python-hurry-filesize/usr/lib/python3.10/site-packages/hurry/filesize
copying hurry/filesize/filesize.py -> python-hurry-filesize/usr/lib/python3.10/site-packages/hurry/filesize
copying hurry/filesize/README.txt -> python-hurry-filesize/usr/lib/python3.10/site-packages/hurry/filesize
writing byte-compilation script '/tmp/tmpar5pk4ta.py'
/usr/bin/python -Wignore:The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives:DeprecationWarning /tmp/tmpar5pk4ta.py
removing /tmp/tmpar5pk4ta.py
running install_egg_info
removing 'python-hurry-filesize/usr/lib/python3.10/site-packages/hurry.filesize-0.9-py3.10.egg-info' (and everything under it)
Copying src/hurry.filesize.egg-info to python-hurry-filesize/usr/lib/python3.10/site-packages/hurry.filesize-0.9-py3.10.egg-info
Installing python-hurry-filesize/usr/lib/python3.10/site-packages/hurry.filesize-0.9-py3.10-nspkg.pth
running install_scripts
[sebastien@Aquilam hurry.filesize-0.9]$ 
Mais les fichiers ne sont pas copiés dans /usr/lib/python3.10/site-packages/. Comme il est indiqué que setuptools est déprécié, j'ai installé python-pip et python-wheel :

Code : Tout sélectionner

[sebastien@Aquilam hurry.filesize-0.9]$ sudo python3.10 -m pip install . --root="python-hurry-filesize/" --upgrade
Processing /home/Donnees/sebastien/Téléchargements/hurry.filesize-0.9
Requirement already satisfied: setuptools in /usr/lib/python3.10/site-packages (from hurry.filesize==0.9) (59.1.1)
Building wheels for collected packages: hurry.filesize
  Building wheel for hurry.filesize (setup.py) ... done
  Created wheel for hurry.filesize: filename=hurry.filesize-0.9-py3-none-any.whl size=4136 sha256=7738eb343f1898586291d1940afca2c0ceb7906881206c78cb8cc50e09397917
  Stored in directory: /root/.cache/pip/wheels/0a/3c/e1/486b0d914a0cde6671b7bb499002d43dfec49ea97c504a20f9
Successfully built hurry.filesize
Installing collected packages: hurry.filesize
Successfully installed hurry.filesize-0.9
Tout semble bien se passer, pour autant les fichiers ne sont pas copiés et le module pas disponible pour python. Si je copie les fichiers manuellement ça marche :

Code : Tout sélectionner

[sebastien@Aquilam hurry.filesize-0.9]$ sudo cp -r python-hurry-filesize/usr/lib/python3.10/site-packages/. /usr/lib/python3.10/site-packages/
[sebastien@Aquilam hurry.filesize-0.9]$ 
Quelqu'un a-t-il une idée?
Dernière modification par lesebas le mer. 02 févr. 2022, 21:55, modifié 3 fois.
Seb

Archlinux sur AMD64 (xfce / lightdm)
Avatar de l’utilisateur
lesebas
Chu Ko Nu
Messages : 330
Inscription : ven. 01 févr. 2013, 19:16

Re: [Python] installation module

Message par lesebas »

Ok résolu il suffit d'installer le paquet directement depuis l'archive sans la décompresser (RTFM :D ) :

Code : Tout sélectionner

[sebastien@Aquilam ~]$ sudo python -m pip install ./Downloads/hurry.filesize-0.9.tar.gz 
Processing ./Downloads/hurry.filesize-0.9.tar.gz
Requirement already satisfied: setuptools in /usr/lib/python3.10/site-packages (from hurry.filesize==0.9) (59.1.1)
Building wheels for collected packages: hurry.filesize
  Building wheel for hurry.filesize (setup.py) ... done
  Created wheel for hurry.filesize: filename=hurry.filesize-0.9-py3-none-any.whl size=4136 sha256=223984550b997aae671e96cf6ba2dea58f9ec3773cce5aeef864c018a88a07b5
  Stored in directory: /root/.cache/pip/wheels/b6/02/1c/023e1171a74eaec5ea7dbf35ba9773cab2e72654c8500947bb
Successfully built hurry.filesize
Installing collected packages: hurry.filesize
Successfully installed hurry.filesize-0.9
[sebastien@Aquilam ~]$ 
Seb

Archlinux sur AMD64 (xfce / lightdm)
Avatar de l’utilisateur
lesebas
Chu Ko Nu
Messages : 330
Inscription : ven. 01 févr. 2013, 19:16

Re: [Python] installation module

Message par lesebas »

Je rouvre ce post car ce n'est qu'a moitié résolu. En effet l'installation se passe bien avec pip. Néanmoins quand je lance la commande avec makepkg il semble que l'installation la commande pip ne copie rien dans le sous dossier ./pkg/hurry.filesize du coup ça install un paquet vide. J'ai bien trouvé la solution de lancer la commande en post install mais c'est un peu bourrin.

Mon pkgbuild :

Code : Tout sélectionner

# Maintainer: lesebas <sebastiendotdelignyatgmail.com>

pkgname=hurry.filesize
pkgver=0.9
pkgrel=5
pkgdesc="A simple Python library for human readable file sizes (or anything sized in bytes)."
arch=('any')
url="http://pypi.python.org/pypi/hurry.filesize/"
license=('GPL')
depends=('python')
makedepends=('python-pip' 'python-wheel')
install=python-hurry-filesize.install
source=("https://files.pythonhosted.org/packages/ee/5e/16e17bedcf54d5b618dc0771690deda77178e5c310402881c3d2d6c5f27c/$pkgname-$pkgver.tar.gz")
md5sums=('8549ccd09bb31b5ff1e8e8c1eacc7794')

package() {
  python -m pip install ./$pkgname-$pkgver.tar.gz
}
et python-hurry-filesize.install :

Code : Tout sélectionner

post_upgrade() {
 python -m pip install ./hurry.filesize-0.9.tar.gz
}

post_remove() {
 python -m pip uninstall hurry.filesize
}

post_install() {
  python -m pip install ./hurry.filesize-0.9.tar.gz
}
C'est comme-ci pip ne tenais pas compte de l’environnement fakeroot
Seb

Archlinux sur AMD64 (xfce / lightdm)
Avatar de l’utilisateur
benjarobin
Maître du Kyudo
Messages : 17187
Inscription : sam. 30 mai 2009, 15:48
Localisation : Lyon

Re: [Python] installation module

Message par benjarobin »

As tu regardé comment les paquets python étaient créés sur les dépôts officiel ? Car ce n'est pas du tout comme cela que c'est réalisé
Zsh | KDE | PC fixe : core i7, carte nvidia
Titre d'un sujet : [Thème] Sujet (état) / Règles du forum
Avatar de l’utilisateur
lesebas
Chu Ko Nu
Messages : 330
Inscription : ven. 01 févr. 2013, 19:16

Re: [Python] installation module

Message par lesebas »

Sur le site officiel : https://pypi.org/project/hurry.filesize/ il est recommandé d'utiliser

Code : Tout sélectionner

pip install hurry.filesize
.

Néanmoins la doc archlinux déconseille l'utilisation de pip. Mais il ya des indications pour le faire, je vais creuser :

https://wiki.archlinux.org/title/Python ... elines#pip
Seb

Archlinux sur AMD64 (xfce / lightdm)
Avatar de l’utilisateur
lesebas
Chu Ko Nu
Messages : 330
Inscription : ven. 01 févr. 2013, 19:16

Re: [Python] installation module

Message par lesebas »

Ok en suivant les guideline du wiki sur les modules python ça marche !

Code : Tout sélectionner

pkgname=python-hurry-filesize
pkgver=0.9
pkgrel=6
pkgdesc="A simple Python library for human readable file sizes (or anything sized in bytes)."
arch=('any')
url="http://pypi.python.org/pypi/hurry.filesize/"
license=('GPL')
depends=('python')
makedepends=('python-pip' 'python-wheel')
source=()

package() {
  PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-deps hurry.filesize
}
Seb

Archlinux sur AMD64 (xfce / lightdm)
Répondre