Exemplo n.º 1
0
 def test_mkdir_mode(self):
     # (identical to test_remote.TestRemotePath.test_mkdir_mode)
     with local.tempdir() as tmp:
         # just verify that mode argument works the same way it does for
         # Python's own os.mkdir, which takes into account the umask
         # (different from shell mkdir mode argument!); umask on my
         # system is 022 by default, so 033 is ok for testing this
         try:
             (tmp / "pb_333").mkdir(exist_ok=False,
                                    parents=False,
                                    mode=0o333)
             local.python(
                 "-c",
                 "import os; os.mkdir({}, 0o333)".format(
                     repr(str(tmp / "py_333"))),
             )
             pb_final_mode = oct((tmp / "pb_333").stat().st_mode)
             py_final_mode = oct((tmp / "py_333").stat().st_mode)
             assert pb_final_mode == py_final_mode
         finally:
             # we have to revert this so the tempdir deletion works
             if (tmp / "pb_333").exists():
                 (tmp / "pb_333").chmod(0o777)
             if (tmp / "py_333").exists():
                 (tmp / "py_333").chmod(0o777)
     assert not tmp.exists()
Exemplo n.º 2
0
    def main(self):
        delete(local.cwd // "*.egg-info", "build", "dist")

        if self.upload:
            local.python("setup.py", "register")
        
        local.python("setup.py", "sdist", "--formats=zip,gztar", "bdist_wininst", "--plat-name=win32", 
            "upload" if self.upload else None)
        
        delete(local.cwd // "*.egg-info", "build")
Exemplo n.º 3
0
    def main(self):
        local.cwd.chdir(HERE)
        sys.path.insert(0, str(ROOT))
        local.env["PYTHONPATH"] = ROOT

        local.python("build_openni.py")
        local.python("build_nite.py")

        from primesense import openni2, nite2

        dist = local.path("../dist")
        dist.delete()
        dist.mkdir()

        tmp = local.path("tmp")
        tmp.delete()
        tmp.mkdir()

        copy("../primesense", tmp / "primesense")
        copy("MANIFEST.in", tmp)
        copy("../LICENSE", tmp)
        copy("../README.rst", tmp)

        ver = "%s.%s.%s.%s-%s" % (
            openni2.c_api.ONI_VERSION_MAJOR, openni2.c_api.ONI_VERSION_MINOR,
            openni2.c_api.ONI_VERSION_MAINTENANCE,
            openni2.c_api.ONI_VERSION_BUILD, config.get("pypi", "release"))

        data = local.path("setup_template.py").read().replace("$VERSION$", ver)
        (tmp / "setup.py").write(data)

        with local.cwd(tmp):
            if self.upload:
                # copy pypirc to ~
                orig = local.path("~/.pypirc")
                restore = False
                if orig.exists():
                    copy(orig, "~/.pypirc-openni-wrapper")
                    restore = True
                copy(ROOT / "_pypirc", "~/.pypirc")
                try:
                    local.python["setup.py", "sdist", "--formats=zip,gztar",
                                 None if self.dont_register else "register",
                                 "upload"] & FG
                finally:
                    if restore:
                        copy("~/.pypirc-openni-wrapper", orig)
            else:
                local.python["setup.py", "sdist", "--formats=zip,gztar"] & FG

        for fn in tmp / "dist" // "*":
            fn.move(dist)
Exemplo n.º 4
0
    def test_env(self):
        assert "PATH" in local.env
        assert "FOOBAR72" not in local.env
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR72']")
        local.env["FOOBAR72"] = "spAm"
        assert local.python(
            "-c", "import os;print (os.environ['FOOBAR72'])"
        ).splitlines() == ["spAm"]

        with local.env(FOOBAR73=1889):
            assert local.python(
                "-c", "import os;print (os.environ['FOOBAR73'])"
            ).splitlines() == ["1889"]
            with local.env(FOOBAR73=1778):
                assert local.python(
                    "-c", "import os;print (os.environ['FOOBAR73'])"
                ).splitlines() == ["1778"]
            assert local.python(
                "-c", "import os;print (os.environ['FOOBAR73'])"
            ).splitlines() == ["1889"]
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR73']")

        # path manipulation
        with pytest.raises(CommandNotFound):
            local.which("dummy-executable")
        with local.env():
            local.env.path.insert(0, local.cwd / "not-in-path")
            p = local.which("dummy-executable")
            assert p == local.cwd / "not-in-path" / "dummy-executable"
Exemplo n.º 5
0
    def main(self):
        local.cwd.chdir(HERE)
        sys.path.insert(0, str(ROOT))
        local.env["PYTHONPATH"] = ROOT

        local.python("build_openni.py")
        local.python("build_nite.py")
        
        from primesense import openni2, nite2
        
        dist = local.path("../dist")
        dist.delete()
        dist.mkdir()
        
        tmp = local.path("tmp")
        tmp.delete()
        tmp.mkdir()
        
        copy("../primesense", tmp / "primesense")
        copy("MANIFEST.in", tmp)
        copy("../LICENSE", tmp)
        copy("../README.rst", tmp)
        
        ver = "%s.%s.%s.%s-%s" % (openni2.c_api.ONI_VERSION_MAJOR, openni2.c_api.ONI_VERSION_MINOR, 
            openni2.c_api.ONI_VERSION_MAINTENANCE, openni2.c_api.ONI_VERSION_BUILD, config.get("pypi", "release"))
        
        data = local.path("setup_template.py").read().replace("$VERSION$", ver)
        (tmp / "setup.py").write(data)
        
        with local.cwd(tmp):
            if self.upload:
                # copy pypirc to ~
                orig = local.path("~/.pypirc")
                restore = False
                if orig.exists():
                    copy(orig, "~/.pypirc-openni-wrapper")
                    restore = True
                copy(ROOT / "_pypirc", "~/.pypirc")
                try:
                    local.python["setup.py", "sdist", "--formats=zip,gztar", 
                        None if self.dont_register else "register", "upload"] & FG
                finally:
                    if restore:
                        copy("~/.pypirc-openni-wrapper", orig)
            else:
                local.python["setup.py", "sdist", "--formats=zip,gztar"] & FG
        
        for fn in tmp / "dist" // "*":
            fn.move(dist)
Exemplo n.º 6
0
    def main(self):
        delete(local.cwd // "*.egg-info", "build", "dist")

        #if self.upload:
        #    local.python("setup.py", "register")

        local.python("setup.py", "sdist", "--formats=zip,gztar", "bdist_wininst", "--plat-name=win32")

        delete(local.cwd // "*.egg-info", "build")

        if self.upload:
            if twine is None:
                print("Twine not installed, cannot securly upload. Install twine.")
            else:
                twine['upload','dist/*'] & FG
Exemplo n.º 7
0
 def test_local(self):
     self.assertTrue("plumbum" in str(local.cwd))
     self.assertTrue("PATH" in local.env.getdict())
     self.assertEqual(local.path("foo"), os.path.join(os.getcwd(), "foo"))
     local.which("ls")
     local["ls"]
     self.assertEqual(local.python("-c", "print ('hi there')").splitlines(), ["hi there"])
Exemplo n.º 8
0
 def test_local(self):
     self.assertTrue("plumbum" in str(local.cwd))
     self.assertTrue("PATH" in local.env.getdict())
     self.assertEqual(local.path("foo"), os.path.join(os.getcwd(), "foo"))
     local.which("ls")
     local["ls"]
     self.assertEqual(local.python("-c", "print ('hi there')").splitlines(), ["hi there"])
Exemplo n.º 9
0
 def test_local(self):
     from plumbum.cmd import cat, head
     assert "plumbum" in str(local.cwd)
     assert "PATH" in local.env.getdict()
     assert local.path("foo") == os.path.join(os.getcwd(), "foo")
     local.which("ls")
     local["ls"]
     assert local.python("-c", "print ('hi there')").splitlines() == ["hi there"]
Exemplo n.º 10
0
Arquivo: build.py Projeto: C4rt/rpyc
    def main(self):
        delete("build", "dist", "MANIFEST", local.cwd // "*.egg-info")

        # generate zip, tar.gz, and win32 installer
        if self.publish:
            print("registering...")
            local.python("setup.py", "register")
            print("uploading zip and tar.gz")
            local.python("setup.py", "sdist", "--formats=zip,gztar", "upload")
            print("uploading win installer")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32", "upload")
        else:
            local.python("setup.py", "sdist", "--formats=zip,gztar")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32")
    
        delete("build", local.cwd // "*.egg-info")
        print("Built", [f.basename for f in local.cwd / "dist"])
    def main(self):
        delete(local.cwd // "*.egg-info", "build", "dist")

        local.python("setup.py", "sdist", "bdist_wheel")

        delete(local.cwd // "*.egg-info", "build")

        if self.upload:
            if twine is None:
                print(
                    "Twine not installed, cannot securely upload. Install twine."
                )
            else:
                twine['upload', 'dist/*tar.gz', 'dist/*.whl'] & FG
        else:
            print("Built. To upload, run:")
            print("  twine upload dist/*tar.gz dist/*.whl")
Exemplo n.º 12
0
    def main(self):
        delete("build", "dist", "MANIFEST", local.cwd // "*.egg-info")

        # generate zip, tar.gz, and win32 installer
        if self.publish:
            print("registering...")
            local.python("setup.py", "register")
            print("uploading zip and tar.gz")
            local.python("setup.py", "sdist", "--formats=zip,gztar", "upload")
            print("uploading win installer")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32",
                         "upload")
        else:
            local.python("setup.py", "sdist", "--formats=zip,gztar")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32")

        delete("build", local.cwd // "*.egg-info")
        print("Built", [f.basename for f in local.cwd / "dist"])
Exemplo n.º 13
0
    def test_env(self):
        self.assertTrue("PATH" in local.env)
        self.assertFalse("FOOBAR72" in local.env)
        self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR72']")
        local.env["FOOBAR72"] = "spAm"
        self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines(), ["spAm"])

        with local.env(FOOBAR73 = 1889):
            self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"])
            with local.env(FOOBAR73 = 1778):
                self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1778"])
            self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"])
        self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR73']")

        # path manipulation
        self.assertRaises(CommandNotFound, local.which, "dummy-executable")
        with local.env():
            local.env.path.insert(0, local.cwd / "not-in-path")
            p = local.which("dummy-executable")
            self.assertEqual(p, local.cwd / "not-in-path" / "dummy-executable")
Exemplo n.º 14
0
    def test_env(self):
        self.assertTrue("PATH" in local.env)
        self.assertFalse("FOOBAR72" in local.env)
        self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR72']")
        local.env["FOOBAR72"] = "spAm"
        self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines(), ["spAm"])

        with local.env(FOOBAR73 = 1889):
            self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"])
            with local.env(FOOBAR73 = 1778):
                self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1778"])
            self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"])
        self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR73']")

        # path manipulation
        self.assertRaises(CommandNotFound, local.which, "dummy-executable")
        with local.env():
            local.env.path.insert(0, local.cwd / "not-in-path")
            p = local.which("dummy-executable")
            self.assertEqual(p, local.cwd / "not-in-path" / "dummy-executable")
Exemplo n.º 15
0
Arquivo: build.py Projeto: B-Rich/rpyc
    def main(self):
        delete("build", "dist", "MANIFEST", local.cwd // "*.egg-info")

        # generate zip, tar.gz, and win32 installer
        if self.publish:
            print("registering...")
            local.python("setup.py", "register")
            print("uploading zip and tar.gz")
            local.python("setup.py", "sdist", "--formats=zip,gztar", "upload")
            print("uploading win installer")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32", "upload")
    
            # upload to sourceforge
            print("uploading to sourceforge")
            dst = "gangesmaster,[email protected]:/home/frs/project/r/rp/rpyc/main/%s/" % (version_string,)
            local["rsync"]("-rv", "dist/", dst)
        else:
            local.python("setup.py", "sdist", "--formats=zip,gztar")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32")
    
        delete("build", local.cwd // "*.egg-info")
        print("Built", [f.basename for f in local.cwd / "dist"])
Exemplo n.º 16
0
 def test_mkdir_mode(self):
     # (identical to test_remote.TestRemotePath.test_mkdir_mode)
     with local.tempdir() as tmp:
         # just verify that mode argument works the same way it does for
         # Python's own os.mkdir, which takes into account the umask
         # (different from shell mkdir mode argument!); umask on my
         # system is 022 by default, so 033 is ok for testing this
         try:
             (tmp / "pb_333").mkdir(exist_ok=False, parents=False,
                 mode=0o333)
             local.python('-c', 'import os; os.mkdir({0}, 0o333)'.format(
                 repr(str(tmp / "py_333"))))
             pb_final_mode = oct((tmp / "pb_333").stat().st_mode)
             py_final_mode = oct((tmp / "py_333").stat().st_mode)
             assert pb_final_mode == py_final_mode
         finally:
             # we have to revert this so the tempdir deletion works
             if (tmp / "pb_333").exists():
                 (tmp / "pb_333").chmod(0o777)
             if (tmp / "py_333").exists():
                 (tmp / "py_333").chmod(0o777)
     assert not tmp.exists()
Exemplo n.º 17
0
    def test_pid_file(self):
        code = """from __future__ import with_statement
from plumbum.fs.atomic import PidFile, PidFileTaken
try:
    with PidFile("mypid"):
        raise ValueError("this should have failed")
except PidFileTaken:
    print("already locked")
"""
        with PidFile("mypid"):
            output = local.python("-c", code)
            self.assertEqual(output.strip(), "already locked")

        local.path("mypid").delete()
Exemplo n.º 18
0
    def test_pid_file(self):
        code = """from __future__ import with_statement
from plumbum.fs.atomic import PidFile, PidFileTaken
try:
    with PidFile("mypid"):
        raise ValueError("this should have failed")
except PidFileTaken:
    print("already locked")
"""
        with PidFile("mypid"):
            output = local.python("-c", code)
            self.assertEqual(output.strip(), "already locked")

        local.path("mypid").delete()
Exemplo n.º 19
0
def main():

    with local.cwd(os.path.abspath(os.path.dirname(__file__))):

        # Touch the todo list
        with local.cwd('../collections/magic_collection/docs'):
            os.utime('todo.rst')

        # Regenerate the module autodocs
        with local.cwd('../tools'):
            local.python(
                'generate_module_docs.py',
                (
                    '..\\collections\\magic_collection',
                    '--output-dir',
                    '..\\collections\\magic_collection\\docs\\modules',
                    '--no-toc',
                    'magic_collection'
                )
            )

        # Build the documentation
        with local.cwd('../collections/magic_collection/docs'):

            make_doc = local[local.cwd / 'make.bat']

            with local.env(
                BUILDDIR='generated_external'
            ):
                make_doc.run('html', stdout=sys.stdout, stderr=sys.stderr)

            with local.env(
                SPHINXOPTS='-t internal',
                BUILDDIR='generated_internal'
            ):
                make_doc.run('html', stdout=sys.stdout, stderr=sys.stderr)
Exemplo n.º 20
0
Arquivo: build.py Projeto: genba/rpyc
    def main(self):
        delete("build", "dist", "MANIFEST", local.cwd // "*.egg-info")

        # generate zip, tar.gz, and win32 installer
        if self.publish:
            print("registering...")
            local.python("setup.py", "register")
            print("uploading zip and tar.gz")
            local.python("setup.py", "sdist", "--formats=zip,gztar", "upload")
            print("uploading win installer")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32",
                         "upload")

            # upload to sourceforge
            print("uploading to sourceforge")
            dst = "gangesmaster,[email protected]:/home/frs/project/r/rp/rpyc/main/%s/" % (
                version_string, )
            local["rsync"]("-rv", "dist/", dst)
        else:
            local.python("setup.py", "sdist", "--formats=zip,gztar")
            local.python("setup.py", "bdist_wininst", "--plat-name=win32")

        delete("build", local.cwd // "*.egg-info")
        print("Built", [f.basename for f in local.cwd / "dist"])
Exemplo n.º 21
0
    def test_atomic_file2(self):
        af = AtomicFile("tmp.txt")

        code = """from __future__ import with_statement
from plumbum.fs.atomic import AtomicFile
af = AtomicFile("tmp.txt")
try:
    with af.locked(blocking = False):
        raise ValueError("this should have failed")
except (OSError, IOError):
    print("already locked")
"""
        with af.locked():
            output = local.python("-c", code)
            self.assertEqual(output.strip(), "already locked")

        local.path("tmp.txt").delete()
Exemplo n.º 22
0
    def test_atomic_file2(self):
        af = AtomicFile("tmp.txt")

        code = """from __future__ import with_statement
from plumbum.fs.atomic import AtomicFile
af = AtomicFile("tmp.txt")
try:
    with af.locked(blocking = False):
        raise ValueError("this should have failed")
except (OSError, IOError):
    print("already locked")
"""
        with af.locked():
            output = local.python("-c", code)
            self.assertEqual(output.strip(), "already locked")

        local.path("tmp.txt").delete()
Exemplo n.º 23
0
    def test_env(self):
        assert "PATH" in local.env
        assert "FOOBAR72" not in local.env
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR72']")
        local.env["FOOBAR72"] = "spAm"
        assert local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines() == ["spAm"]

        with local.env(FOOBAR73 = 1889):
            assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"]
            with local.env(FOOBAR73 = 1778):
                assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1778"]
            assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"]
        with pytest.raises(ProcessExecutionError):
            local.python("-c", "import os;os.environ['FOOBAR73']")

        # path manipulation
        with pytest.raises(CommandNotFound):
            local.which("dummy-executable")
        with local.env():
            local.env.path.insert(0, local.cwd / "not-in-path")
            p = local.which("dummy-executable")
            assert p == local.cwd / "not-in-path" / "dummy-executable"
Exemplo n.º 24
0
                goners = tgt_dir // "*"
                goners.extend(tgt_dir // ".*")
                for e in goners:
                    e.delete()
        else:
            raise NameExistsNotDir, "\"%s\" exists but is not a folder." % target_folder
    else:
        tgt_dir.mkdir()

# Clean out build directories
delete_below_folder("build")
delete_below_folder("dist")

# Add license to our distro
local.path("license.txt").copy("dist")

# Run py2exe
local.python("setup.py", "py2exe")

# Put everything in dist into a zip file
dist_dir = local.path('dist')
z = ZipFile(app_name + '.zip', 'w', compression=ZIP_DEFLATED)
for f in dist_dir.list():
    z.write(os.path.join('dist', f.basename),
            os.path.join(app_name, f.basename))
z.close()

# Clean out build directories again
delete_below_folder("build")
delete_below_folder("dist")