Skip to content

Merge Repositories #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
59c1ccc
Update pdm.lock
Behemyth Jun 15, 2023
f12cdb5
Updates
Behemyth Jun 19, 2023
39d10af
Steps
Behemyth Jun 19, 2023
ab9b73b
Update pyproject.toml
Behemyth Jun 27, 2023
b370893
Update pyproject.toml
Behemyth Jul 18, 2023
4cd84d5
Update Extensions Recs
Behemyth Aug 31, 2023
24a8e31
Builder Simplification
Behemyth Mar 13, 2024
f028bf5
Data Object
Behemyth Mar 13, 2024
86810a8
Add Builder and Data Tests
Behemyth Mar 13, 2024
e5e93eb
Resolver Object
Behemyth Mar 13, 2024
0151142
Update schema.py
Behemyth Mar 13, 2024
0a09ce0
Add Tests
Behemyth Mar 13, 2024
c2c5a17
Remove Scaffolding Function
Behemyth Mar 14, 2024
c02f5df
Implement Data And Builder Tests
Behemyth Mar 14, 2024
188b50d
Update pdm.lock
Behemyth Mar 14, 2024
2b93d6e
Comments
Behemyth Mar 14, 2024
794da47
Lotso Stuff
Behemyth Aug 17, 2024
6a7173f
Git
Behemyth Aug 17, 2024
45795a4
Cmake
Behemyth Aug 17, 2024
e9ebb4b
Other Plugins
Behemyth Aug 17, 2024
dd827fa
Fix License Metadata
Behemyth Oct 4, 2024
925f290
Increment Python Requirement
Behemyth Oct 7, 2024
00c597f
Update Chore
Behemyth Nov 6, 2024
6b37a9e
ja
Behemyth Nov 9, 2024
70055a2
Ouch
Behemyth Nov 9, 2024
36a5929
yaaa
Behemyth Nov 10, 2024
0a7f06e
Types
Behemyth Nov 10, 2024
eabe238
More Import and Type fixes
Behemyth Nov 10, 2024
8f9ea35
More Typing
Behemyth Nov 11, 2024
4c738fe
Import Fixes
Behemyth Nov 11, 2024
ce223d4
Final Type Checks
Behemyth Nov 11, 2024
7270bf5
Fix Lints
Behemyth Nov 11, 2024
72c6cd9
Alias Fix
Behemyth Nov 11, 2024
ac184d8
Ya
Behemyth Nov 11, 2024
cbcdd74
Move Plugin
Behemyth Nov 11, 2024
483ee50
Update pdm.lock
Behemyth Nov 14, 2024
24d681f
Fix Tests
Behemyth Nov 16, 2024
f7fb98f
Update pdm.lock
Behemyth Nov 16, 2024
23d05f8
Delete requirement.txt
Behemyth Nov 16, 2024
fbf1812
Skip Mocked Plugin Entrypoint Tests
Behemyth Nov 16, 2024
7cfac1e
Add Docs Folder
Behemyth Nov 17, 2024
199f05c
Yas
Behemyth Nov 17, 2024
7b69588
ya
Behemyth Nov 17, 2024
283f54e
Update pdm.lock
Behemyth Nov 18, 2024
74438bc
Update extensions.json
Behemyth Nov 18, 2024
025bd4b
Update Scripts
Behemyth Nov 18, 2024
dc041a3
Remove Playbook
Behemyth Nov 18, 2024
9c85e90
Init Fixture Documentation
Behemyth Nov 18, 2024
9deef9d
Update pdm.lock
Behemyth Nov 19, 2024
652f3f4
Remove Data Config
Behemyth Nov 20, 2024
7f86825
Delete CMakePresets.json
Behemyth Nov 20, 2024
e0f4a9d
Delete vcpkg.json
Behemyth Nov 20, 2024
745c9fb
Update plugin.py
Behemyth Nov 20, 2024
c055d30
Fix Path Overriding
Behemyth Nov 20, 2024
50f2fb7
Update utility.py
Behemyth Nov 20, 2024
1a6ecfe
Update test_project.py
Behemyth Nov 20, 2024
aac1417
DefaultSCM
Behemyth Nov 20, 2024
e26c5fe
Update builder.py
Behemyth Nov 20, 2024
e9d6325
Update shared.py
Behemyth Nov 20, 2024
a9d1667
Update test_project.py
Behemyth Nov 20, 2024
8133ae6
Update test_project.py
Behemyth Nov 20, 2024
b7ad0ea
Mock Entrypoints
Behemyth Nov 20, 2024
78d44f7
Remove Outdated Test
Behemyth Nov 20, 2024
6f0466f
Harness Module
Behemyth Nov 20, 2024
32254ba
Replace Interface
Behemyth Nov 20, 2024
83df4f1
Base Ruff Config
Behemyth Nov 20, 2024
31f464f
Fixing More Errors
Behemyth Nov 20, 2024
2b7807c
Finish Linting
Behemyth Nov 20, 2024
a04945d
Merge branch 'development' of https://github.com/Synodic-Software/CPP…
Behemyth Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ __pypackages__/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/extensions.json
/.mypy_cache
node_modules/
build/
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.black-formatter"
"ms-python.black-formatter",
"asciidoctor.asciidoctor-vscode",
"charliermarsh.ruff"
]
}
8 changes: 7 additions & 1 deletion cppython/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@

