-
Notifications
You must be signed in to change notification settings - Fork 83
Drop support for pyp2rpm #4478
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
base: main
Are you sure you want to change the base?
Drop support for pyp2rpm #4478
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """ | ||
| Switch packages to pyp2spec | ||
|
|
||
| Revision ID: 43f9339a9e9a | ||
| Create Date: 2026-09-10 11:11:34.114231 | ||
| """ | ||
| # pylint: disable=invalid-name | ||
|
|
||
| import json | ||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = '43f9339a9e9a' | ||
| down_revision = 'e31b4af2468c' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| session = sa.orm.sessionmaker(bind=op.get_bind())() | ||
|
|
||
| sql = "SELECT id, source_json FROM package WHERE source_type=:source_type" | ||
| data = {"source_type": 5} | ||
| rows = session.execute(sa.text(sql), data).mappings() | ||
| for row in rows: | ||
| # This should never happen | ||
| if not row["source_json"]: | ||
| continue | ||
|
|
||
| source_dict = json.loads(row["source_json"]) | ||
| if source_dict.get("spec_generator") != "pyp2rpm": | ||
| continue | ||
|
|
||
| source_dict["spec_generator"] = "pyp2spec" | ||
|
|
||
| sql = "UPDATE package SET source_json=:source_json WHERE id=:id" | ||
| data = { | ||
| "source_json": json.dumps(source_dict), | ||
| "id": row["id"], | ||
| } | ||
| session.execute(sa.text(sql), data) | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # No way back | ||
| return | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """ | ||
| Test all kinds of package request via v3 API | ||
| """ | ||
|
|
||
| import pytest | ||
| from tests.coprs_test_case import CoprsTestCase, TransactionDecorator | ||
|
|
||
|
|
||
| class TestAPIv3Packages(CoprsTestCase): | ||
|
|
||
| @TransactionDecorator("u1") | ||
| @pytest.mark.usefixtures("f_users", "f_users_api", "f_coprs", "f_db") | ||
| def test_v3_package_pypi(self): | ||
| response = self.api3.create_pypi_package( | ||
| "foocopr", | ||
| "pello1", | ||
| options={"spec_generator": "pyp2spec"}, | ||
| ) | ||
| assert response.status_code == 200 | ||
|
|
||
| with pytest.raises(AssertionError): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the defined invalid-generator response.
🤖 Prompt for AI Agents |
||
| response = self.api3.create_pypi_package( | ||
| "foocopr", | ||
| "pello2", | ||
| options={"spec_generator": "pyp2rpm"}, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,12 @@ def init_provider(self): | |
| source_json = self.source_dict | ||
| self.pypi_package_version = source_json["pypi_package_version"] | ||
| self.pypi_package_name = source_json["pypi_package_name"] | ||
| self.spec_generator = source_json.get("spec_generator", "pyp2rpm") | ||
| self.spec_generator = source_json.get("spec_generator", "pyp2spec") | ||
| self.spec_template = source_json.get("spec_template", '') | ||
| self.python_versions = source_json["python_versions"] or [] | ||
|
|
||
| def tool_presence_check(self): | ||
| if self.spec_generator not in ["pyp2rpm", "pyp2spec"]: | ||
| if self.spec_generator not in ["pyp2spec"]: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Normalize null 🤖 Prompt for AI Agents |
||
| msg = "Unsupported tool: {0}".format(self.spec_generator) | ||
| raise RuntimeError(msg) | ||
|
|
||
|
|
@@ -30,26 +30,7 @@ def tool_presence_check(self): | |
|
|
||
| def produce_srpm(self): | ||
| self.tool_presence_check() | ||
|
|
||
| if self.spec_generator == "pyp2rpm": | ||
| self._produce_srpm_pyp2rpm() | ||
| else: | ||
| self._produce_srpm_pyp2spec() | ||
|
|
||
| def _produce_srpm_pyp2rpm(self): | ||
| cmd = ["pyp2rpm", self.pypi_package_name, "-t", self.spec_template, | ||
| "--srpm", "-d", self.resultdir] | ||
|
|
||
| for i, python_version in enumerate(self.python_versions): | ||
| if i == 0: | ||
| cmd += ["-b", str(python_version)] | ||
| else: | ||
| cmd += ["-p", str(python_version)] | ||
|
|
||
| if self.pypi_package_version: | ||
| cmd += ["-v", self.pypi_package_version] | ||
|
|
||
| return run_cmd(cmd) | ||
| self._produce_srpm_pyp2spec() | ||
|
|
||
| def _produce_srpm_pyp2spec(self): | ||
| os.chdir(self.resultdir) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.