def test_pex_builder():
    # test w/ and w/o zipfile dists
    with nested(temporary_dir(), make_distribution("p1", zipped=True)) as (td, p1):
        write_pex(td, exe_main, dists=[p1])

        success_txt = os.path.join(td, "success.txt")
        PEX(td).run(args=[success_txt])
        assert os.path.exists(success_txt)
        with open(success_txt) as fp:
            assert fp.read() == "success"

    # test w/ and w/o zipfile dists
    with nested(temporary_dir(), temporary_dir(), make_distribution("p1", zipped=True)) as (td1, td2, p1):
        target_egg_dir = os.path.join(td2, os.path.basename(p1.location))
        safe_mkdir(target_egg_dir)
        with closing(zipfile.ZipFile(p1.location, "r")) as zf:
            zf.extractall(target_egg_dir)
        p1 = DistributionHelper.distribution_from_path(target_egg_dir)

        write_pex(td1, exe_main, dists=[p1])

        success_txt = os.path.join(td1, "success.txt")
        PEX(td1).run(args=[success_txt])
        assert os.path.exists(success_txt)
        with open(success_txt) as fp:
            assert fp.read() == "success"
示例#2
0
def test_pex_builder():
    # test w/ and w/o zipfile dists
    with nested(temporary_dir(), make_distribution('p1',
                                                   zipped=True)) as (td, p1):
        write_pex(td, exe_main, dists=[p1])

        success_txt = os.path.join(td, 'success.txt')
        PEX(td).run(args=[success_txt])
        assert os.path.exists(success_txt)
        with open(success_txt) as fp:
            assert fp.read() == 'success'

    # test w/ and w/o zipfile dists
    with nested(temporary_dir(), temporary_dir(),
                make_distribution('p1', zipped=True)) as (td1, td2, p1):
        target_egg_dir = os.path.join(td2, os.path.basename(p1.location))
        safe_mkdir(target_egg_dir)
        with closing(zipfile.ZipFile(p1.location, 'r')) as zf:
            zf.extractall(target_egg_dir)
        p1 = DistributionHelper.distribution_from_path(target_egg_dir)

        write_pex(td1, exe_main, dists=[p1])

        success_txt = os.path.join(td1, 'success.txt')
        PEX(td1).run(args=[success_txt])
        assert os.path.exists(success_txt)
        with open(success_txt) as fp:
            assert fp.read() == 'success'
示例#3
0
def yield_pex_builder(zip_safe=True):
  with nested(temporary_dir(), make_distribution('p1', zipped=True, zip_safe=zip_safe)) as (td, p1):
    pb = PEXBuilder(path=td)
    pb.add_egg(p1.location)
    yield pb
示例#4
0
def test_zipsafe():
  for zipped in (False, True):
    with make_distribution(zipped=zipped) as dist:
      assert DistributionHelper.zipsafe(dist)
示例#5
0
def test_zipsafe():
  for zipped in (False, True):
    with make_distribution(zipped=zipped) as dist:
      assert DistributionHelper.zipsafe(dist)