Beispiel #1
0
def createProject():
    """
        Turns a software package into PyCharm project.

        For this some files within ".idea" are created.
    """
    BuildSystemTools.requireTopLevelDir()

    configDir = '.idea'
    logging.info('creating config in %s', configDir)

    projectRoot = ProjectProperties.detectTopLevelDir()

    if projectRoot is None:
        raise RuntimeError('unable to detect top-level-directory of package')

    packageName = ProjectProperties.getPackageName(projectRoot)
    packageVersion = ProjectProperties.getPackageVersion(projectRoot)

    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)

    template = PackageCreator_JetBrains_PyCharm_Config(packageName,
                                                       packageVersion,
                                                       outputDir=configDir)
    template.run()
Beispiel #2
0
def showStatistics():
    """
        Shows few numbers on current SIT such as number of packages.
    """
    from ToolBOSCore.Packages import ProjectProperties

    path = getRootPath()
    total = []
    pkgRoots = []
    pkgVersions = 0
    regexp = re.compile("^(\d+)\.(\d+)$")

    Any.requireMsg(regexp, 'internal script error: empty regexp')

    getProjectsWithErrorHandling(path, total)

    for package in total:
        pkgRoot = os.path.dirname(package)
        version = ProjectProperties.getPackageVersion(package, True)

        if pkgRoot not in pkgRoots:
            pkgRoots.append(pkgRoot)

        # if this package is one with a 2-digit version, add it to the
        # number of 2-digit-packages
        if regexp.match(version):
            pkgVersions += 1

    logging.info('path:                                  %s' % path)
    logging.info('number of distinct packages:           %d' % len(pkgRoots))
    logging.info('number of 2-digit-versions:            %d' % pkgVersions)
    logging.info('number of 3-digit-versions (= total):  %d' % len(total))
Beispiel #3
0
def isTopLevelDir( path='.' ):
    """
        Returns a boolean whether or not the provided directory is the
        top-level-directory of a source package.
    """
    regExpVersion   = re.compile( "^(\d+\.\d+).*$" )
    projectVersion  = ProjectProperties.getPackageVersion( path, verbatim=True )
    versionDirFound = bool( regExpVersion.search( projectVersion ) )

    if versionDirFound:
        return True
    else:
        return os.path.exists( 'CMakeLists.txt' ) or \
               os.path.exists( 'packageVar.cmake' ) or \
               os.path.exists( 'pkgInfo.py' )
Beispiel #4
0
def createProject():
    """
        Turns a software package into CLion project.

        For this some files within ".idea" are created.
    """
    BuildSystemTools.requireTopLevelDir()

    configDir = '.idea'
    logging.info('creating config in %s', configDir)

    projectRoot = ProjectProperties.detectTopLevelDir()
    packageName = ProjectProperties.getPackageName(projectRoot)
    packageVersion = ProjectProperties.getPackageVersion(projectRoot)

    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)

    template = PackageCreator_JetBrains_CLion_Config(packageName,
                                                     packageVersion,
                                                     outputDir=configDir)
    template.run()
