Esempio n. 1
0
def test_dist_name(copy_sample):
    td = copy_sample('altdistname')
    make_wheel_in(td / 'pyproject.toml', td)
    res = td / 'package_dist1-0.1-py2.py3-none-any.whl'
    assert_isfile(res)
    with unpack(res) as td_unpack:
        assert_isdir(Path(td_unpack, 'package_dist1-0.1.dist-info'))
Esempio n. 2
0
def test_dist_name(copy_sample):
    td = copy_sample('altdistname')
    wheel_main(td / 'flit.ini')
    res = td / 'dist/package_dist1-0.1-py2.py3-none-any.whl'
    assert_isfile(res)
    with unpack(res) as td_unpack:
        assert_isdir(Path(td_unpack, 'package_dist1-0.1.dist-info'))
Esempio n. 3
0
 def test_install_package(self):
     Installer(samples_dir / 'package1' / 'flit.ini').install_directly()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'package1-0.1.dist-info')
     assert_isfile(self.tmpdir / 'scripts' / 'pkg_script')
     with (self.tmpdir / 'scripts' / 'pkg_script').open() as f:
         assert f.readline().strip() == "#!" + sys.executable
Esempio n. 4
0
def test_console_example():
    responses.add_callback(
        'GET',
        re.compile(r'https://www.python.org/ftp/.*'),
        callback=respond_python_zip,
        content_type='application/zip',
    )

    with TemporaryWorkingDirectory() as td:
        for src in example_dir.iterdir():
            copy(str(src), td)


        with modified_env({CACHE_ENV_VAR: td}), \
             MockCommand('makensis') as makensis:
            ec = main(['installer.cfg'])

        assert ec == 0
        assert makensis.get_calls()[0]['argv'][1].endswith('installer.nsi')

        build_dir = Path(td, 'build', 'nsis')
        assert_isdir(build_dir)
        assert_isfile(build_dir / 'Python' / 'python.exe')
        assert_isfile(build_dir / 'pkgs' / 'guessnumber.py')
        assert_isfile(build_dir / 'Guess_the_Number.launch.py')
Esempio n. 5
0
def test_dist_name():
    clear_samples_dist()
    wheel_main(samples_dir / 'altdistname.ini')
    res = samples_dir / 'dist/package_dist1-0.1-py2.py3-none-any.whl'
    assert_isfile(res)
    with unpack(res) as td:
        assert_isdir(Path(td, 'package_dist1-0.1.dist-info'))
Esempio n. 6
0
def test_copy_from_zipfile(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['zippedmod2', 'zippedpkg2'],
                 tmpdir, running_python, sample_path)
#        assert_isfile(pjoin(tmpdir, 'zippedmod.py'))
#        assert_isdir(pjoin(tmpdir, 'zippedpkg'))
    assert_isfile(pjoin(tmpdir, 'zippedmod2.py'))
    assert_isdir(pjoin(tmpdir, 'zippedpkg2'))
Esempio n. 7
0
def test_copy_from_zipfile(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['zippedmod2', 'zippedpkg2'], tmpdir, running_python,
                 sample_path)
    #        assert_isfile(pjoin(tmpdir, 'zippedmod.py'))
    #        assert_isdir(pjoin(tmpdir, 'zippedpkg'))
    assert_isfile(pjoin(tmpdir, 'zippedmod2.py'))
    assert_isdir(pjoin(tmpdir, 'zippedpkg2'))
Esempio n. 8
0
 def test_install_module(self):
     Installer.from_ini_path(samples_dir / 'module1_toml' /
                             'pyproject.toml').install_directly()
     assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
     assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.1.dist-info')
     self._assert_direct_url(samples_dir / 'module1_toml',
                             'module1',
                             '0.1',
                             expected_editable=False)
Esempio n. 9
0
def test_editable_wheel_src_module(copy_sample):
    td = copy_sample('module3')
    make_wheel_in(td / 'pyproject.toml', td, editable=True)
    whl_file = td / 'module3-0.1-py2.py3-none-any.whl'
    assert_isfile(whl_file)
    with unpack(whl_file) as unpacked:
        pth_path = Path(unpacked, 'module3.pth')
        assert_isfile(pth_path)
        assert pth_path.read_text() == str(td / "src")
        assert_isdir(Path(unpacked, 'module3-0.1.dist-info'))
Esempio n. 10
0
 def test_install_module_pep621(self):
     Installer.from_ini_path(
         core_samples_dir / 'pep621_nodynamic' /
         'pyproject.toml', ).install_directly()
     assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
     assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.3.dist-info')
     self._assert_direct_url(core_samples_dir / 'pep621_nodynamic',
                             'module1',
                             '0.3',
                             expected_editable=False)
