From 574634487927a156d9f245bb9eab6c3b00af65ed Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 25 Jun 2015 20:03:39 -0400 Subject: * Track initial working directory * Assign script locations AFTER generating a viable place to put them. --- cbc/environment.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'cbc/environment.py') 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]) -- cgit