def registerNormalPackage(package,
                          sitProxyPath=None,
                          indexBaseDir=None,
                          dryRun=False):
    """
        Creates a symlink to the *.pck file of 'package' within the RTMaps
        index.

        RTMAPS_VERSION is taken from the dependency list of the package.
    """
    if sitProxyPath is None:
        sitProxyPath = SIT.getPath()

    if indexBaseDir is None:
        indexBaseDir = getIndexBaseDir(sitProxyPath)

    ProjectProperties.requireIsCanonicalPath(package)
    Any.requireIsDir(sitProxyPath)
    Any.requireIsDir(indexBaseDir)
    Any.requireIsBool(dryRun)

    platformList = getPlatformNames()
    packageName = ProjectProperties.getPackageName(package)
    packageVersion = ProjectProperties.getPackageVersion(package)
    versionTokens = ProjectProperties.splitVersion(packageVersion)
    majorVersion = int(versionTokens[0])
    minorVersion = int(versionTokens[1])
    installRoot = os.path.join(sitProxyPath, package)

    Any.requireIsListNonEmpty(platformList)
    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)
    Any.requireIsDir(installRoot)

    deps = ProjectProperties.getDependencies(package)
    try:
        Any.requireIsListNonEmpty(deps)
    except AssertionError:
        logging.debug(
            'empty list of dependencies in RTMaps package is unplausible')
        msg = "%s: unable to retrieve dependencies, please check SIT installation" % package
        raise ValueError(msg)

    expr = re.compile('^sit://External/RTMaps/(\d+\.\d+)')

    # detect RTMaps version used by package
    rtmapsVersion = ''

    for dep in deps:
        tmp = expr.match(dep)

        if tmp:
            rtmapsVersion = tmp.group(1)
            break

    Any.requireIsTextNonEmpty(rtmapsVersion)
    logging.debug('%s depends on RTMaps %s', package, rtmapsVersion)

    libDir = os.path.join(installRoot, 'lib')
    pckFiles = FastScript.findFiles(libDir, ext='.pck')

    Any.requireMsg(
        len(pckFiles) > 0,
        package + ": No *.pck file found, forgot to compile?")

    for relPath in pckFiles:
        pckFileName = os.path.basename(relPath)
        pckPackage = os.path.splitext(pckFileName)[0]
        pckFileExt = os.path.splitext(pckFileName)[1]

        logging.debug('registering %s', pckPackage)

        for platform in platformList:
            pckPath = os.path.join(libDir, platform, pckFileName)
            dstDir = os.path.join(indexBaseDir, rtmapsVersion, platform)

            if os.path.exists(pckPath):
                symlinkFile = '%s_%d.%d%s' % (pckPackage, majorVersion,
                                              minorVersion, pckFileExt)
                symlinkPath = os.path.join(dstDir, symlinkFile)
                target = pckPath

                FastScript.link(target, symlinkPath, dryRun)
