Ejemplo n.º 1
0
 def meta(self) -> Metadata:
     if not self.pyproject:
         self.pyproject = {"project": tomlkit.table()}
     m = Metadata(self.pyproject_file, False)
     m._metadata = self.pyproject.get("project", {})
     m._tool_settings = self.tool_settings
     return m
Ejemplo n.º 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()
Ejemplo n.º 3
0
    def read_pyproject_toml(file: Path) -> Setup:
        from pdm.project.metadata import MutableMetadata

        try:
            metadata = MutableMetadata(file)
        except ValueError:
            return Setup()
        return Setup(
            name=metadata.name,
            version=metadata.version,
            install_requires=metadata.dependencies or [],
            extras_require=metadata.optional_dependencies or {},
            python_requires=metadata.requires_python,
        )
Ejemplo n.º 4
0
    def read_pyproject_toml(self, filepath):
        from pdm.project.metadata import MutableMetadata

        try:
            metadata = MutableMetadata(filepath)
        except ValueError:
            return {}
        return {
            "name": metadata.name,
            "version": metadata.version,
            "install_requires": metadata.dependencies,
            "extras_require": metadata.optional_dependencies,
            "python_requires": metadata.requires_python,
        }
Ejemplo n.º 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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 def meta(self) -> Metadata:
     if not self.pyproject:
         self.pyproject = {"project": atoml.table()}
     m = Metadata(self.pyproject_file, self.pyproject.get("project", {}))
     m._metadata = self.pyproject.get("project", {})
     return m