Skip to content

Commit

Permalink
fixing bin to activate virtualenv
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Feb 11, 2015
1 parent 862acfe commit 29b0021
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]

setup(name='uranium',
version='0.0.52',
version='0.0.55',
description='a build system for python',
long_description='a build system for python',
author='Yusuke Tsutsumi',
Expand Down
15 changes: 13 additions & 2 deletions uranium/bin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
BIN_SCRIPT_TEMPLATE = """
import os
#!/usr/bin/env {python_version}
import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this
import os
bin_directory = os.path.dirname(os.path.realpath(__file__))
base = os.path.join(bin_directory, os.pardir)
{extras}
{body}
""".strip()
import os
import stat
import sys


class BinDirectory(object):
""" this wraps a few convenience methods for the bin directory """
Expand All @@ -25,7 +29,8 @@ def install_script(self, name, body, execution_dir="base"):

bin_script = BIN_SCRIPT_TEMPLATE.format(
body=body,
extras=extras
extras=extras,
python_version=self._get_python_version()
)

target_path = os.path.join(self.root, name)
Expand All @@ -35,6 +40,12 @@ def install_script(self, name, body, execution_dir="base"):

_make_executable(target_path)

def _get_python_version(self):
return "python{major}.{minor}".format(
major=sys.version_info[0],
minor=sys.version_info[1]
)


def _make_executable(path):
permission = os.stat(path).st_mode | stat.S_IXUSR | stat.S_IRUSR
Expand Down

0 comments on commit 29b0021

Please sign in to comment.