Beispiel #6
0
    def __init__(self, projectRoot=None, pkgInfoContent=None):

        from ToolBOSCore.SoftwareQuality.CheckRoutine import sqLevelDefault

        if not projectRoot:
            projectRoot = ProjectProperties.detectTopLevelDir()

        if not projectRoot:
            raise AssertionError('unknown project root location')

        Any.requireIsDir(projectRoot)

        # general meta-info
        self.canonicalPath = None
        self.cmakelistsContent = None
        self.hasCMakeLists = None
        self.installRoot = None
        self.isDeprecated = None
        self.packageCategory = None
        self.packageName = None
        self.packageVersion = None  # e.g. "2.0"
        self.packageVersionRaw = None  # e.g. "2.0-rc3" (corresponds to dir.name)
        self.patchlevel = None  # e.g. 42, may correspond to SVN rev.
        self.topLevelDir = None
        self.versionTokens = None  # e.g. ( "2", "0", "123" )

        # dependencies
        self.buildDependencies = []  # direct build-deps
        self.buildDependsArch = {}
        self.dependencies = []  # direct deps
        self.dependsArch = {}
        self.inheritedProjects = []  # deps. + recommend. (used in BashSrc)
        self.recommendations = []
        self.suggestions = []

        # values extracted from install/user{Install,Src}.php / pkgInfo.py
        self.pkgInfoContent = pkgInfoContent
        self.docTool = None
        self.install = []
        self.installHooks = {}
        self.installMatching = []
        self.installSymlinks = []
        self.installGroup = None
        self.installUmask = None
        self.installMode = 'incremental'
        self.linkAllLibraries = False
        self.usePatchlevels = False
        self.userSrcContent = None
        self.userSrcEnv = ()
        self.userSrcAlias = ()
        self.userSrcBashCode = ()
        self.userSrcCmdCode = ()
        self.sqLevel = sqLevelDefault
        self.sqOptInRules = []
        self.sqOptOutRules = []
        self.sqOptInDirs = []
        self.sqOptOutDirs = []
        self.sqOptInFiles = []
        self.sqOptOutFiles = []
        self.sqCheckExe = None
        self.sqComments = {}
        self.useClang = None

        # revision control system
        self.gitBranch = None
        self.gitBranchForCIA = None
        self.gitFound = None
        self.gitCommitIdLong = None
        self.gitCommitIdShort = None
        self.gitOrigin = None
        self.gitOriginForCIA = None
        self.gitRelPath = None
        self.gitRepositoryRoot = None
        self.svnFound = None
        self.svnRelPath = None
        self.svnRevision = None
        self.svnRepositoryURL = None
        self.svnRepositoryRoot = None
        self.svnRevisionForCIA = None
        self.vcsBranch = None
        self.vcsFound = None
        self.vcsURL = None
        self.vcsRelPath = None
        self.vcsRevision = None
        self.vcsRoot = None

        # current user (likely the maintainer when working on source tree)
        self.userAccount = None
        self.userName = None

        # maintainer (filesystem owner when accessing SIT packages)
        self.maintainerAccount = None
        self.maintainerName = None

        cmakePath = os.path.join(projectRoot, 'CMakeLists.txt')
        self.hasCMakeLists = os.path.exists(cmakePath)

        self.topLevelDir = projectRoot
        self.packageName = ProjectProperties.getPackageName(self.topLevelDir)
        self.packageVersion = ProjectProperties.getPackageVersion(
            self.topLevelDir, False)
        self.packageVersionRaw = ProjectProperties.getPackageVersion(
            self.topLevelDir, True)
        self.versionTokens = ProjectProperties.splitVersion(
            self.packageVersionRaw)

        Any.requireIsTextNonEmpty(self.packageName)
        Any.requireIsTextNonEmpty(self.packageVersion)

        # compute typical directory names (may not be present!)
        hostPlatform = Platforms.getHostPlatform()
        Any.requireIsTextNonEmpty(hostPlatform)

        self.binDir = os.path.join(self.topLevelDir, 'bin')
        self.binDirArch = os.path.join(self.topLevelDir, 'bin', hostPlatform)
        self.examplesDir = os.path.join(self.topLevelDir, 'examples')
        self.examplesDirArch = os.path.join(self.topLevelDir, 'examples',
                                            hostPlatform)
        self.includeDir = os.path.join(self.topLevelDir, 'include')
        self.installDir = os.path.join(self.topLevelDir, 'install')
        self.libDir = os.path.join(self.topLevelDir, 'lib')
        self.libDirArch = os.path.join(self.topLevelDir, 'lib', hostPlatform)
        self.srcDir = os.path.join(self.topLevelDir, 'src')
        self.testDir = os.path.join(self.topLevelDir, 'test')
        self.testDirArch = os.path.join(self.topLevelDir, 'test', hostPlatform)

        if self.hasCMakeLists:
            # source tree, C/C++ package
            self.cmakelistsContent = FastScript.getFileContent(cmakePath)

            if self.cmakelistsContent:
                self.packageCategory = CMakeLists.getCategory(
                    self.cmakelistsContent)
            else:
                logging.debug('skipping empty %s', cmakePath)

        else:
            # source tree w/o CMakeLists.txt, or package installed in SIT
            self.cmakelistsContent = None

            try:
                self.packageCategory = ProjectProperties.getPackageCategoryFromPath(
                    projectRoot)
            except AssertionError:
                raise AssertionError('unable to detect package category')

        if self.packageCategory:
            self.canonicalPath = os.path.join(self.packageCategory,
                                              self.packageName,
                                              self.packageVersion)

        self._retrieveCurrentUser()

        # Any.requireIsTextNonEmpty( self.maintainerAccount ) # might be empty
        # Any.requireIsTextNonEmpty( self.maintainerName )    # might be empty
        Any.requireIsTextNonEmpty(self.packageName)
        Any.requireIsTextNonEmpty(self.packageVersion)
        Any.requireIsTextNonEmpty(self.packageVersionRaw)
        Any.requireIsTextNonEmpty(self.topLevelDir)
        Any.requireIsTextNonEmpty(self.userAccount)
        Any.requireIsTextNonEmpty(self.userName)