Skip to content

Commit c9a47a3

Browse files
authored
Skip_Upload (#119)
1 parent adcc1d1 commit c9a47a3

File tree

12 files changed

+132
-71
lines changed

12 files changed

+132
-71
lines changed

cppython/plugins/conan/plugin.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _install_dependencies(self, *, update: bool = False) -> None:
7777
If False, use cached versions when available.
7878
"""
7979
operation = 'update' if update else 'install'
80-
80+
8181
try:
8282
# Setup environment and generate conanfile
8383
conan_api, conanfile_path = self._prepare_installation()
@@ -247,6 +247,7 @@ def publish(self) -> None:
247247
raise FileNotFoundError(f'conanfile.py not found at {conanfile_path}')
248248

249249
conan_api = ConanAPI()
250+
250251
all_remotes = conan_api.remotes.list()
251252

252253
# Configure remotes for upload
@@ -272,7 +273,7 @@ def publish(self) -> None:
272273
user=None,
273274
channel=None,
274275
lockfile=None,
275-
remotes=all_remotes,
276+
remotes=all_remotes, # Use all remotes for dependency resolution
276277
update=None,
277278
check_updates=False,
278279
is_build_require=False,
@@ -284,22 +285,31 @@ def publish(self) -> None:
284285
conan_api.graph.analyze_binaries(
285286
graph=deps_graph,
286287
build_mode=['*'],
287-
remotes=all_remotes,
288+
remotes=all_remotes, # Use all remotes for dependency resolution
288289
update=None,
289290
lockfile=None,
290291
)
291292

292293
conan_api.install.install_binaries(deps_graph=deps_graph, remotes=all_remotes)
293294

294-
# Upload if not local only
295-
if not self.data.local_only:
295+
if not self.data.skip_upload:
296296
self._upload_package(conan_api, ref, configured_remotes)
297297

298298
def _get_configured_remotes(self, all_remotes):
299-
"""Get and validate configured remotes for upload."""
300-
if self.data.local_only:
299+
"""Get and validate configured remotes for upload.
300+
301+
Note: This only affects upload behavior. For dependency resolution,
302+
we always use all available system remotes regardless of this config.
303+
"""
304+
# If skip_upload is True, don't upload anywhere
305+
if self.data.skip_upload:
301306
return []
302307

308+
# If no remotes specified, upload to all available remotes
309+
if not self.data.remotes:
310+
return all_remotes
311+
312+
# Otherwise, upload only to specified remotes
303313
configured_remotes = [remote for remote in all_remotes if remote.name in self.data.remotes]
304314

305315
if not configured_remotes:

cppython/plugins/conan/resolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def resolve_conan_data(data: dict[str, Any], core_data: CorePluginData) -> Conan
318318

319319
return ConanData(
320320
remotes=parsed_data.remotes,
321+
skip_upload=parsed_data.skip_upload,
321322
host_profile=host_profile,
322323
build_profile=build_profile,
323324
)

cppython/plugins/conan/schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,22 @@ class ConanData(CPPythonModel):
293293
"""Resolved conan data"""
294294

295295
remotes: list[str]
296+
skip_upload: bool
296297
host_profile: Profile
297298
build_profile: Profile
298299

299-
@property
300-
def local_only(self) -> bool:
301-
"""Check if publishing should be local-only."""
302-
return len(self.remotes) == 0
303-
304300

305301
class ConanConfiguration(CPPythonModel):
306302
"""Raw conan data"""
307303

308304
remotes: Annotated[
309305
list[str],
310-
Field(description='List of remotes to upload to. Empty list means the local conan cache will be used.'),
306+
Field(description='List of remotes to upload to. If empty, uploads to all available remotes.'),
311307
] = ['conancenter']
308+
skip_upload: Annotated[
309+
bool,
310+
Field(description='If true, skip uploading packages during publish (local-only mode).'),
311+
] = False
312312
host_profile: Annotated[
313313
str | None,
314314
Field(

pdm.lock

Lines changed: 48 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,23 @@ dependencies = [
2020
]
2121

2222
[project.optional-dependencies]
23-
pytest = ["pytest>=8.4.1", "pytest-mock>=3.14.1"]
24-
git = ["dulwich>=0.23.2"]
25-
pdm = ["pdm>=2.25.4"]
26-
cmake = ["cmake>=4.0.3"]
27-
conan = ["conan>=2.18.1", "libcst>=1.8.2"]
23+
pytest = [
24+
"pytest>=8.4.1",
25+
"pytest-mock>=3.14.1",
26+
]
27+
git = [
28+
"dulwich>=0.23.2",
29+
]
30+
pdm = [
31+
"pdm>=2.25.4",
32+
]
33+
cmake = [
34+
"cmake>=4.0.3",
35+
]
36+
conan = [
37+
"conan>=2.18.1",
38+
"libcst>=1.8.2",
39+
]
2840

2941
[project.urls]
3042
homepage = "https://github.com/Synodic-Software/CPPython"
@@ -47,8 +59,15 @@ cppython = "cppython.plugins.pdm.plugin:CPPythonPlugin"
4759
cppython = "cppython.test.pytest.fixtures"
4860

4961
[dependency-groups]
50-
lint = ["ruff>=0.12.3", "pyrefly>=0.23.1"]
51-
test = ["pytest>=8.4.1", "pytest-cov>=6.2.1", "pytest-mock>=3.14.1"]
62+
lint = [
63+
"ruff>=0.12.4",
64+
"pyrefly>=0.24.2",
65+
]
66+
test = [
67+
"pytest>=8.4.1",
68+
"pytest-cov>=6.2.1",
69+
"pytest-mock>=3.14.1",
70+
]
5271

5372
[project.scripts]
5473
cppython = "cppython.console.entry:app"

tests/fixtures/conan.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Shared fixtures for Conan plugin tests"""
22

33
from pathlib import Path
4+
from typing import Any
45
from unittest.mock import Mock
56

67
import pytest
@@ -10,6 +11,24 @@
1011
from cppython.plugins.conan.plugin import ConanProvider
1112
from cppython.plugins.conan.schema import ConanDependency
1213

14+
# Shared parameterization for plugin data across all conan tests
15+
CONAN_PLUGIN_DATA_PARAMS = [
16+
{'remotes': ['conancenter'], 'skip_upload': False}, # Default behavior
17+
{'remotes': [], 'skip_upload': False}, # Empty remotes (upload to all)
18+
{'remotes': ['conancenter'], 'skip_upload': True}, # Skip upload with specific remotes
19+
{'remotes': [], 'skip_upload': True}, # Skip upload with empty remotes
20+
]
21+
22+
23+
@pytest.fixture(name='conan_plugin_data', scope='session', params=CONAN_PLUGIN_DATA_PARAMS)
24+
def fixture_conan_plugin_data(request) -> dict[str, Any]:
25+
"""Shared parameterized plugin data for conan tests
26+
27+
Returns:
28+
The constructed plugin data with different combinations of remotes and skip_upload
29+
"""
30+
return request.param
31+
1332

1433
@pytest.fixture(autouse=True)
1534
def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):

tests/integration/examples/test_conan_cmake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_simple(example_runner: CliRunner) -> None:
5252

5353
# --- Setup for Publish with modified config ---
5454
# Modify the in-memory representation of the pyproject data
55-
pyproject_data['tool']['cppython']['providers']['conan']['remotes'] = []
55+
pyproject_data['tool']['cppython']['providers']['conan']['skip_upload'] = True
5656

5757
# Create a new project instance with the modified configuration for the 'publish' step
5858
publish_project = Project(project_configuration, interface, pyproject_data)

tests/unit/plugins/conan/test_install.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ class TestConanInstall(ProviderPluginTestMixin[ConanProvider]):
2929

3030
@staticmethod
3131
@pytest.fixture(name='plugin_data', scope='session')
32-
def fixture_plugin_data() -> dict[str, Any]:
32+
def fixture_plugin_data(conan_plugin_data: dict[str, Any]) -> dict[str, Any]:
3333
"""A required testing hook that allows data generation
3434
3535
Returns:
3636
The constructed plugin data
3737
"""
38-
return {
39-
'remotes': [],
40-
}
38+
return conan_plugin_data
4139

4240
@staticmethod
4341
@pytest.fixture(name='plugin_type', scope='session')

0 commit comments

Comments
 (0)