archrelease: copy trunk to extra-x86_64
[arch-packages.git] / python-setuptools / trunk / PKGBUILD
blobcca6527b8685eac5ca81e3a728c454cff52eae73
1 # Maintainer: Angel Velasquez <angvp@archlinux.org>
2 # Maintainer: Felix Yan <felixonmars@archlinux.org>
3 # Contributor: Eli Schwartz <eschwartz@archlinux.org>
5 pkgname=python-setuptools
6 pkgver=67.7.0
7 _commit=f11f8b16e28ef2e21c1f454d8925b2c512d32d37
8 pkgrel=1
9 epoch=1
10 pkgdesc="Easily download, build, install, upgrade, and uninstall Python packages"
11 arch=('any')
12 license=('PSF')
13 url="https://pypi.org/project/setuptools/"
14 depends=('python-jaraco.text' 'python-more-itertools' 'python-ordered-set' 'python-packaging'
15          'python-platformdirs' 'python-tomli' 'python-validate-pyproject')
16 makedepends=('git' 'python-setuptools')
17 checkdepends=('python-jaraco.envs' 'python-jaraco.path' 'python-pip' 'python-pip-run'
18               'python-pytest-fixture-config' 'python-pytest-virtualenv' 'python-wheel'
19               'python-pytest-enabler' 'python-pytest-mypy' 'python-pytest-timeout' 'python-sphinx'
20               'python-build' 'python-ini2toml' 'python-tomli-w')
21 provides=('python-distribute')
22 replaces=('python-distribute')
23 source=("git+https://github.com/pypa/setuptools.git#commit=$_commit"
24         system-validate-pyproject.patch
25         add-dependency.patch)
26 sha512sums=('SKIP'
27             '390fea2c575a0042054f51d33e629b04a48f832f0a4a2dd07d34e23cdf330c382dba0f54bfb7c8a6a253bb248a4940f2a789672f715e4dc2aeb395fa185cae7a'
28             '9c5d80c753e78bf613572fb789a234984087d0ce96d0bad22b5ed731d83c77bf6d8acfa65c78f6c78f9063be7819c2b58988fdf8e7fc89b55339f94a87b3b21f')
30 export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=0
32 prepare() {
33   cd setuptools
35   patch -p1 -i ../system-validate-pyproject.patch
37   rm -r {pkg_resources,setuptools}/{extern,_vendor} setuptools/config/_validate_pyproject
39   # Upstream devendoring logic is badly broken, see:
40   # https://bugs.archlinux.org/task/58670
41   # https://github.com/pypa/pip/issues/5429
42   # https://github.com/pypa/setuptools/issues/1383
43   # The simplest fix is to simply rewrite import paths to use the canonical
44   # location in the first place
45   for _module in setuptools pkg_resources '' ; do
46       find . -name \*.py -exec sed -i \
47           -e 's/from '$_module.extern' import/import/' \
48           -e 's/from '$_module.extern'\./from /' \
49           -e 's/import '$_module.extern'\./import /' \
50           -e "s/__import__('$_module.extern./__import__('/" \
51           -e 's/from \.\.extern\./from /' \
52           {} +
53   done
55   # Add the devendored dependencies into metadata of setuptools
56   patch -p1 -i ../add-dependency.patch
58   # Fix tests invoking python-build
59   sed -e 's/"-m", "build", "--wheel"/"-m", "build", "--wheel", "--no-isolation"/' \
60       -e 's/"-m", "build", "--sdist"/"-m", "build", "--sdist", "--no-isolation"/' \
61       -i setuptools/tests/fixtures.py
63   # Remove post-release tag since we are using stable tags
64   sed -e '/tag_build = .post/d' \
65       -e '/tag_date = 1/d' \
66       -i setup.cfg
68   # Fix shebang
69   sed -i -e "s|^#\!.*/usr/bin/env python|#!/usr/bin/env python3|" setuptools/command/easy_install.py
72 build() {
73   cd setuptools
74   python setup.py build
77 check() { (
78   # Workaround UTF-8 tests by setting LC_CTYPE
79   export LC_CTYPE=en_US.UTF-8
81   # https://github.com/pypa/setuptools/pull/810
82   export PYTHONDONTWRITEBYTECODE=1
84   cd setuptools
85   # 1,4: subtle difference introduced by devendoring
86   # 2: pip failures related to devendoring, 
87   # 3: TODO
88   PYTHONPATH="$PWD"/build/lib python -m pytest \
89     --deselect setuptools/tests/config/test_apply_pyprojecttoml.py::test_apply_pyproject_equivalent_to_setupcfg \
90     --deselect setuptools/tests/test_virtualenv.py \
91     --deselect setuptools/tests/test_editable_install.py::test_editable_with_prefix \
92     --deselect setuptools/_normalization.py::setuptools._normalization.safe_version
95 package() {
96   cd setuptools
97   python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 --skip-build