forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPKGBUILD.setup-py-python-pkg
More file actions
103 lines (92 loc) · 3.47 KB
/
Copy pathPKGBUILD.setup-py-python-pkg
File metadata and controls
103 lines (92 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Maintainer: Some One <some.one@some.email.com>
#This value is here because some python package names have capital letters
#while there is a strong preference for lowercase letters in ArchLinux and
#MSYS packages.
_realname=somepackage
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.0.0
pkgrel=1
pkgdesc="Some package (mingw-w64)"
arch=('any')
url='https://www.somepackage.org/'
license=('LICENSE')
validpgpkeys=('gpg_KEY')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
"${MINGW_PACKAGE_PREFIX}-python-setuptools")
install=${_realname}-${CARCH}.install
options=('staticlibs' 'strip' '!debug')
#Ideally, you should download the sources from github or some other place besides
#pypi, but that ideal is not always possible.
_dtoken='aa/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
#Some Python packages software might use this instead
#source=("https://pypi.python.org/packages/source/[first letter of the packages]/${_realname}/${_realname}-${pkgver}.tar.gz")
@_dtoken would be the part of the URL between the /package and filename.
# I did this to make it so you could just update the token to a new version instead of the complete
# download URL.
source=("https://pypi.python.org/packages/${_dtoken}/${_realname}-${pkgver}.tar.gz"
"0001-An-important-fix.patch"
"0002-A-less-important-fix.patch")
sha256sums=('SKIP'
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _patch in "$@"
do
msg2 "Applying $_patch"
patch -Nbp1 -i "${srcdir}/$_patch"
done
}
del_file_exists() {
for _fname in "$@"
do
if [ -f $_fname ]; then
rm -rf $_fname
fi
done
}
# =========================================== #
prepare() {
cd "${srcdir}"
pushd "${_realname}-${pkgver}"
apply_patch_with_msg 0001-A-really-important-fix.patch \
0002-A-less-important-fix.patch
popd
rm -rf python-build-${CARCH} | true
cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
# Set version for setuptools_scm
export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}
# Note that build() is sometimes skipped because it's done in
# the packages setup.py install for simplicity if you can do so.
# but sometimes, you want to do a check before install which would
# also trigger the build.
build() {
msg "Python build for ${CARCH}"
cd "${srcdir}/python-build-${CARCH}"
${MINGW_PREFIX}/bin/python setup.py build
}
check() {
msg "Python test for ${CARCH}"
cd "${srcdir}/python-build-${CARCH}"
${MINGW_PREFIX}/bin/python setup.py check
}
package() {
cd "${srcdir}/python-build-${CARCH}"
MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
--root="${pkgdir}" --optimize=1 --skip-build
install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
# This entire section should be removed if the package does NOT install
# anything in the /mingw*/bin directory.
### begin section ###
local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})
# fix python command in files
for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
sed -e "s|/usr/bin/env |${MINGW_PREFIX}|g" \
-e "s|${PREFIX_WIN}|${MINGW_PREFIX}|g" -i ${_f}
done
#### end section ####
}