Esempio n. 1
0
def do_vcs_install(manifest_in, versionfile_source, ipy):
    GITS = ["git"]
    if sys.platform == "win32":
        GITS = ["git.cmd", "git.exe"]
    files = [manifest_in, versionfile_source, ipy]
    try:
        me = __file__
        if me.endswith(".pyc") or me.endswith(".pyo"):
            me = os.path.splitext(me)[0] + ".py"
        versioneer_file = os.path.relpath(me)
    except NameError:
        versioneer_file = "versioneer.py"
    files.append(versioneer_file)
    present = False
    try:
        f = open(".gitattributes", "r")
        for line in f.readlines():
            if line.strip().startswith(versionfile_source):
                if "export-subst" in line.strip().split()[1:]:
                    present = True
        f.close()
    except EnvironmentError:
        pass    
    if not present:
        f = open(".gitattributes", "a+")
        f.write("%s export-subst\n" % versionfile_source)
        f.close()
        files.append(".gitattributes")
    run_command(GITS, ["add", "--"] + files)
Esempio n. 2
0
def git_versions_from_vcs(tag_prefix, root, verbose=False):
    # this runs 'git' from the root of the source tree. This only gets called
    # if the git-archive 'subst' keywords were *not* expanded, and
    # _version.py hasn't already been rewritten with a short version string,
    # meaning we're inside a checked out source tree.

    if not os.path.exists(os.path.join(root, ".git")):
        if verbose:
            print("no .git in %s" % root)
        return {}

    GITS = ["git"]
    if sys.platform == "win32":
        GITS = ["git.cmd", "git.exe"]
    stdout = run_command(GITS, ["describe", "--tags", "--dirty", "--always"],
                         cwd=root)
    if stdout is None:
        return {}
    if not stdout.startswith(tag_prefix):
        if verbose:
            print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))
        return {}
    tag = stdout[len(tag_prefix):]
    stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
    if stdout is None:
        return {}
    full = stdout.strip()
    if tag.endswith("-dirty"):
        full += "-dirty"
    return {"version": tag, "full": full}
Esempio n. 3
0
 def python(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.subpath("demoapp"))
     assert not kwargs, kwargs.keys()
     output = run_command([sys.executable], list(args), workdir, True)
     if output is None:
         self.fail("problem running python")
     return output
 def python(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.subpath("demoapp"))
     assert not kwargs, kwargs.keys()
     output = run_command([sys.executable], list(args), workdir, True)
     if output is None:
         self.fail("problem running python")
     return output
Esempio n. 5
0
 def command(self, cmd, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.projdir)
     assert not kwargs, kwargs.keys()
     output, rc = run_command([cmd], list(args), workdir, True)
     if output is None:
         self.fail("problem running command %s" % cmd)
     return output
 def git(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.subpath("demoapp"))
     assert not kwargs, kwargs.keys()
     output = run_command(GITS, list(args), workdir, True)
     if output is None:
         self.fail("problem running git")
     return output
