Skip to content

Commit

Permalink
bdist_pex: Nicer output filename
Browse files Browse the repository at this point in the history
1. Include version number in output filename, like `sdist` and
`bdist_wheel` do.

2. Output the actual filename that we are writing to, including the
`bdist_dir`.

Instead of this:

    $ python setup.py bdist_pex --pex-args="--index-url=http:/myindex"
    running bdist_pex
    Writing environment pex into dummysvc.pex

we get this:

    $ python setup.py bdist_pex --pex-args="--index-url=http://myindex"
    running bdist_pex
    Writing environment pex into /Users/marca/dev/surveymonkey/DummySvc/dist/dummysvc-0.0.4.dev53.pex
  • Loading branch information
msabramo authored and wickman committed Aug 13, 2015
1 parent a53fb0f commit 7bd3e3d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pex/commands/bdist_pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ def initialize_options(self):
def finalize_options(self):
self.pex_args = self.pex_args.split()

def _write(self, pex_builder, name, script=None):
def _write(self, pex_builder, target, script=None):
builder = pex_builder.clone()

if script is not None:
builder.set_script(script)

target = os.path.join(self.bdist_dir, name + '.pex')

builder.build(target)

def run(self):
name = self.distribution.get_name()
version = self.distribution.get_version()
parser, options_builder = configure_clp()
package_dir = os.path.dirname(os.path.realpath(os.path.expanduser(self.distribution.script_name)))

Expand All @@ -58,13 +57,15 @@ def run(self):
if self.bdist_all:
for entry_point in self.distribution.entry_points['console_scripts']:
script_name = entry_point.split('=')[0].strip()
log.info('Writing %s to %s.pex' % (script_name, script_name))
self._write(pex_builder, script_name, script=script_name)
target = os.path.join(self.bdist_dir, script_name + '.pex')
log.info('Writing %s to %s' % (script_name, target))
self._write(pex_builder, target, script=script_name)
else:
target = os.path.join(self.bdist_dir, name + '-' + version + '.pex')
if len(self.distribution.entry_points.get('console_scripts', [])) == 1:
script_name = self.distribution.entry_points['console_scripts'][0].split('=')[0].strip()
log.info('Writing %s to %s.pex' % (script_name, name))
self._write(pex_builder, name, script=script_name)
log.info('Writing %s to %s' % (script_name, target))
self._write(pex_builder, target, script=script_name)
else:
log.info('Writing environment pex into %s.pex' % name)
self._write(pex_builder, name, script=None)
log.info('Writing environment pex into %s' % target)
self._write(pex_builder, target, script=None)

0 comments on commit 7bd3e3d

Please sign in to comment.