"""The CPPython project.

This module serves as the entry point for the CPPython project, a Python-based
solution for managing C++ dependencies. It includes core functionality, plugin
interfaces, and utility functions that facilitate the integration and management
of various tools and systems.
"""
100 changes: 46 additions & 54 deletions cppython/builder.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""Defines the data and routines for building a CPPython project type"""

import logging
from importlib import metadata
from importlib.metadata import entry_points
from inspect import getmodule
from logging import Logger
from typing import Any

from cppython_core.exceptions import PluginError
from cppython_core.plugin_schema.generator import Generator
from cppython_core.plugin_schema.provider import Provider
from cppython_core.plugin_schema.scm import SCM
from cppython_core.resolution import (
from cppython.core.plugin_schema.generator import Generator
from cppython.core.plugin_schema.provider import Provider
from cppython.core.plugin_schema.scm import SCM
from cppython.core.resolution import (
PluginBuildData,
PluginCPPythonData,
resolve_cppython,
Expand All @@ -21,7 +20,7 @@
resolve_provider,
resolve_scm,
)
from cppython_core.schema import (
from cppython.core.schema import (
CoreData,
CorePluginData,
CPPythonGlobalConfiguration,
Expand All @@ -32,15 +31,16 @@
ProjectConfiguration,
ProjectData,
)

from cppython.data import Data, Plugins
from cppython.defaults import DefaultSCM
from cppython.utility.exception import PluginError


class Resolver:
"""The resolution of data sources for the builder"""

def __init__(self, project_configuration: ProjectConfiguration, logger: Logger) -> None:

"""Initializes the resolver"""
self._project_configuration = project_configuration
self._logger = logger

Expand All @@ -56,19 +56,18 @@ def generate_plugins(
Returns:
The resolved plugin data
"""

raw_generator_plugins = self.find_generators()
generator_plugins = self.filter_plugins(
raw_generator_plugins,
cppython_local_configuration.generator_name,
"Generator",
'Generator',
)

raw_provider_plugins = self.find_providers()
provider_plugins = self.filter_plugins(
raw_provider_plugins,
cppython_local_configuration.provider_name,
"Provider",
'Provider',
)

