diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-25 20:03:39 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-25 20:03:39 -0400 | 
| commit | 574634487927a156d9f245bb9eab6c3b00af65ed (patch) | |
| tree | 525eaeb0ca9c446c0ea53219dd575fb76130c195 | |
| parent | 6125fb6e1fe114440e28e6fb68f7561257d1ce05 (diff) | |
| download | cbc-574634487927a156d9f245bb9eab6c3b00af65ed.tar.gz | |
* Track initial working directory
* Assign script locations AFTER generating a viable place to put them.
| -rw-r--r-- | cbc/environment.py | 20 | 
1 files changed, 18 insertions, 2 deletions
| diff --git a/cbc/environment.py b/cbc/environment.py index cd1389b..7bc427c 100644 --- a/cbc/environment.py +++ b/cbc/environment.py @@ -9,6 +9,8 @@ class Environment(object):          self.environ = os.environ.copy()
          self.config = {}
          self.cbchome = None
 +        self.pwd = os.path.abspath(os.curdir)
 +        self.pkgdir = None
          if 'CBC_HOME' in kwargs:
              self.cbchome = kwargs['CBC_HOME']
 @@ -21,17 +23,31 @@ class Environment(object):          if self.cbchome is None:
              raise IncompleteEnv('Environment.cbchome is undefined')
 +        
 +        self.cbchome = os.path.abspath(self.cbchome)
          if not os.path.exists(self.cbchome):
              os.makedirs(self.cbchome)
 +    def _script_meta(self):
          self.config['script'] = {}
          self.config['script']['meta'] = self.join('meta.yaml')
          self.config['script']['build_linux'] = self.join('build.sh')
          self.config['script']['build_windows'] = self.join('bld.bat')
 -    def join(self, path):
 -        return os.path.join(self.cbchome, path)
 +    def join(self, filename):
 +        return os.path.abspath(os.path.join(self.pkgdir, filename))
 +    def mkpkgdir(self, pkgname):
 +        pkgdir = os.path.join(self.cbchome, pkgname)
 +        
 +        if not pkgname:
 +            raise IncompleteEnv('Empty package name passed to {0}'.format(__name__))
 +        if not os.path.exists(pkgdir):
 +            os.mkdir(pkgdir)
 +            
 +        self.pkgdir = pkgdir
 +        self._script_meta()
 +        
      '''
      def local_temp(self):
          temp_prefix = os.path.basename(os.path.splitext(__name__)[0])
 | 
