Skip to content

Commit

Permalink
feat(Python): support Poetry package manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
shahinism committed Sep 9, 2024
1 parent 8cd2cb3 commit 3d92ccf
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 17 deletions.
10 changes: 9 additions & 1 deletion copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ python_version:
type: str
help: "Required Python version:"
default: ">=3.11"
when: "{{ language == 'Python' }}"
when: "{{ language == 'Python' }}"

python_package_manager:
type: str
help: "Package Manager:"
choices:
- Poetry
- PDM
when: "{{ language == 'Python' }}"

project_license:
type: str
Expand Down
30 changes: 15 additions & 15 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1720853497,
"lastModified": 1725637114,
"owner": "cachix",
"repo": "devenv",
"rev": "7f569a0f2473b9f6000fd9e4c32511fd1b0d37c1",
"treeHash": "4d452ecc8223834e39d507f9ea92308f007ee05d",
"rev": "c31e347a96dbb7718a0279afa993752a7dfc6a39",
"treeHash": "e0dfcbbfb0974603336900406b364bd4d1308fa4",
"type": "github"
},
"original": {
Expand Down Expand Up @@ -95,11 +95,11 @@
]
},
"locked": {
"lastModified": 1720642556,
"lastModified": 1724996935,
"owner": "nlewo",
"repo": "nix2container",
"rev": "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4",
"treeHash": "a9c2f1d3f52f288515ca0fb11f9aed970fd869b6",
"rev": "fa6bb0a1159f55d071ba99331355955ae30b3401",
"treeHash": "a934d246fadcf8b36d28f3577fad413f5ab3f7d3",
"type": "github"
},
"original": {
Expand All @@ -110,11 +110,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1725194671,
"lastModified": 1725816686,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b833ff01a0d694b910daca6e2ff4a3f26dee478c",
"treeHash": "bb5efa178da5cad3d41f9557a800b8fa3033c1f5",
"rev": "add0443ee587a0c44f22793b8c8649a0dbc3bb00",
"treeHash": "621fcf9b0d86811bd99b99447146defeb8f41ca0",
"type": "github"
},
"original": {
Expand All @@ -126,11 +126,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1720954236,
"lastModified": 1725693463,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "53e81e790209e41f0c1efa9ff26ff2fd7ab35e27",
"treeHash": "ca1f1273cf201da604f7c704535d4b7fac62cdb2",
"rev": "68e7dce0a6532e876980764167ad158174402c6f",
"treeHash": "ee872ee4d2426a6c3e1e4b3fa844550ce1b52b29",
"type": "github"
},
"original": {
Expand All @@ -150,11 +150,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1721042469,
"lastModified": 1725513492,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
"treeHash": "91f40b7a3b9f6886bd77482cba5b5cd890415a2e",
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528",
"treeHash": "4b46d77870afecd8f642541cb4f4927326343b59",
"type": "github"
},
"original": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
description = "DataChef's project kickstarter! Reproducible, Declarative and Reliable development environments."
authors = ["Reza (Shahin) Khanipour <Shahin@DataChef.co>"]
readme = "README.md"
package = [
packages = [
{ include = "iception", from = "src" },
]

Expand Down
193 changes: 193 additions & 0 deletions temp/test/devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1725637114,
"owner": "cachix",
"repo": "devenv",
"rev": "c31e347a96dbb7718a0279afa993752a7dfc6a39",
"treeHash": "e0dfcbbfb0974603336900406b364bd4d1308fa4",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"treeHash": "bd263f021e345cb4a39d80c126ab650bebc3c10c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"mk-shell-bin": {
"locked": {
"lastModified": 1677004959,
"owner": "rrbutani",
"repo": "nix-mk-shell-bin",
"rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887",
"treeHash": "496327dabdc787353a29987f492dd4939151baad",
"type": "github"
},
"original": {
"owner": "rrbutani",
"repo": "nix-mk-shell-bin",
"type": "github"
}
},
"nix2container": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1724996935,
"owner": "nlewo",
"repo": "nix2container",
"rev": "fa6bb0a1159f55d071ba99331355955ae30b3401",
"treeHash": "a934d246fadcf8b36d28f3577fad413f5ab3f7d3",
"type": "github"
},
"original": {
"owner": "nlewo",
"repo": "nix2container",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1725816686,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "add0443ee587a0c44f22793b8c8649a0dbc3bb00",
"treeHash": "621fcf9b0d86811bd99b99447146defeb8f41ca0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1725693463,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "68e7dce0a6532e876980764167ad158174402c6f",
"treeHash": "ee872ee4d2426a6c3e1e4b3fa844550ce1b52b29",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1725513492,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "7570de7b9b504cfe92025dd1be797bf546f66528",
"treeHash": "4b46d77870afecd8f642541cb4f4927326343b59",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"mk-shell-bin": "mk-shell-bin",
"nix2container": "nix2container",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"treeHash": "cce81f2a0f0743b2eb61bc2eb6c7adbe2f2c6beb",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block languages %}
python = {
enable = true;
{% if python_package_manager == "PDM" %}
venv = {
enable = true;
requirements = ''
Expand All @@ -14,6 +15,15 @@ epc
black
'';
};
{% elif python_package_manager == "Poetry" %}
poetry = {
enable = true;
activate.enable = true;
install.enable = true;
install.allExtras = true;
install.groups = [ "dev" ];
};
{% endif %}
};
{% endblock %}

Expand All @@ -36,7 +46,9 @@ black
{% block extra_config %}
enterShell = ''
hello
{% if python_package_manager == "PDM" %}
pdm install
{% endif %}
'';
{% endblock %}
{% block hooks %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if python_package_manager == "PDM" %}
[project]
name = "{{project_name}}"
version = "{{project_version}}"
Expand Down Expand Up @@ -30,6 +31,31 @@ dev = [
"pytest-dependency>=0.6.0",
"pytest>=8.3.1",
]

{% elif python_package_manager == "Poetry" %}
[tool.poetry]
name = "{{project_name}}"
version = "{{project_version}}"
description = "{{project_description}}"
authors = ["{{author_name}} <{{author_email}}>"]
readme = "README.md"
license = "{{project_license}}"
packages = [
{ include = "{{project_name}}", from = "src" },
]

[tool.poetry.dependencies]
python = "{{python_version}}"

[tool.poetry.group.dev.dependencies]
commitizen = "^3.29.0"
pdbpp = "^0.10.3"
mypy = "^1.11.0"
pytest-coverage = "^0.0"
pytest-dependency = "^0.6.0"
pytest = "^8.3.1"
{% endif %}

[tool.commitizen]
version = "1.0.0"
update_changelog_on_bump = true
Expand Down

0 comments on commit 3d92ccf

Please sign in to comment.