You are not logged in.

#1 2018-07-15 08:45:56

Truc
Member
Registered: 2014-03-06
Posts: 15

python dependency problem, creating my first package

Hello guys,

I'm trying to create my first package but I'm having some issues.

Here's my PKGBUILD:

# Maintainer: truc <metrucgmail.com>

pkgname=cloudfail-git
pkgver=0.9.3.r102.ge8ad02c
pkgrel=2
pkgdesc="Tactical reconnaissance tool which aims to gather enough information about a target protected by Cloudflare"
arch=('any')
url="https://github.com/m0rtem/CloudFail"
license=('GPL')
depends=('python')
makedepends=('python-pip')
provides=('cloudfail')
source=("cloudfail"::'git+https://github.com/m0rtem/CloudFail.git')
sha512sums=('SKIP')
options=('!strip')



package() {
	# Install files in /opt
	mkdir -p "$pkgdir/opt/cloudfail"
	cp -a $srcdir/cloudfail/. $pkgdir/opt/cloudfail
	pip install -r $pkgdir/opt/cloudfail/requirements.txt --target $pkgdir/opt/cloudfail/lib
	pip install PySocks 

	# Create an indirect launcher in /usr/bin
	mkdir -p "$pkgdir/usr/bin"
	install -Dm 755 "$srcdir/cloudfail/cloudfail.py" "$pkgdir/usr/bin/cloudfail"
}

Everything goes well except when I try to exectute the binary I get a python dependency error. It comes from a module from the package itself (I mean it's not on pip, it comes with the package).

If I go in /opt/ and execute it from there everything will go well because it can resolve the dependency, but the binary in /bin cannot. How can I solve this?

▶ cloudfail
Traceback (most recent call last):
  File "/usr/bin/cloudfail", line 16, in <module>
    from DNSDumpsterAPI import DNSDumpsterAPI
ModuleNotFoundError: No module named 'DNSDumpsterAPI'

Last edited by Truc (2018-07-15 08:46:43)

Offline

#2 2018-07-15 09:16:40

loqs
Member
Registered: 2014-03-06
Posts: 17,327

Re: python dependency problem, creating my first package

/opt/cloudfail/lib is not in the standard python search path so DNSDumpsterAPI is not found.

Offline

#3 2018-07-15 09:25:53

Truc
Member
Registered: 2014-03-06
Posts: 15

Re: python dependency problem, creating my first package

But DNSDumpster is not installed by pip so at the end it won't be found anyway I think right?
I can fix the problem by copying it like this:

package() {
	cd "$srcdir/$pkgname"
	pwd
	pip install -r requirements.txt 
	pip install PySocks 

	# Create an indirect launcher in /usr/bin
	install -Dm 755 "${srcdir}/$pkgname/cloudfail.py" "${pkgdir}/usr/bin/cloudfail"

	#dependency fix
	mkdir -p $pkgdir/usr/lib/python3.6/site-packages
	cp  $srcdir/$pkgname/DNSDumpsterAPI.py $pkgdir/usr/lib/python3.6/site-packages/DNSDumpsterAPI.py

}

Offline

#4 2018-07-15 09:46:42

loqs
Member
Registered: 2014-03-06
Posts: 17,327

Re: python dependency problem, creating my first package

Yes it appears the application is expected to be unpacked into a local directory and executed from that directory rather than system wide install.

Offline

#5 2018-07-15 15:09:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: python dependency problem, creating my first package

Why do you need a virtualenv at all? Why not just depend on the python packages for the dependencies, which are available in the repos?

Then install DNSDumpsterAPI.py and /usr/bin/cloudfail by hand because upstream did not provide a setup.py for you.

But, pip/requirements.txt should definitely not be necessary.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB