Beispiel #1
0
 def recreate_venv(self, site_packages=False):
     """
     (Re-)creates this project's virtual environment, deleting the old
     virtualenv folder, if one is found. Afterwards, it will register all
     configuration files (files in the project's root folder, that end on
     '.conf') as configuration files, so that they are available to the score
     CLI inside the virtual environment.
     """
     try:
         shutil.rmtree(self.venvdir)
     except FileNotFoundError:
         pass
     create_args = ['--python', sys.executable, '--make', 'true']
     if site_packages:
         create_args.insert(-1, '--site-packages')
     self.vex(*create_args)
     self.install()
     self.vex('pip', 'install', '--upgrade',
              '--force-reinstall', 'score.cli')
     for file in os.listdir(self.folder):
         if not file.endswith('.conf'):
             continue
         name = file[:-5]
         file = os.path.join(self.folder, file)
         try:
             addconf(name, file, venv=self.venvdir)
         except InvalidConfigurationNameException:
             pass
         else:
             make_default_conf(name, venv=self.venvdir)
Beispiel #2
0
 def relocate(self, project, folder):
     """
     Moves the code folder of given *project* to the specified *folder*.
     """
     project = self.get(project)
     shutil.move(project.folder, folder)
     configurations = name2file(include_global=False, venv=project.venvdir)
     for name, path in configurations.items():
         path = get_origin(path)
         if not path.startswith(project.folder):
             continue
         relpath = os.path.relpath(path, project.folder)
         newpath = os.path.join(folder, relpath)
         addconf(name, newpath, venv=project.venvdir)
     project.folder = folder
     project.install()
     settings = self._read_conf()
     settings[project.name] = {'folder': folder}
     self._write_conf(settings)
     return project