diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-04-03 23:08:34 +0100 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-06-15 16:43:42 +0100 |
commit | ad803aeaeb3aa36d615193e627219c813cae16b6 (patch) | |
tree | d89c3599007f3d2f86e45369de9f811a0792c71f /setuptools/command/dist_info.py | |
parent | c6106b7b5eac56f6f84174ede07aa221d5aa635d (diff) | |
download | python-setuptools-git-ad803aeaeb3aa36d615193e627219c813cae16b6.tar.gz |
Change dist_info to better control output directory
Diffstat (limited to 'setuptools/command/dist_info.py')
-rw-r--r-- | setuptools/command/dist_info.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/setuptools/command/dist_info.py b/setuptools/command/dist_info.py index 5e38c96c..b948763d 100644 --- a/setuptools/command/dist_info.py +++ b/setuptools/command/dist_info.py @@ -11,6 +11,7 @@ from inspect import cleandoc from distutils.core import Command from distutils import log from setuptools.extern import packaging +from setuptools._deprecation_warning import SetuptoolsDeprecationWarning class dist_info(Command): @@ -19,29 +20,45 @@ class dist_info(Command): user_options = [ ('egg-base=', 'e', "directory containing .egg-info directories" - " (default: top of the source tree)"), + " (default: top of the source tree)" + " DEPRECATED: use --output-dir."), + ('output-dir=', 'o', "directory inside of which the .dist-info will be" + "created (default: top of the source tree)"), ] def initialize_options(self): self.egg_base = None + self.output_dir = None + self.name = None self.dist_info_dir = None def finalize_options(self): - egg_info = self.get_finalized_command('egg_info') - egg_info.egg_base = self.egg_base + if self.egg_base: + msg = "--egg-base is deprecated for dist_info command. Use --output-dir." + warnings.warn(msg, SetuptoolsDeprecationWarning) + self.output_dir = self.egg_base or self.output_dir + + dist = self.distribution + project_dir = dist.src_root or os.curdir + self.output_dir = self.output_dir or project_dir + + egg_info = self.reinitialize_command('egg_info') + egg_info.egg_base = self.output_dir egg_info.finalize_options() - name = _safe(self.distribution.get_name()) - base = self.egg_base or os.curdir - version = _version(self.distribution.get_version()) - self.dist_info_dir = os.path.join(base, f"{name}-{version}.dist-info") self.egg_info = egg_info - self.egg_base = egg_info.egg_base + + name = _safe(dist.get_name()) + version = _version(dist.get_version()) + self.name = f"{name}-{version}" + self.dist_info_dir = os.path.join(self.output_dir, f"{self.name}.dist-info") def run(self): self.egg_info.run() + egg_info_dir = self.egg_info.egg_info log.info("creating '{}'".format(os.path.abspath(self.dist_info_dir))) bdist_wheel = self.get_finalized_command('bdist_wheel') - bdist_wheel.egg2dist(self.egg_info.egg_info, self.dist_info_dir) + bdist_wheel.egg2dist(egg_info_dir, self.dist_info_dir) + assert os.path.exists(egg_info_dir) is False def _safe(component: str) -> str: |