Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20283e5

Browse files
committed
Added --plat-name option to override sysconfig.get_platform() in
generated filenames.
1 parent 14deaae commit 20283e5

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lib/distutils/command/bdist.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class bdist (Command):
3232

3333
user_options = [('bdist-base=', 'b',
3434
"temporary directory for creating built distributions"),
35+
('plat-name=', 'p',
36+
"platform name to embed in generated filenames "
37+
"(default: %s)" % get_platform()),
3538
('formats=', None,
3639
"formats for distribution (comma-separated list)"),
3740
('dist-dir=', 'd',
@@ -70,20 +73,24 @@ class bdist (Command):
7073

7174
def initialize_options (self):
7275
self.bdist_base = None
76+
self.plat_name = None
7377
self.formats = None
7478
self.dist_dir = None
7579

7680
# initialize_options()
7781

7882

7983
def finalize_options (self):
84+
# have to finalize 'plat_name' before 'bdist_base'
85+
if self.plat_name is None:
86+
self.plat_name = get_platform()
87+
8088
# 'bdist_base' -- parent of per-built-distribution-format
8189
# temporary directories (eg. we'll probably have
8290
# "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
8391
if self.bdist_base is None:
8492
build_base = self.get_finalized_command('build').build_base
85-
plat = get_platform()
86-
self.bdist_base = os.path.join (build_base, 'bdist.' + plat)
93+
self.bdist_base = os.path.join(build_base, 'bdist.' + self.plat_name)
8794

8895
self.ensure_string_list('formats')
8996
if self.formats is None:

Lib/distutils/command/bdist_dumb.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class bdist_dumb (Command):
2020

2121
user_options = [('bdist-dir=', 'd',
2222
"temporary directory for creating the distribution"),
23+
('plat-name=', 'p',
24+
"platform name to embed in generated filenames "
25+
"(default: %s)" % get_platform()),
2326
('format=', 'f',
2427
"archive format to create (tar, ztar, gztar, zip)"),
2528
('keep-tree', 'k',
@@ -35,6 +38,7 @@ class bdist_dumb (Command):
3538

3639
def initialize_options (self):
3740
self.bdist_dir = None
41+
self.plat_name = None
3842
self.format = None
3943
self.keep_tree = 0
4044
self.dist_dir = None
@@ -43,6 +47,7 @@ def initialize_options (self):
4347

4448

4549
def finalize_options (self):
50+
4651
if self.bdist_dir is None:
4752
bdist_base = self.get_finalized_command('bdist').bdist_base
4853
self.bdist_dir = os.path.join(bdist_base, 'dumb')
@@ -55,7 +60,9 @@ def finalize_options (self):
5560
("don't know how to create dumb built distributions " +
5661
"on platform %s") % os.name
5762

58-
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
63+
self.set_undefined_options('bdist',
64+
('dist_dir', 'dist_dir'),
65+
('plat_name', 'plat_name'))
5966

6067
# finalize_options()
6168

@@ -74,7 +81,7 @@ def run (self):
7481
# And make an archive relative to the root of the
7582
# pseudo-installation tree.
7683
archive_basename = "%s.%s" % (self.distribution.get_fullname(),
77-
get_platform())
84+
self.plat_name)
7885
print "self.bdist_dir = %s" % self.bdist_dir
7986
print "self.format = %s" % self.format
8087
self.make_archive (os.path.join(self.dist_dir, archive_basename),

0 commit comments

Comments
 (0)