示例#1
0
def test_build_single_module_with_readme(fixture_project):
    project = fixture_project("demo-module")
    project.meta["readme"] = "README.md"
    project.write_pyproject()
    actions.do_build(project)
    assert "demo-module-0.1.0/README.md" in get_tarball_names(
        project.root / "dist/demo-module-0.1.0.tar.gz")
示例#2
0
def test_build_distributions(tmp_path, core):
    project = core.create_project()
    actions.do_build(project, dest=tmp_path.as_posix())
    wheel = Wheel(next(tmp_path.glob("*.whl")).as_posix())
    assert wheel.name == "pdm"
    tarball = next(tmp_path.glob("*.tar.gz"))
    assert tarball.exists()
示例#3
0
def test_build_single_module(fixture_project):
    project = fixture_project("demo-module")
    assert project.meta.version == "0.1.0"

    actions.do_build(project)
    tar_names = get_tarball_names(project.root /
                                  "dist/demo-module-0.1.0.tar.gz")
    for name in [
            "foo_module.py",
            "bar_module.py",
            "LICENSE",
            "pyproject.toml",
            "PKG-INFO",
    ]:
        assert f"demo-module-0.1.0/{name}" in tar_names

    zip_names = get_wheel_names(project.root /
                                "dist/demo_module-0.1.0-py3-none-any.whl")
    for name in ["foo_module.py", "bar_module.py"]:
        assert name in zip_names

    for name in ("pyproject.toml", "LICENSE"):
        assert name not in zip_names

    assert Wheel(
        (project.root /
         "dist/demo_module-0.1.0-py3-none-any.whl").as_posix()).metadata
示例#4
0
def test_build_src_package(fixture_project):
    project = fixture_project("demo-src-package")
    actions.do_build(project)

    tar_names = get_tarball_names(project.root /
                                  "dist/demo-package-0.1.0.tar.gz")
    assert "demo-package-0.1.0/src/my_package/__init__.py" in tar_names
    assert "demo-package-0.1.0/src/my_package/data.json" in tar_names

    zip_names = get_wheel_names(project.root /
                                "dist/demo_package-0.1.0-py3-none-any.whl")
    assert "my_package/__init__.py" in zip_names
    assert "my_package/data.json" in zip_names
示例#5
0
文件: build.py 项目: danieleades/pdm
 def handle(self, project: Project, options: argparse.Namespace) -> None:
     config_settings = None
     if options.config_setting:
         config_settings = {}
         for item in options.config_setting:
             name, _, value = item.partition("=")
             if name not in config_settings:
                 config_settings[name] = value
             else:
                 if not isinstance(config_settings[name], list):
                     config_settings[name] = [config_settings[name]]
                 config_settings[name].append(value)
     actions.do_build(
         project,
         sdist=options.sdist,
         wheel=options.wheel,
         dest=options.dest,
         clean=options.clean,
         config_settings=config_settings,
     )
示例#6
0
def test_build_package_include(fixture_project):
    project = fixture_project("demo-package")
    project.tool_settings["includes"] = [
        "my_package/",
        "single_module.py",
        "data_out.json",
    ]
    project.tool_settings["excludes"] = ["my_package/*.json"]
    project.write_pyproject()
    actions.do_build(project)

    tar_names = get_tarball_names(project.root /
                                  "dist/demo-package-0.1.0.tar.gz")
    assert "demo-package-0.1.0/my_package/__init__.py" in tar_names
    assert "demo-package-0.1.0/my_package/data.json" not in tar_names
    assert "demo-package-0.1.0/single_module.py" in tar_names
    assert "demo-package-0.1.0/data_out.json" in tar_names

    zip_names = get_wheel_names(project.root /
                                "dist/demo_package-0.1.0-py3-none-any.whl")
    assert "my_package/__init__.py" in zip_names
    assert "my_package/data.json" not in zip_names
    assert "single_module.py" in zip_names
    assert "data_out.json" in zip_names
示例#7
0
def build(project, sdist, wheel, dest, clean):
    actions.do_build(project, sdist, wheel, dest, clean)
示例#8
0
def test_build_ignoring_pip_environment(fixture_project):
    project = fixture_project("demo-module")
    os.environ["PIP_REQUIRE_VIRTUALENV"] = "1"
    actions.do_build(project)
示例#9
0
def test_build_with_config_settings(fixture_project):
    project = fixture_project("demo-src-package")
    actions.do_build(project, config_settings={"--plat-name": "win_amd64"})

    assert (project.root / "dist/demo_package-0.1.0-py3-none-win_amd64.whl").exists()
示例#10
0
文件: build.py 项目: uranusjr/pdm
 def handle(self, project: Project, options: argparse.Namespace) -> None:
     actions.do_build(project, options.sdist, options.wheel, options.dest,
                      options.clean)