Esempio n. 7
0
 def git(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", "_test/demoapp")
     assert not kwargs, kwargs.keys()
     output = run_command(["git"]+list(args), workdir, True)
     if output is None:
         self.fail("problem running git")
     return output
Esempio n. 8
0
 def git(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.subpath("demoapp"))
     assert not kwargs, kwargs.keys()
     output = run_command(GITS, list(args), workdir, True)
     if output is None:
         self.fail("problem running git")
     return output
Esempio n. 9
0
 def command(self, cmd, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.subpath("demoapp"))
     assert not kwargs, kwargs.keys()
     output = run_command([cmd], list(args), workdir, True)
     if output is None:
         self.fail("problem running command %s" % cmd)
     return output
Esempio n. 10
0
 def python(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.projdir)
     exe = kwargs.pop("python", sys.executable)
     assert not kwargs, kwargs.keys()
     output, rc = run_command([exe], list(args), workdir, True)
     if output is None:
         self.fail("problem running python (workdir: %s)" % workdir)
     return output
Esempio n. 11
0
 def python(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.projdir)
     exe = kwargs.pop("python", sys.executable)
     assert not kwargs, kwargs.keys()
     output, rc = run_command([exe], list(args), workdir, True)
     if output is None:
         self.fail("problem running python (workdir: %s)" % workdir)
     return output
Esempio n. 12
0
 def git(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.gitdir)
     assert not kwargs, kwargs.keys()
     env = os.environ.copy()
     env["EMAIL"] = "*****@*****.**"
     env["GIT_AUTHOR_NAME"] = "foo"
     env["GIT_COMMITTER_NAME"] = "foo"
     output, rc = run_command(GITS, args=list(args), cwd=workdir,
                              verbose=True, env=env)
     if output is None:
         self.fail("problem running git (workdir: %s)" % workdir)
     return output
Esempio n. 13
0
 def git(self, *args, **kwargs):
     workdir = kwargs.pop("workdir", self.gitdir)
     assert not kwargs, kwargs.keys()
     env = os.environ.copy()
     env["EMAIL"] = "*****@*****.**"
     env["GIT_AUTHOR_NAME"] = "foo"
     env["GIT_COMMITTER_NAME"] = "foo"
     output, rc = run_command(GITS,
                              args=list(args),
                              cwd=workdir,
                              verbose=True,
                              env=env)
     if output is None:
         self.fail("problem running git (workdir: %s)" % workdir)
     return output
Esempio n. 14
0
        out = self.python("rundemo", "--version", workdir=build_lib)
        data = dict([line.split(":",1) for line in out.splitlines()])
        self.compare(data["__version__"], exp_version, state, tree, "RB")
        self.assertPEP440(data["__version__"], state, tree, "RB")
        self.compare(data["version"], exp_version, state, tree, "RB")
        self.compare(data["dirty"], str(exp_dirty), state, tree, "RB")
        self.compare(data["full-revisionid"], str(exp_full), state, tree, "RB")
        self.compare(data["error"], str(exp_error), state, tree, "RB")

    def compare(self, got, expected, state, tree, runtime):
        where = "/".join([state, tree, runtime])
        self.assertEqual(got, expected, "%s: got '%s' != expected '%s'"
                         % (where, got, expected))
        if VERBOSE: print(" good %s" % where)

    def assertPEP440(self, got, state, tree, runtime):
        where = "/".join([state, tree, runtime])
        pv = parse_version(got)
        # rather than using an undocumented API, setuptools dev recommends this
        self.assertFalse("Legacy" in pv.__class__.__name__,
                         "%s: '%s' was not pep440-compatible"
                         % (where, got))
        self.assertEqual(str(pv), got,
                         "%s: '%s' pep440-normalized to '%s'"
                         % (where, got, str(pv)))

if __name__ == '__main__':
    ver, rc = run_command(common.GITS, ["--version"], ".", True)
    print("git --version: %s" % ver.strip())
    unittest.main()
            # and has more boilerplate.
            print(self.python("setup.py", "version", workdir=workdir))
        # setup.py --version gives us get_version() with verbose=False.
        v = self.python("setup.py", "--version", workdir=workdir)
        self.compare(v, exp_short, state, tree, "RA1")
        # and test again from outside the tree
        v = self.python(os.path.join(workdir, "setup.py"), "--version",
                        workdir=self.testdir)
        self.compare(v, exp_short, state, tree, "RA2")

        if dirty:
            return # cannot detect dirty files in a build # XXX really?

        # RB: setup.py build; rundemo --version
        if os.path.exists(os.path.join(workdir, "build")):
            shutil.rmtree(os.path.join(workdir, "build"))
        self.python("setup.py", "build", "--build-lib=build/lib",
                    "--build-scripts=build/lib", workdir=workdir)
        build_lib = os.path.join(workdir, "build", "lib")
        out = self.python("rundemo", "--version", workdir=build_lib)
        data = dict([line.split(":",1) for line in out.splitlines()])
        self.compare(data["__version__"], exp_short, state, tree, "RB")
        self.compare(data["shortversion"], exp_short, state, tree, "RB")
        self.compare(data["longversion"], exp_long, state, tree, "RB")


if __name__ == '__main__':
    ver = run_command(GITS, ["--version"], ".", True)
    print("git --version: %s" % ver.strip())
    unittest.main()
Esempio n. 16
0
            # setup.py version invokes cmd_version, which uses verbose=True
            # and has more boilerplate.
            print(self.python("setup.py", "version", workdir=workdir))
        # setup.py --version gives us get_version() with verbose=False.
        v = self.python("setup.py", "--version", workdir=workdir)
        self.compare(v, exp_short, state, tree, "RA")
        if dirty:
            return # cannot detect dirty files in a build

        # RB: setup.py build; rundemo --version
        if os.path.exists(os.path.join(workdir, "build")):
            shutil.rmtree(os.path.join(workdir, "build"))
        self.python("setup.py", "build", "--build-lib=build/lib",
                    "--build-scripts=build/lib", workdir=workdir)
        build_lib = os.path.join(workdir, "build", "lib")
        # copy bin/rundemo into the build libdir, so we don't have to muck
        # with PYTHONPATH when we execute it
        shutil.copyfile(os.path.join(workdir, "bin", "rundemo"),
                        os.path.join(build_lib, "rundemo"))
        out = self.python("rundemo", "--version", workdir=build_lib)
        data = dict([line.split(":",1) for line in out.splitlines()])
        self.compare(data["__version__"], exp_short, state, tree, "RB")
        self.compare(data["shortversion"], exp_short, state, tree, "RB")
        self.compare(data["longversion"], exp_long, state, tree, "RB")


if __name__ == '__main__':
    ver = run_command(["git", "--version"], ".", True)
    print("git --version: %s" % ver.strip())
    unittest.main()
Esempio n. 17
0
            # and has more boilerplate.
            print(self.python("setup.py", "version", workdir=workdir))
        # setup.py --version gives us get_version() with verbose=False.
        v = self.python("setup.py", "--version", workdir=workdir)
        self.compare(v, exp_short, state, tree, "RA1")
        # and test again from outside the tree
        v = self.python(os.path.join(workdir, "setup.py"), "--version",
                        workdir=self.testdir)
        self.compare(v, exp_short, state, tree, "RA2")

        if dirty:
            return # cannot detect dirty files in a build # XXX really?

        # RB: setup.py build; rundemo --version
        if os.path.exists(os.path.join(workdir, "build")):
            shutil.rmtree(os.path.join(workdir, "build"))
        self.python("setup.py", "build", "--build-lib=build/lib",
                    "--build-scripts=build/lib", workdir=workdir)
        build_lib = os.path.join(workdir, "build", "lib")
        out = self.python("rundemo", "--version", workdir=build_lib)
        data = dict([line.split(":",1) for line in out.splitlines()])
        self.compare(data["__version__"], exp_short, state, tree, "RB")
        self.compare(data["shortversion"], exp_short, state, tree, "RB")
        self.compare(data["longversion"], exp_long, state, tree, "RB")


if __name__ == '__main__':
    ver = run_command(GITS, ["--version"], ".", True)
    print("git --version: %s" % ver.strip())
    unittest.main()
Esempio n. 18
0
        build_lib = os.path.join(workdir, "build", "lib")
        out = self.python("rundemo", "--version", workdir=build_lib)
        data = dict([line.split(":",1) for line in out.splitlines()])
        self.compare(data["__version__"], exp_version, state, tree, "RB")
        self.assertPEP440(data["__version__"], state, tree, "RB")
        self.compare(data["version"], exp_version, state, tree, "RB")
        self.compare(data["dirty"], str(exp_dirty), state, tree, "RB")
        self.compare(data["full-revisionid"], str(exp_full), state, tree, "RB")
        self.compare(data["error"], str(exp_error), state, tree, "RB")

    def compare(self, got, expected, state, tree, runtime):
        where = "/".join([state, tree, runtime])
        self.assertEqual(got, expected, "%s: got '%s' != expected '%s'"
                         % (where, got, expected))
        if VERBOSE: print(" good %s" % where)

    def assertPEP440(self, got, state, tree, runtime):
        where = "/".join([state, tree, runtime])
        pv = parse_version(got)
        self.assertFalse(isinstance(pv, SetuptoolsLegacyVersion),
                         "%s: '%s' was not pep440-compatible"
                         % (where, got))
        self.assertEqual(str(pv), got,
                         "%s: '%s' pep440-normalized to '%s'"
                         % (where, got, str(pv)))

if __name__ == '__main__':
    ver, rc = run_command(common.GITS, ["--version"], ".", True)
    print("git --version: %s" % ver.strip())
    unittest.main()