Exemple #1
0
 def build_egg_info(self, out_dir: str) -> str:
     # Ignore destination since editable builds should be build locally
     builder = Builder(self.src_dir)
     setup_py_path = builder.ensure_setup_py().as_posix()
     self.install(["setuptools"])
     args = [self.executable, "-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
     args.extend(["egg_info", "--egg-base", out_dir])
     self.subprocess_runner(args, cwd=self.src_dir)
     filename = _find_egg_info(out_dir)
     return os.path.join(out_dir, filename)
Exemple #2
0
    def ensure_setup_py(self) -> str:
        from pdm.pep517.base import Builder
        from pdm.project.metadata import MutableMetadata

        builder = Builder(self.src_dir)
        if os.path.exists(os.path.join(self.src_dir, "pyproject.toml")):
            try:
                builder._meta = MutableMetadata(
                    os.path.join(self.src_dir, "pyproject.toml"))
            except ValueError:
                builder._meta = None
        return builder.ensure_setup_py().as_posix()
def test_merge_includes_and_excludes(monkeypatch, includes, excludes,
                                     data_a_exist, data_b_exist):
    builder = Builder(FIXTURES / "projects/demo-package-with-deep-path")
    data_a, data_b = Path("my_package/data/data_a.json"), Path(
        "my_package/data/data_inner/data_b.json")
    with builder:
        monkeypatch.setattr(Metadata, "source_includes", [])
        monkeypatch.setattr(Metadata, "includes", includes)
        monkeypatch.setattr(Metadata, "excludes", excludes)
        include_files = builder.find_files_to_add()
        assert (data_a in include_files) == data_a_exist
        assert (data_b in include_files) == data_b_exist
Exemple #4
0
def test_auto_include_tests_for_sdist():
    builder = Builder(FIXTURES / "projects/demo-package-with-tests")
    with utils.cd(builder.location):
        sdist_files = builder.find_files_to_add(True)
        wheel_files = builder.find_files_to_add(False)

    sdist_only_files = ("tests/__init__.py", "LICENSE", "pyproject.toml")
    include_files = ("my_package/__init__.py", )
    for file in include_files:
        path = Path(file)
        assert path in sdist_files
        assert path in wheel_files

    for file in sdist_only_files:
        path = Path(file)
        assert path in sdist_files
        assert path not in wheel_files
Exemple #5
0
    def build_egg_info(self, out_dir: str) -> str:
        # Ignore destination since editable builds should be build locally
        from pdm.project.metadata import MutableMetadata

        builder = Builder(self.src_dir)
        if os.path.exists(os.path.join(self.src_dir, "pyproject.toml")):
            builder._meta = MutableMetadata(
                os.path.join(self.src_dir, "pyproject.toml"))
        setup_py_path = builder.ensure_setup_py().as_posix()
        self.install(["setuptools"])
        args = [self.executable, "-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
        args.extend(
            ["egg_info", "--egg-base",
             os.path.relpath(out_dir, self.src_dir)])
        self.subprocess_runner(args, cwd=self.src_dir)
        filename = _find_egg_info(out_dir)
        return os.path.join(out_dir, filename)
def test_recursive_glob_patterns_in_includes() -> None:
    builder = Builder(FIXTURES / "projects/demo-package-with-deep-path")
    with builder:
        sdist_files = builder.find_files_to_add(True)
        wheel_files = builder.find_files_to_add(False)

    data_files = (
        "my_package/data/data_a.json",
        "my_package/data/data_inner/data_b.json",
    )

    assert Path("my_package/__init__.py") in sdist_files
    assert Path("my_package/__init__.py") in wheel_files

    for file in data_files:
        path = Path(file)
        assert path in sdist_files
        assert path not in wheel_files
Exemple #7
0
    def build(self,
              out_dir: str,
              config_settings: Optional[Mapping[str, Any]] = None) -> str:
        from pdm.pep517.base import Builder
        from pdm.project.metadata import MutableMetadata

        builder = Builder(self.src_dir)
        if os.path.exists(os.path.join(self.src_dir, "pyproject.toml")):
            builder._meta = MutableMetadata(
                os.path.join(self.src_dir, "pyproject.toml"))
        setup_py_path = builder.ensure_setup_py().as_posix()
        self.install(["setuptools"])
        args = [self.executable, "-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
        args.extend(
            ["egg_info", "--egg-base",
             os.path.relpath(out_dir, self.src_dir)])
        self.subprocess_runner(args, cwd=self.src_dir)
        filename = self._find_egg_info(out_dir)
        return os.path.join(out_dir, filename)
Exemple #8
0
def _prepare_metadata(builder: Builder, metadata_directory: str) -> str:
    dist_info = Path(metadata_directory, builder.dist_info_name)
    dist_info.mkdir(exist_ok=True)
    if builder.meta.entry_points:
        with (dist_info / "entry_points.txt").open("w", encoding="utf-8") as f:
            builder._write_entry_points(f)

    with (dist_info / "WHEEL").open("w", encoding="utf-8") as f:
        builder._write_wheel_file(f)

    with (dist_info / "METADATA").open("w", encoding="utf-8") as f:
        builder._write_metadata_file(f)

    return dist_info.name
Exemple #9
0
def export(project: Project, candidates: List, options: Optional[Any]) -> str:
    from pdm.pep517.base import Builder

    builder = Builder(project.root)
    return builder.format_setup_py()
Exemple #10
0
def export(project, candidates, options):
    from pdm.pep517.base import Builder

    builder = Builder(project.root)
    return builder.format_setup_py()