From d1f3bb06b8a954fbe2e713dbd55047c8fdc43ba8 Mon Sep 17 00:00:00 2001 From: Corey Hickey Date: Tue, 27 Jul 2021 17:58:23 -0700 Subject: [PATCH] fix inconsistent naming between packages and dependencies This works around: https://github.com/pypa/setuptools/issues/2522 For example, when building a module which depends on 'backports_abc', fpm will currently translate that into a dependency on 'backports-abc'. When building the 'backports_abc' module, fpm will currently retain the original name. Thus, it is not possible to use fpm to meet some dependencies. Underscores should be allowed in package names, but the most important thing is to be internally consistent. If and when pkg_resources fixes safe_name(), then the behavior will automatically change and remain consistent. Note that this change matches both methods ok loading requirements: * for setup.py, setuptools internally calls pkg_resources.safe_name() * for requirements.txt, pkg_resources uses its own safe_name() --- lib/fpm/package/pyfpm/get_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fpm/package/pyfpm/get_metadata.py b/lib/fpm/package/pyfpm/get_metadata.py index 89a803a502..c333d7752b 100644 --- a/lib/fpm/package/pyfpm/get_metadata.py +++ b/lib/fpm/package/pyfpm/get_metadata.py @@ -68,7 +68,7 @@ def process_dep(self, dep): def run(self): data = { - "name": self.distribution.get_name(), + "name": pkg_resources.safe_name(self.distribution.get_name()), "version": self.distribution.get_version(), "author": u("%s <%s>") % ( u(self.distribution.get_author()),