-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
@@ -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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :)
|
||
|
||
class PdmPythonBuildSystem(PythonBuildSystem): | ||
name = "Pdm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "Pdm" | |
name = "PDM" |
username_command = ["pdm", "config", "pypi." + index.alias + ".username", index.credentials[0]] | ||
password_command = ["pdm", "config", "pypi." + index.alias + ".password", index.credentials[1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using f-strings:
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]] |
There was a problem hiding this comment.
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/". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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/". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
index = next((i for i, v in enumerate(sources_conf) if v["name"] == source_name), None) | ||
if index is None: | ||
raise KeyError(source_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly more readable (IMO):
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix
|
||
def update_lockfile(self, settings: PythonSettings, pyproject: Pyproject) -> TaskStatus: | ||
command = ["pdm", "update"] | ||
sp.check_call(command, cwd=self.project_directory) |
There was a problem hiding this comment.
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.
No description provided.