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")
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()
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
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
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, )
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
def build(project, sdist, wheel, dest, clean): actions.do_build(project, sdist, wheel, dest, clean)
def test_build_ignoring_pip_environment(fixture_project): project = fixture_project("demo-module") os.environ["PIP_REQUIRE_VIRTUALENV"] = "1" actions.do_build(project)
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()
def handle(self, project: Project, options: argparse.Namespace) -> None: actions.do_build(project, options.sdist, options.wheel, options.dest, options.clean)