Skip to content
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

Integrate PDM as python build system #33

Merged
merged 31 commits into from
Jun 13, 2023
Merged

Conversation

szandara
Copy link

No description provided.

@@ -83,53 +142,63 @@ def _update_dependencies_version(self, obj: Dict[str, Any], version: str) -> Non
del value["develop"]
value["version"] = version


class PyprojectBase(ABC):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got very confused by the naming while reading this code. The PyprojectBase object is a wrapper for Pyproject object. What about instead having just the Pyproject class that would be a "plain object" and provide mutation functions that takes this Pyproject for input?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is basically what it does now, Pyproject is an input of specialized classes that have mutation functions. PyprojectBase is not a base for Pyproject. Let me rename it.

Copy link
Contributor

@ntrinquier ntrinquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @szandara, that looks great! I left a few stylistic comments :)

kraken-std/src/kraken/std/python/buildsystem/pdm.py Outdated Show resolved Hide resolved


class PdmPythonBuildSystem(PythonBuildSystem):
name = "Pdm"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "Pdm"
name = "PDM"

Comment on lines 54 to 55
username_command = ["pdm", "config", "pypi." + index.alias + ".username", index.credentials[0]]
password_command = ["pdm", "config", "pypi." + index.alias + ".password", index.credentials[1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using f-strings:

Suggested change
username_command = ["pdm", "config", "pypi." + index.alias + ".username", index.credentials[0]]
password_command = ["pdm", "config", "pypi." + index.alias + ".password", index.credentials[1]]
username_command = ["pdm", "config", f"pypi.{index.alias}.username", index.credentials[0]]
password_command = ["pdm", "config", f"pypi.{index.alias}.password", index.credentials[1]]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

f"{package_dir.relative_to(self.project_directory)} to {as_version}"
)

# Pdm does not allow configuring the output folder, so it's always going to be "dist/".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Pdm does not allow configuring the output folder, so it's always going to be "dist/".
# PDM does not allow configuring the output folder, so it's always going to be "dist/".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Comment on lines 77 to 79
index = next((i for i, v in enumerate(sources_conf) if v["name"] == source_name), None)
if index is None:
raise KeyError(source_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly more readable (IMO):

Suggested change
index = next((i for i, v in enumerate(sources_conf) if v["name"] == source_name), None)
if index is None:
raise KeyError(source_name)
index = [conf["name"] for conf in sources_conf].index(source_name)

(it will throw a ValueError instead of a KeyError, but I don't think it's that important here)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

GitHub Action and others added 3 commits June 9, 2023 06:51

def update_lockfile(self, settings: PythonSettings, pyproject: Pyproject) -> TaskStatus:
command = ["pdm", "update"]
sp.check_call(command, cwd=self.project_directory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use call() and return TaskStatus.from_command(cmd, code) for better UX.

@NiklasRosenstein NiklasRosenstein merged commit 466703e into develop Jun 13, 2023
8 checks passed
@NiklasRosenstein NiklasRosenstein deleted the zandaras/pdm branch June 13, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants