Python pacakge `python3-pygtrie` compile error: option --single-version-externally-managed not recognized

I created a Makefile for python3-pygtrie:

python3-pygtrie Makefiile
include $(TOPDIR)/rules.mk

PKG_NAME:=pygtrie
PKG_VERSION:=2.4.2
PKG_RELEASE:=1

PYPI_NAME:=$(PKG_NAME)
PKG_HASH:=43205559d28863358dbbf25045029f58e2ab357317a59b11f11ade278ac64692

PKG_MAINTAINER:=mina86
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE

include $(TOPDIR)/feeds/packages/lang/python/pypi.mk
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk

define Package/python3-$(PKG_NAME)
  SECTION:=lang
  CATEGORY:=Languages
  SUBMENU:=Python
  TITLE:=python3-$(PKG_NAME)
  URL:=https://github.com/mina86/pygtrie
  DEPENDS:=+python3 +python3-pip
endef

define Package/python3-$(PKG_NAME)/description
pygtrie is a pure Python implementation of a trie data structure compatible
with Python 2.x and Python 3.x.
endef

$(eval $(call Py3Package,python3-$(PKG_NAME)))
$(eval $(call BuildPackage,python3-$(PKG_NAME)))
$(eval $(call BuildPackage,python3-$(PKG_NAME)-src))

But I get error error: option --single-version-externally-managed not recognized, here are the full logs:

Full logs
cd "/tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2/" && CC="ccache_cc" CCSHARED="ccache_cc -DPIC -fpic" CXX="ccache_cxx" LD="ccache_cc" LDSHARED="ccache_cc -shared" CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2=pygtrie-2.4.2 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" CPPFLAGS="-I/tmp/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/include -I/tmp/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include/fortify -I/tmp/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include -I/tmp/openwrt/staging_dir/target-x86_64_musl/usr/include/python3.10" LDFLAGS="-L/tmp/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/lib -L/tmp/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/lib -znow -zrelro -lpython3.10" _PYTHON_HOST_PLATFORM="linux-x86_64" __PYVENV_LAUNCHER__="/usr/bin/python3.10" PYTHONPATH="/tmp/openwrt/staging_dir/target-x86_64_musl/usr/lib/python3.10:/tmp/openwrt/staging_dir/target-x86_64_musl//usr/lib/python3.10/site-packages:/tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2/ipkg-install//usr/lib/python3.10/site-packages" PYTHONDONTWRITEBYTECODE=1 PYTHONOPTIMIZE="" _python_sysroot="/tmp/openwrt/staging_dir/target-x86_64_musl" _python_prefix="/usr" _python_exec_prefix="/usr"     /tmp/openwrt/staging_dir/hostpkg/bin/python3.10  setup.py   install --prefix="/usr" --root="/tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2/ipkg-install" --single-version-externally-managed
/tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2/setup.py:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils.command.build_py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --single-version-externally-managed not recognized
make[2]: *** [Makefile:45: /tmp/openwrt/build_dir/target-x86_64_musl/pypi/pygtrie-2.4.2/.built] Error 1
make[2]: Leaving directory '/home/a/openwrt/package/little-paimon/python3-pygtrie'
time: package/little-paimon/python3-pygtrie/compile#1.08#0.04#1.10
    ERROR: package/little-paimon/python3-pygtrie failed to build.
make[1]: *** [package/Makefile:116: package/little-paimon/python3-pygtrie/compile] Error 1
make[1]: Leaving directory '/home/a/openwrt'
make: *** [/home/a/openwrt/include/toplevel.mk:230: package/python3-pygtrie/compile] Error 2

Then I tried adding python3-wheel as a dependency of python3-pygtrie:

python3-wheel Makefiile
include $(TOPDIR)/rules.mk

PKG_NAME:=wheel
PKG_VERSION:=0.37.1
PKG_RELEASE:=1

PYPI_NAME:=$(PKG_NAME)
PKG_HASH:=e9a504e793efbca1b8e0e9cb979a249cf4a0a7b5b8c9e8b65a5e39d49529c1c4

PKG_MAINTAINER:=pypa
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE

include $(TOPDIR)/feeds/packages/lang/python/pypi.mk
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk

define Package/python3-$(PKG_NAME)
  SECTION:=lang
  CATEGORY:=Languages
  SUBMENU:=Python
  TITLE:=python3-$(PKG_NAME)
  URL:=https://github.com/pypa/wheel
  DEPENDS:=+python3
endef

define Package/python3-$(PKG_NAME)/description
This library is the reference implementation of the Python wheel packaging
standard, as defined in PEP 427.
endef

$(eval $(call Py3Package,python3-$(PKG_NAME)))
$(eval $(call BuildPackage,python3-$(PKG_NAME)))
$(eval $(call BuildPackage,python3-$(PKG_NAME)-src))

But the error still happend.

Could you please help me with this problem? Thanks a lot!

The setup.py of pygtrie uses distutils for setup, which is the reason for the error. So I add a patches to replace distutils with setuptools:

--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,6 @@
 import codecs
 import distutils.command.build_py
 import distutils.command.sdist
-import distutils.core
 import os
 import os.path
 import re
@@ -11,6 +10,8 @@ import sys
 import stat
 import tempfile

+from setuptools import setup
+
 import version


@@ -176,4 +177,4 @@ kwargs = {
 if re.search(r'(?:\d+\.)*\d+', release):
     kwargs['download_url'] = kwargs['url'] + '/tarball/v' + release

-distutils.core.setup(**kwargs)
+setup(**kwargs)
2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.