Esempio n. 11
0
def test_wheel_src_module(copy_sample):
    td = copy_sample('module3')
    wheel_main(td / 'flit.ini')

    whl_file = td / 'dist/module3-0.1-py2.py3-none-any.whl'
    assert_isfile(whl_file)
    with unpack(whl_file) as unpacked:
        assert_isfile(Path(unpacked, 'module3.py'))
        assert_isdir(Path(unpacked, 'module3-0.1.dist-info'))
        assert_isfile(Path(unpacked, 'module3-0.1.dist-info', 'LICENSE'))
Esempio n. 12
0
def test_wheel_src_module(copy_sample):
    td = copy_sample('module3')
    make_wheel_in(td / 'pyproject.toml', td)

    whl_file = td / 'module3-0.1-py2.py3-none-any.whl'
    assert_isfile(whl_file)
    with unpack(whl_file) as unpacked:
        assert_isfile(Path(unpacked, 'module3.py'))
        assert_isdir(Path(unpacked, 'module3-0.1.dist-info'))
        assert_isfile(Path(unpacked, 'module3-0.1.dist-info', 'LICENSE'))
Esempio n. 13
0
def test_wheel_module_local_version(copy_sample):
    """Test if a local version specifier is preserved in wheel filename and dist-info dir name"""
    td = copy_sample('modulewithlocalversion')
    make_wheel_in(td / 'pyproject.toml', td)

    whl_file = td / 'modulewithlocalversion-0.1.dev0+test-py2.py3-none-any.whl'
    assert_isfile(whl_file)
    with unpack(whl_file) as unpacked:
        assert_isfile(Path(unpacked, 'modulewithlocalversion.py'))
        assert_isdir(
            Path(unpacked, 'modulewithlocalversion-0.1.dev0+test.dist-info'))
Esempio n. 14
0
def test_build_main(copy_sample):
    td = copy_sample('module1_toml')
    shutil.copy(str(samples_dir / 'EG_README.rst'), str(td))
    (td / '.git').mkdir()   # Fake a git repo

    with MockCommand('git', LIST_FILES_TEMPLATE.format(
            python=sys.executable, module='module1.py')):
        res = build.main(td / 'pyproject.toml')
    assert res.wheel.file.suffix == '.whl'
    assert res.sdist.file.name.endswith('.tar.gz')

    assert_isdir(td / 'dist')
Esempio n. 15
0
 def test_symlink_module_pep621(self):
     if os.name == 'nt':
         raise SkipTest("symlink")
     Installer.from_ini_path(core_samples_dir / 'pep621_nodynamic' /
                             'pyproject.toml',
                             symlink=True).install_directly()
     assert_islink(self.tmpdir / 'site-packages' / 'module1.py',
                   to=core_samples_dir / 'pep621_nodynamic' / 'module1.py')
     assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.3.dist-info')
     self._assert_direct_url(core_samples_dir / 'pep621_nodynamic',
                             'module1',
                             '0.3',
                             expected_editable=True)
Esempio n. 16
0
def test_matching_one_pattern(tmpdir):
    td1 = str(tmpdir.mkdir('wheels'))
    td2 = str(tmpdir.mkdir('pkgs'))

    subprocess.call(['pip', 'wheel', 'requests==2.19.1', '-w', str(td1)])

    wg = WheelGetter([], [os.path.join(td1, '*.whl')], td2, platform.python_version(), 64)
    wg.get_globs()

    assert_isdir(os.path.join(td2, 'requests'))
    assert_isfile(os.path.join(td2, 'requests-2.19.1.dist-info', 'METADATA'))

    assert_isdir(os.path.join(td2, 'urllib3'))
    assert glob.glob(os.path.join(td2, 'urllib3*.dist-info'))
Esempio n. 17
0
def test_build_main():
    with TemporaryDirectory() as td:
        pyproject = Path(td, 'pyproject.toml')
        shutil.copy(str(samples_dir / 'module1-pkg.toml'), str(pyproject))
        shutil.copy(str(samples_dir / 'module1.py'), td)
        shutil.copy(str(samples_dir / 'EG_README.rst'), td)
        Path(td, '.git').mkdir()  # Fake a git repo

        with MockCommand('git', LIST_FILES):
            res = build.main(pyproject)
        assert res.wheel.file.suffix == '.whl'
        assert res.sdist.file.name.endswith('.tar.gz')

        assert_isdir(Path(td, 'dist'))
Esempio n. 18
0
def test_editable_wheel_has_absolute_pth(copy_sample):
    td = copy_sample('module1_toml')
    oldcwd = os.getcwd()
    os.chdir(str(td))
    try:
        make_wheel_in(Path('pyproject.toml'), Path('.'), editable=True)
        whl_file = 'module1-0.1-py2.py3-none-any.whl'
        assert_isfile(whl_file)
        with unpack(whl_file) as unpacked:
            pth_path = Path(unpacked, 'module1.pth')
            assert_isfile(pth_path)
            assert Path(pth_path.read_text()).is_absolute()
            assert pth_path.read_text() == str(td.resolve())
            assert_isdir(Path(unpacked, 'module1-0.1.dist-info'))
    finally:
        os.chdir(oldcwd)