scm_plugins = self.find_source_managers()
Expand All @@ -80,7 +79,8 @@ def generate_plugins(

return PluginBuildData(generator_type=generator_type, provider_type=provider_type, scm_type=scm_type)

def generate_cppython_plugin_data(self, plugin_build_data: PluginBuildData) -> PluginCPPythonData:
@staticmethod
def generate_cppython_plugin_data(plugin_build_data: PluginBuildData) -> PluginCPPythonData:
"""Generates the CPPython plugin data from the resolved plugins

Args:
Expand All @@ -89,15 +89,15 @@ def generate_cppython_plugin_data(self, plugin_build_data: PluginBuildData) -> P
Returns:
The plugin data used by CPPython
"""

return PluginCPPythonData(
generator_name=plugin_build_data.generator_type.name(),
provider_name=plugin_build_data.provider_type.name(),
scm_name=plugin_build_data.scm_type.name(),
)

@staticmethod
def generate_pep621_data(
self, pep621_configuration: PEP621Configuration, project_configuration: ProjectConfiguration, scm: SCM | None
pep621_configuration: PEP621Configuration, project_configuration: ProjectConfiguration, scm: SCM | None
) -> PEP621Data:
"""Generates the PEP621 data from configuration sources

Expand All @@ -111,13 +111,13 @@ def generate_pep621_data(
"""
return resolve_pep621(pep621_configuration, project_configuration, scm)

def resolve_global_config(self) -> CPPythonGlobalConfiguration:
@staticmethod
def resolve_global_config() -> CPPythonGlobalConfiguration:
"""Generates the global configuration object

Returns:
The global configuration object
"""

return CPPythonGlobalConfiguration()

def find_generators(self) -> list[type[Generator]]:
Expand All @@ -129,24 +129,23 @@ def find_generators(self) -> list[type[Generator]]:
Returns:
The list of generator plugin types
"""

group_name = "generator"
group_name = 'generator'
plugin_types: list[type[Generator]] = []

# Filter entries by type
for entry_point in list(metadata.entry_points(group=f"cppython.{group_name}")):
for entry_point in list(entry_points(group=f'cppython.{group_name}')):
loaded_type = entry_point.load()
if not issubclass(loaded_type, Generator):
self._logger.warning(
f"Found incompatible plugin. The '{loaded_type.name()}' plugin must be an instance of"
f" '{group_name}'"
)
else:
self._logger.warning(f"{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}")
self._logger.warning(f'{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}')
plugin_types.append(loaded_type)

if not plugin_types:
raise PluginError(f"No {group_name} plugin was found")
raise PluginError(f'No {group_name} plugin was found')

return plugin_types

Expand All @@ -159,24 +158,23 @@ def find_providers(self) -> list[type[Provider]]:
Returns:
The list of provider plugin types
"""

group_name = "provider"
group_name = 'provider'
plugin_types: list[type[Provider]] = []

# Filter entries by type
for entry_point in list(metadata.entry_points(group=f"cppython.{group_name}")):
for entry_point in list(entry_points(group=f'cppython.{group_name}')):
loaded_type = entry_point.load()
if not issubclass(loaded_type, Provider):
self._logger.warning(
f"Found incompatible plugin. The '{loaded_type.name()}' plugin must be an instance of"
f" '{group_name}'"
)
else:
self._logger.warning(f"{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}")
self._logger.warning(f'{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}')
plugin_types.append(loaded_type)

if not plugin_types:
raise PluginError(f"No {group_name} plugin was found")
raise PluginError(f'No {group_name} plugin was found')

return plugin_types

Expand All @@ -189,30 +187,29 @@ def find_source_managers(self) -> list[type[SCM]]:
Returns:
The list of source control manager plugin types
"""

group_name = "scm"
group_name = 'scm'
plugin_types: list[type[SCM]] = []

# Filter entries by type
for entry_point in list(metadata.entry_points(group=f"cppython.{group_name}")):
for entry_point in list(entry_points(group=f'cppython.{group_name}')):
loaded_type = entry_point.load()
if not issubclass(loaded_type, SCM):
self._logger.warning(
f"Found incompatible plugin. The '{loaded_type.name()}' plugin must be an instance of"
f" '{group_name}'"
)
else:
self._logger.warning(f"{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}")
self._logger.warning(f'{group_name} plugin found: {loaded_type.name()} from {getmodule(loaded_type)}')
plugin_types.append(loaded_type)

if not plugin_types:
raise PluginError(f"No {group_name} plugin was found")
raise PluginError(f'No {group_name} plugin was found')

return plugin_types

def filter_plugins[
T: DataPlugin
](self, plugin_types: list[type[T]], pinned_name: str | None, group_name: str) -> list[type[T]]:
def filter_plugins[T: DataPlugin](
self, plugin_types: list[type[T]], pinned_name: str | None, group_name: str
) -> list[type[T]]:
"""Finds and filters data plugins

Args:
Expand All @@ -226,13 +223,12 @@ def filter_plugins[
Returns:
The list of applicable plugins
"""

# Lookup the requested plugin if given
if pinned_name is not None:
for loaded_type in plugin_types:
if loaded_type.name() == pinned_name:
self._logger.warning(
f"Using {group_name} plugin: {loaded_type.name()} from {getmodule(loaded_type)}"
f'Using {group_name} plugin: {loaded_type.name()} from {getmodule(loaded_type)}'
)
return [loaded_type]

Expand All @@ -243,13 +239,13 @@ def filter_plugins[
# Deduce types
for loaded_type in plugin_types:
self._logger.warning(
f"A {group_name} plugin is supported: {loaded_type.name()} from {getmodule(loaded_type)}"
f'A {group_name} plugin is supported: {loaded_type.name()} from {getmodule(loaded_type)}'
)
supported_types.append(loaded_type)

# Fail
if supported_types is None:
raise PluginError(f"No {group_name} could be deduced from the root directory.")
raise PluginError(f'No {group_name} could be deduced from the root directory.')

return supported_types

Expand All @@ -260,21 +256,20 @@ def select_scm(self, scm_plugins: list[type[SCM]], project_data: ProjectData) ->
scm_plugins: The list of SCM plugin types
project_data: The project data

Raises:
PluginError: Raised if no SCM plugin was found that supports the given data

Returns:
The selected SCM plugin type
"""

for scm_type in scm_plugins:
if scm_type.features(project_data.pyproject_file.parent).repository:
return scm_type

raise PluginError("No SCM plugin was found that supports the given path")
self._logger.info('No SCM plugin was found that supports the given path')

return DefaultSCM

@staticmethod
def solve(
self, generator_types: list[type[Generator]], provider_types: list[type[Provider]]
generator_types: list[type[Generator]], provider_types: list[type[Provider]]
) -> tuple[type[Generator], type[Provider]]:
"""Selects the first generator and provider that can work together

Expand All @@ -288,7 +283,6 @@ def solve(
Returns:
A tuple of the selected generator and provider plugin types
"""

combos: list[tuple[type[Generator], type[Provider]]] = []

for generator_type in generator_types:
Expand All @@ -300,12 +294,12 @@ def solve(
break

if not combos:
raise PluginError("No provider that supports a given generator could be deduced")
raise PluginError('No provider that supports a given generator could be deduced')

return combos[0]

@staticmethod
def create_scm(
self,
core_data: CoreData,
scm_type: type[SCM],
) -> SCM:
Expand All @@ -318,7 +312,6 @@ def create_scm(
Returns:
The constructed source control manager
"""

cppython_plugin_data = resolve_cppython_plugin(core_data.cppython_data, scm_type)
scm_data = resolve_scm(core_data.project_data, cppython_plugin_data)

Expand All @@ -344,7 +337,6 @@ def create_generator(
Returns:
The constructed generator
"""

cppython_plugin_data = resolve_cppython_plugin(core_data.cppython_data, generator_type)

generator_data = resolve_generator(core_data.project_data, cppython_plugin_data)
Expand Down Expand Up @@ -380,7 +372,6 @@ def create_provider(
Returns:
A constructed provider plugins
"""

cppython_plugin_data = resolve_cppython_plugin(core_data.cppython_data, provider_type)

provider_data = resolve_provider(core_data.project_data, cppython_plugin_data)
Expand All @@ -403,6 +394,7 @@ class Builder:
"""Helper class for building CPPython projects"""

def __init__(self, project_configuration: ProjectConfiguration, logger: Logger) -> None:
"""Initializes the builder"""
self._project_configuration = project_configuration
self._logger = logger

Expand All @@ -413,7 +405,7 @@ def __init__(self, project_configuration: ProjectConfiguration, logger: Logger)
self._logger.addHandler(logging.StreamHandler())
self._logger.setLevel(levels[project_configuration.verbosity])

self._logger.info("Logging setup complete")
self._logger.info('Logging setup complete')

self._resolver = Resolver(self._project_configuration, self._logger)

Expand All @@ -428,12 +420,12 @@ def build(
Args:
pep621_configuration: The PEP621 configuration
cppython_local_configuration: The local configuration
plugin_build_data: Plugin override data. If it exists, the build will use the given types instead of resolving them
plugin_build_data: Plugin override data. If it exists, the build will use the given types
instead of resolving them

Returns:
The built data object
"""

project_data = resolve_project_configuration(self._project_configuration)

if plugin_build_data is None:
Expand Down
7 changes: 6 additions & 1 deletion cppython/console/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

"""Console interface for the CPPython project.

This module provides a command-line interface (CLI) for interacting with the
CPPython project. It includes commands for managing project configurations,
installing dependencies, and updating project data.
"""
Loading
Loading