Skip to content

Commit

Permalink
Prefer alternative from egg_info.py to pkg_resources.Distribution.egg…
Browse files Browse the repository at this point in the history
…_name
  • Loading branch information
abravalheri committed Jan 24, 2023
1 parent ea6df15 commit cbd0cb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
15 changes: 7 additions & 8 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import textwrap
import marshal

from pkg_resources import get_build_platform, Distribution
from setuptools.extension import Library
from setuptools import Command
from .._path import ensure_directory
Expand Down Expand Up @@ -64,7 +63,7 @@ class bdist_egg(Command):
('bdist-dir=', 'b',
"temporary directory for creating the distribution"),
('plat-name=', 'p', "platform name to embed in generated filenames "
"(default: %s)" % get_build_platform()),
"(by default uses `pkg_resources.get_build_platform()`)"),
('exclude-source-files', None,
"remove all .py files from the generated egg"),
('keep-temp', 'k',
Expand Down Expand Up @@ -98,18 +97,18 @@ def finalize_options(self):
self.bdist_dir = os.path.join(bdist_base, 'egg')

if self.plat_name is None:
from pkg_resources import get_build_platform

self.plat_name = get_build_platform()

self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))

if self.egg_output is None:

# Compute filename of the output egg
basename = Distribution(
None, None, ei_cmd.egg_name, ei_cmd.egg_version,
get_python_version(),
self.distribution.has_ext_modules() and self.plat_name
).egg_name()
basename = ei_cmd._get_egg_basename(
py_version=get_python_version(),
platform=self.distribution.has_ext_modules() and self.plat_name,
)

self.egg_output = os.path.join(self.dist_dir, basename + '.egg')

Expand Down
5 changes: 1 addition & 4 deletions setuptools/command/install_egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from setuptools import namespaces
from setuptools.archive_util import unpack_archive
from .._path import ensure_directory
import pkg_resources


class install_egg_info(namespaces.Installer, Command):
Expand All @@ -24,9 +23,7 @@ def finalize_options(self):
self.set_undefined_options('install_lib',
('install_dir', 'install_dir'))
ei_cmd = self.get_finalized_command("egg_info")
basename = pkg_resources.Distribution(
None, None, ei_cmd.egg_name, ei_cmd.egg_version
).egg_name() + '.egg-info'
basename = f"{ei_cmd._get_egg_basename()}.egg-info"
self.source = ei_cmd.egg_info
self.target = os.path.join(self.install_dir, basename)
self.outputs = []
Expand Down
9 changes: 5 additions & 4 deletions setuptools/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pkg_resources import parse_version
from setuptools.extern.packaging.tags import sys_tags
from setuptools.extern.packaging.utils import canonicalize_name
from setuptools.command.egg_info import write_requirements
from setuptools.command.egg_info import write_requirements, _egg_basename
from setuptools.archive_util import _unpack_zipfile_obj


Expand Down Expand Up @@ -89,10 +89,11 @@ def is_compatible(self):
return next((True for t in self.tags() if t in supported_tags), False)

def egg_name(self):
return pkg_resources.Distribution(
project_name=self.project_name, version=self.version,
return _egg_basename(
self.project_name,
self.version,
platform=(None if self.platform == 'any' else get_platform()),
).egg_name() + '.egg'
) + ".egg"

def get_dist_info(self, zf):
# find the correct name of the .dist-info dir in the wheel file
Expand Down

0 comments on commit cbd0cb7

Please sign in to comment.