Esempio n. 19
0
 def test_install_package(self):
     oldcwd = os.getcwd()
     os.chdir(str(samples_dir / 'package1'))
     try:
         Installer.from_ini_path(
             pathlib.Path('pyproject.toml')).install_directly()
     finally:
         os.chdir(oldcwd)
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'package1-0.1.dist-info')
     assert_isfile(self.tmpdir / 'scripts' / 'pkg_script')
     with (self.tmpdir / 'scripts' / 'pkg_script').open() as f:
         assert f.readline().strip() == "#!" + sys.executable
     self._assert_direct_url(samples_dir / 'package1',
                             'package1',
                             '0.1',
                             expected_editable=False)
Esempio n. 20
0
def test_get_ipython_cache_dir():
    with modified_env({'HOME': HOME_TEST_DIR}):
        if os.name == "posix":
            # test default
            os.makedirs(os.path.join(HOME_TEST_DIR, ".cache"))
            with modified_env({'XDG_CACHE_HOME': None}):
                ipdir = paths.get_ipython_cache_dir()
            assert os.path.join(HOME_TEST_DIR, ".cache", "ipython") == ipdir
            assert_isdir(ipdir)

            # test env override
            with modified_env({"XDG_CACHE_HOME": XDG_CACHE_DIR}):
                ipdir = paths.get_ipython_cache_dir()
            assert_isdir(ipdir)
            assert ipdir == os.path.join(XDG_CACHE_DIR, "ipython")
        else:
            assert paths.get_ipython_cache_dir() == paths.get_ipython_dir()
Esempio n. 21
0
def test_get_ipython_cache_dir():
    with modified_env({'HOME': HOME_TEST_DIR}):
        if os.name == 'posix' and sys.platform != 'darwin':
            # test default
            os.makedirs(os.path.join(HOME_TEST_DIR, ".cache"))
            with modified_env({'XDG_CACHE_HOME': None}):
                ipdir = paths.get_ipython_cache_dir()
            nt.assert_equal(os.path.join(HOME_TEST_DIR, ".cache", "ipython"),
                            ipdir)
            assert_isdir(ipdir)

            # test env override
            with modified_env({"XDG_CACHE_HOME": XDG_CACHE_DIR}):
                ipdir = paths.get_ipython_cache_dir()
            assert_isdir(ipdir)
            nt.assert_equal(ipdir, os.path.join(XDG_CACHE_DIR, "ipython"))
        else:
            nt.assert_equal(paths.get_ipython_cache_dir(),
                            paths.get_ipython_dir())
Esempio n. 22
0
def test_get_ipython_cache_dir():
    with modified_env({'HOME': HOME_TEST_DIR}):
        if os.name == 'posix' and sys.platform != 'darwin':
            # test default
            os.makedirs(os.path.join(HOME_TEST_DIR, ".cache"))
            with modified_env({'XDG_CACHE_HOME': None}):
                ipdir = paths.get_ipython_cache_dir()
            nt.assert_equal(os.path.join(HOME_TEST_DIR, ".cache", "ipython"),
                            ipdir)
            assert_isdir(ipdir)

            # test env override
            with modified_env({"XDG_CACHE_HOME": XDG_CACHE_DIR}):
                ipdir = paths.get_ipython_cache_dir()
            assert_isdir(ipdir)
            nt.assert_equal(ipdir, os.path.join(XDG_CACHE_DIR, "ipython"))
        else:
            nt.assert_equal(paths.get_ipython_cache_dir(),
                            paths.get_ipython_dir())
Esempio n. 23
0
def test_console_example():
    responses.add_callback('GET', re.compile(r'https://www.python.org/ftp/.*'),
        callback=respond_python_zip, content_type='application/zip',
    )

    with TemporaryWorkingDirectory() as td:
        for src in example_dir.iterdir():
            copy(str(src), td)


        with modified_env({CACHE_ENV_VAR: td}), \
             MockCommand('makensis') as makensis:
            ec = main(['installer.cfg'])

        assert ec == 0
        assert makensis.get_calls()[0]['argv'][1].endswith('installer.nsi')

        build_dir = Path(td, 'build', 'nsis')
        assert_isdir(build_dir)
        assert_isfile(build_dir / 'Python' / 'python.exe')
        assert_isfile(build_dir / 'pkgs' / 'guessnumber.py')
        assert_isfile(build_dir / 'Guess_the_Number.launch.py')
Esempio n. 24
0
def test_console_example(tmp_path, console_eg_copy, monkeypatch):
    responses.add_callback(
        'GET',
        re.compile(r'https://www.python.org/ftp/.*'),
        callback=respond_python_zip,
        content_type='application/zip',
    )

    monkeypatch.chdir(console_eg_copy)
    monkeypatch.setenv(CACHE_ENV_VAR, str(tmp_path / 'cache'))

    with MockCommand('makensis') as makensis:
        ec = main(['installer.cfg'])

    assert ec == 0
    assert makensis.get_calls()[0]['argv'][1].endswith('installer.nsi')

    build_dir = console_eg_copy / 'build' / 'nsis'
    assert_isdir(build_dir)
    assert_isfile(build_dir / 'Python' / 'python.exe')
    assert_isfile(build_dir / 'pkgs' / 'sample_printer' / '__init__.py')
    assert_isfile(build_dir / 'Sample_printer.launch.py')
Esempio n. 25
0
 def test_remove_appdir(self):
     testpath.assert_isdir(self.appdir)
     self.uninstaller.remove_appdir()
     testpath.assert_not_path_exists(self.appdir)
Esempio n. 26
0
def test_copy_plain(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['plainmod', 'plainpkg'], tmpdir, '3.3.5', sample_path)
    assert_isfile(pjoin(tmpdir, 'plainmod.py'))
    assert_isdir(pjoin(tmpdir, 'plainpkg'))
Esempio n. 27
0
def test_prepare_metadata_for_build_wheel():
    with TemporaryDirectory() as td, cwd(osp.join(samples_dir, 'pep517')):
        dirname = buildapi.prepare_metadata_for_build_wheel(td)
        assert dirname.endswith('.dist-info'), dirname
        assert_isdir(osp.join(td, dirname))
        assert_isfile(osp.join(td, dirname, 'METADATA'))
Esempio n. 28
0
def test_copy_windows(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['win_extmod', 'win_extpkg'], tmpdir, running_python, sample_path)
    assert_isfile(pjoin(tmpdir, 'win_extmod.pyd'))
    assert_isdir(pjoin(tmpdir, 'win_extpkg'))
Esempio n. 29
0
 def test_dist_name(self):
     Installer(samples_dir / 'altdistname.ini').install()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'packagedist1-0.1.dist-info')
Esempio n. 30
0
 def test_install_package(self):
     Installer(samples_dir / 'package1-pkg.ini').install_directly()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'package1-0.1.dist-info')
     assert_isfile(self.tmpdir / 'scripts' / 'pkg_script')
Esempio n. 31
0
 def test_install_package(self):
     Installer(samples_dir / 'package1-pkg.ini').install()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'package1-0.1.dist-info')
     assert_isfile(self.tmpdir / 'scripts' / 'pkg_script')
Esempio n. 32
0
 def test_install_module(self):
     Installer(samples_dir / 'module1-pkg.ini').install()
     assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
     assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.1.dist-info')
Esempio n. 33
0
def test_get_ipython_package_dir():
    ipdir = paths.get_ipython_package_dir()
    assert_isdir(ipdir)
Esempio n. 34
0
def test_copy_plain(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['plainmod', 'plainpkg'], tmpdir, '3.3.5', sample_path)
    assert_isfile(pjoin(tmpdir, 'plainmod.py'))
    assert_isdir(pjoin(tmpdir, 'plainpkg'))
Esempio n. 35
0
def test_get_ipython_package_dir():
    ipdir = paths.get_ipython_package_dir()
    assert_isdir(ipdir)
Esempio n. 36
0
def test_copy_windows(tmpdir):
    tmpdir = str(tmpdir)
    copy_modules(['win_extmod', 'win_extpkg'], tmpdir, running_python,
                 sample_path)
    assert_isfile(pjoin(tmpdir, 'win_extmod.pyd'))
    assert_isdir(pjoin(tmpdir, 'win_extpkg'))
Esempio n. 37
0
 def test_install_module(self):
     Installer(samples_dir / 'module1' / 'flit.ini').install_directly()
     assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
     assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.1.dist-info')
Esempio n. 38
0
 def test_copy_application(self):
     self.installer.copy_application()
     d = pjoin(self.td, 'installed-applications', 'sampleapp')
     testpath.assert_isdir(d)
     testpath.assert_isfile(pjoin(d, 'run.sh'))
Esempio n. 39
0
 def test_dist_name(self):
     Installer(samples_dir / 'altdistname' / 'flit.ini').install_directly()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' / 'package_dist1-0.1.dist-info')
Esempio n. 40
0
 def test_dist_name(self):
     Installer.from_ini_path(samples_dir / 'altdistname' /
                             'pyproject.toml').install_directly()
     assert_isdir(self.tmpdir / 'site-packages' / 'package1')
     assert_isdir(self.tmpdir / 'site-packages' /
                  'package_dist1-0.1.dist-info')