instant-python 0.6.2__py3-none-any.whl → 0.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import typer
2
2
 
3
3
  from instant_python.configuration.parser.parser import Parser
4
4
  from instant_python.dependency_manager.dependency_manager_factory import DependencyManagerFactory
5
+ from instant_python.formatter.project_formatter import ProjectFormatter
5
6
  from instant_python.git.git_configurer import GitConfigurer
6
7
  from instant_python.project_creator.file_system import FileSystem
7
8
  from instant_python.render.custom_project_renderer import CustomProjectRenderer
@@ -44,6 +45,9 @@ def create_new_project(
44
45
  dependencies=configuration.dependencies,
45
46
  )
46
47
 
48
+ formatter = ProjectFormatter(project_directory=configuration.project_folder_name)
49
+ formatter.format()
50
+
47
51
  git_configurer = GitConfigurer(project_directory=configuration.project_folder_name)
48
52
  git_configurer.setup_repository(configuration.git)
49
53
  configuration.save_on_project_folder()
@@ -1,5 +1,6 @@
1
1
  import subprocess
2
2
  from abc import ABC, abstractmethod
3
+ import sys
3
4
 
4
5
  from instant_python.configuration.dependency.dependency_configuration import DependencyConfiguration
5
6
 
@@ -7,6 +8,7 @@ from instant_python.configuration.dependency.dependency_configuration import Dep
7
8
  class DependencyManager(ABC):
8
9
  def __init__(self, project_directory: str) -> None:
9
10
  self._project_directory = project_directory
11
+ self._system_os = sys.platform
10
12
 
11
13
  @abstractmethod
12
14
  def setup_environment(self, python_version: str, dependencies: list[DependencyConfiguration]) -> None:
@@ -1,3 +1,4 @@
1
+ from pathlib import Path
1
2
  import subprocess
2
3
 
3
4
  from instant_python.configuration.dependency.dependency_configuration import DependencyConfiguration
@@ -8,7 +9,7 @@ from instant_python.dependency_manager.command_execution_error import CommandExe
8
9
  class PdmDependencyManager(DependencyManager):
9
10
  def __init__(self, project_directory: str) -> None:
10
11
  super().__init__(project_directory)
11
- self._pdm = "~/.local/bin/pdm"
12
+ self._pdm = self._set_pdm_executable_based_on_os()
12
13
 
13
14
  def setup_environment(self, python_version: str, dependencies: list[DependencyConfiguration]) -> None:
14
15
  try:
@@ -20,9 +21,21 @@ class PdmDependencyManager(DependencyManager):
20
21
 
21
22
  def _install(self) -> None:
22
23
  print(">>> Installing pdm...")
23
- self._run_command(command="curl -sSL https://pdm-project.org/install-pdm.py | python3 -")
24
+ self._run_command(command=self._get_installation_command_based_on_os())
24
25
  print(">>> pdm installed successfully")
25
26
 
27
+ def _set_pdm_executable_based_on_os(self):
28
+ return (
29
+ f"{str(Path.home() / 'AppData' / 'Roaming' / 'Python' / 'Scripts' / 'pdm.exe')}"
30
+ if self._system_os.startswith("win")
31
+ else "~/.local/bin/pdm"
32
+ )
33
+
34
+ def _get_installation_command_based_on_os(self) -> str:
35
+ if self._system_os.startswith("win"):
36
+ return 'powershell -ExecutionPolicy ByPass -c "irm https://pdm-project.org/install-pdm.py | py -"'
37
+ return "curl -sSL https://pdm-project.org/install-pdm.py | python3 -"
38
+
26
39
  def _install_python(self, version: str) -> None:
27
40
  print(f">>> Installing Python {version}...")
28
41
  self._run_command(command=f"{self._pdm} python install {version}")
@@ -34,6 +47,7 @@ class PdmDependencyManager(DependencyManager):
34
47
  for dependency in dependencies:
35
48
  command = self._build_dependency_install_command(dependency)
36
49
  self._run_command(command)
50
+ print(">>> Dependencies installed successfully")
37
51
 
38
52
  def _build_dependency_install_command(self, dependency: DependencyConfiguration) -> str:
39
53
  command = [f"{self._pdm} add"]
@@ -1,3 +1,4 @@
1
+ from pathlib import Path
1
2
  import subprocess
2
3
 
3
4
  from instant_python.configuration.dependency.dependency_configuration import DependencyConfiguration
@@ -8,7 +9,7 @@ from instant_python.dependency_manager.command_execution_error import CommandExe
8
9
  class UvDependencyManager(DependencyManager):
9
10
  def __init__(self, project_directory: str) -> None:
10
11
  super().__init__(project_directory)
11
- self._uv = "~/.local/bin/uv"
12
+ self._uv = self._set_uv_executable_based_on_os()
12
13
 
13
14
  def setup_environment(self, python_version: str, dependencies: list[DependencyConfiguration]) -> None:
14
15
  try:
@@ -20,8 +21,29 @@ class UvDependencyManager(DependencyManager):
20
21
 
21
22
  def _install(self) -> None:
22
23
  print(">>> Installing uv...")
23
- self._run_command(command="curl -LsSf https://astral.sh/uv/install.sh | sh")
24
+ self._run_command(command=self._get_installation_command_based_on_os())
24
25
  print(">>> uv installed successfully")
26
+ if self._system_os.startswith("win"):
27
+ print(
28
+ ">>> Remember to add uv to your PATH environment variable. You can do this:\n"
29
+ " 1. Running the following command if you use cmd:\n"
30
+ " set Path=%Path%;%USERPROFILE%\\.local\\bin\n"
31
+ " 2. Running the following command if you use PowerShell:\n"
32
+ " $env:Path = '$env:USERPROFILE\\.local\\bin;$env:Path'\n"
33
+ " 3. Restarting your shell."
34
+ )
35
+
36
+ def _get_installation_command_based_on_os(self) -> str:
37
+ if self._system_os.startswith("win"):
38
+ return 'powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"'
39
+ return "curl -LsSf https://astral.sh/uv/install.sh | sh"
40
+
41
+ def _set_uv_executable_based_on_os(self):
42
+ return (
43
+ f"{str(Path.home() / '.local' / 'bin' / 'uv.exe')}"
44
+ if self._system_os.startswith("win")
45
+ else "~/.local/bin/uv"
46
+ )
25
47
 
26
48
  def _install_python(self, version: str) -> None:
27
49
  print(f">>> Installing Python {version}...")
@@ -34,6 +56,7 @@ class UvDependencyManager(DependencyManager):
34
56
  for dependency in dependencies:
35
57
  command = self._build_dependency_install_command(dependency)
36
58
  self._run_command(command)
59
+ print(">>> Dependencies installed successfully")
37
60
 
38
61
  def _build_dependency_install_command(self, dependency: DependencyConfiguration) -> str:
39
62
  command = [f"{self._uv} add"]
File without changes
@@ -0,0 +1,19 @@
1
+ import subprocess
2
+
3
+
4
+ class ProjectFormatter:
5
+ def __init__(self, project_directory: str) -> None:
6
+ self._project_directory = project_directory
7
+
8
+ def format(self) -> None:
9
+ self._run_command(command="uvx ruff format")
10
+
11
+ def _run_command(self, command: str) -> None:
12
+ subprocess.run(
13
+ command,
14
+ shell=True,
15
+ check=True,
16
+ cwd=self._project_directory,
17
+ stdout=subprocess.DEVNULL,
18
+ stderr=subprocess.PIPE,
19
+ )
@@ -13,7 +13,7 @@
13
13
  - name: domain
14
14
  type: directory
15
15
  python: True
16
- {% if ["value_objects", "event_bus"] | is_in(template.built_in_features) %}
16
+ {% if ["value_objects", "event_bus", "fastapi_application"] | is_in(template.built_in_features) %}
17
17
  children:
18
18
  {% if "value_objects" in template.built_in_features %}
19
19
  {{ macros.include_and_indent("project_structure/value_objects.yml.j2", 8) }}
@@ -21,6 +21,9 @@
21
21
  {% if "event_bus" in template.built_in_features %}
22
22
  {{ macros.include_and_indent("project_structure/event_bus_domain.yml.j2", 8) }}
23
23
  {% endif %}
24
+ {% if "fastapi_application" in template.built_in_features %}
25
+ {{ macros.include_and_indent("project_structure/fastapi_domain.yml.j2", 8) }}
26
+ {% endif %}
24
27
  {% endif %}
25
28
  - name: application
26
29
  type: directory
@@ -13,9 +13,9 @@
13
13
  - name: shared
14
14
  type: directory
15
15
  python: True
16
- {% if ["value_objects", "synchronous_sqlalchemy", "event_bus", "async_alembic"] | is_in(template.built_in_features) %}
16
+ {% if ["value_objects", "synchronous_sqlalchemy", "event_bus", "async_alembic", "fastapi_application"] | is_in(template.built_in_features) %}
17
17
  children:
18
- {% if ["value_objects", "event_bus"] | is_in(template.built_in_features) %}
18
+ {% if ["value_objects", "event_bus", "fastapi_application"] | is_in(template.built_in_features) %}
19
19
  - name: domain
20
20
  type: directory
21
21
  python: True
@@ -26,6 +26,9 @@
26
26
  {% if "event_bus" in template.built_in_features %}
27
27
  {{ macros.include_and_indent("project_structure/event_bus_domain.yml.j2", 12) }}
28
28
  {% endif %}
29
+ {% if "fastapi_application" in template.built_in_features %}
30
+ {{ macros.include_and_indent("project_structure/fastapi_domain.yml.j2", 12) }}
31
+ {% endif %}
29
32
  {% endif %}
30
33
  {% if ["synchronous_sqlalchemy", "event_bus", "logger", "async_sqlalchemy", "async_alembic", "fastapi_application"] | is_in(template.built_in_features) %}
31
34
  - name: infra
@@ -0,0 +1,7 @@
1
+ - name: exceptions
2
+ type: directory
3
+ python: True
4
+ children:
5
+ - name: exceptions/domain_error
6
+ type: boilerplate_file
7
+ extension: .py
@@ -26,5 +26,6 @@
26
26
  {% if "fastapi_application" in template.built_in_features %}
27
27
  {{ macros.include_and_indent("project_structure/fastapi_app.yml.j2", 4) }}
28
28
  {{ macros.include_and_indent("project_structure/fastapi_infra.yml.j2", 4) }}
29
+ {{ macros.include_and_indent("project_structure/fastapi_domain.yml.j2", 4) }}
29
30
  {% endif %}
30
31
  {% endif %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instant-python
3
- Version: 0.6.2
3
+ Version: 0.8.0
4
4
  Summary: Instant boilerplate generation for Python projects
5
5
  Project-URL: documentation, https://dimanu-py.github.io/instant-python/
6
6
  Project-URL: repository, https://github.com/dimanu-py/instant-python/
@@ -210,6 +210,7 @@ License-File: LICENSE
210
210
  Classifier: Environment :: Console
211
211
  Classifier: Intended Audience :: Developers
212
212
  Classifier: Operating System :: MacOS
213
+ Classifier: Operating System :: Microsoft :: Windows
213
214
  Classifier: Operating System :: POSIX :: Linux
214
215
  Classifier: Operating System :: Unix
215
216
  Classifier: Topic :: Software Development :: Code Generators
@@ -3,7 +3,7 @@ instant_python/cli.py,sha256=gjBeCHZzuG1OHw0gZ_2gBByZ9UB_yq6JPSVUz3pLo3c,804
3
3
  instant_python/instant_python_typer.py,sha256=jVk2VV8O4WHbyVGGn56D8Id-oo03KriwfmxgPTQOdy4,1230
4
4
  instant_python/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  instant_python/commands/config.py,sha256=m62zbX9A_dKaYdLmYaG89kZqRQmqtVQZyeHCyJOP9pU,1169
6
- instant_python/commands/init.py,sha256=6TEltKNKt-SDw8P7hj5GZTZao8Wuo9ksPiv0rzoz0fk,2174
6
+ instant_python/commands/init.py,sha256=jdRQufnBG-29abOOkYeVJ8FwrRarQkRSMqsYZ2CGFNw,2356
7
7
  instant_python/configuration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  instant_python/configuration/configuration_schema.py,sha256=KjZsLgY8IQynHaNIvhdBjFfvoVrtxMonkGuPijIrJTw,2680
9
9
  instant_python/configuration/question_wizard.py,sha256=mK_tWJ88g-wETNxlW6n9OXCmzZ32177u56TM42OdOtA,347
@@ -46,11 +46,13 @@ instant_python/configuration/template/invalid_template_value.py,sha256=GIvrWwn3Z
46
46
  instant_python/configuration/template/template_configuration.py,sha256=4QN2VqDbwjOeISBp63g0YuKePccD9eyysoX9k6QA4UQ,2619
47
47
  instant_python/dependency_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  instant_python/dependency_manager/command_execution_error.py,sha256=3vhincGDyx38NkUMZlcB_eRTaaF8ziZcKeX3kqnKqy8,511
49
- instant_python/dependency_manager/dependency_manager.py,sha256=_fsU5H7hy_F5xJQisXlqx3XFumZ3kblX8xF3GsunxkA,728
49
+ instant_python/dependency_manager/dependency_manager.py,sha256=-QfHcyO9A7EeItICPQWG8RO4sZ_zbjVQp7h9u8-2ph0,778
50
50
  instant_python/dependency_manager/dependency_manager_factory.py,sha256=WRP7LwPhoeFiAABAvfYFq4UhT3ibmc_6mASrPLm8Ok4,914
51
- instant_python/dependency_manager/pdm_dependency_manager.py,sha256=O5EjtA0QeBNU81nhFYfzzrqZnyB-hdodQ6F2R3HJqyM,2064
51
+ instant_python/dependency_manager/pdm_dependency_manager.py,sha256=JxtcSoKAgYLKs3ZYExI2pXxuDF8ZE1fUVySTWIT5Crs,2697
52
52
  instant_python/dependency_manager/unknown_dependency_manager_error.py,sha256=WYV3MGRgzHwJ5HwSOIPBowfIxadg_L6VdbNOKHRbNTE,396
53
- instant_python/dependency_manager/uv_dependency_manager.py,sha256=U9glowDvi0JA4MSoeGANKYeoeE5grTHSXdWj3Rw5GVw,2039
53
+ instant_python/dependency_manager/uv_dependency_manager.py,sha256=c_g3pyz8Q3A9-6IQiVwTIe0WNdlXUXnQ4j8-s8Ya_K8,3160
54
+ instant_python/formatter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
+ instant_python/formatter/project_formatter.py,sha256=EeAlb7_LA6ZaBLopzx3ZA1p3q-Fgi7gEi5sxzDkVWsU,506
54
56
  instant_python/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
57
  instant_python/git/git_configurer.py,sha256=Z6sQpvAk_BYB_eGzJuAomPY0nu2dPPxOsDh3dUPeuuA,1422
56
58
  instant_python/project_creator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -155,6 +157,7 @@ instant_python/templates/project_structure/async_sqlalchemy.yml.j2,sha256=XaOKwR
155
157
  instant_python/templates/project_structure/event_bus_domain.yml.j2,sha256=kqnY9EZaZ2O3HWaQb16jISpR287tBAKxyiq6IaPt1PA,769
156
158
  instant_python/templates/project_structure/event_bus_infra.yml.j2,sha256=pCKtjiIfi6VSBdM7n1QL7lQgM-lRqm2_7eOXYOstwaQ,971
157
159
  instant_python/templates/project_structure/fastapi_app.yml.j2,sha256=e3n1OXSea7LkOPlRCIbKwzyT6n-Y_YhSXwF1-TWX34Y,217
160
+ instant_python/templates/project_structure/fastapi_domain.yml.j2,sha256=21fFqN6Ncm_9pQ5eUH2mwZe73B8d3YGf7q4cSebBQfw,149
158
161
  instant_python/templates/project_structure/fastapi_infra.yml.j2,sha256=VJg6fLYL20iYugnE-Q4QpZg7TfM62zKdkuAxE_gWWmI,223
159
162
  instant_python/templates/project_structure/github_action.yml.j2,sha256=rMEddCYNUWE3kda2LhBu85FpxEWHZqQrOPBTm8mekkk,513
160
163
  instant_python/templates/project_structure/gitignore.yml.j2,sha256=Ex3A7rvCvuIqxTVdeHxM3DPyTl73AcrHyiceHOIzFuw,43
@@ -171,17 +174,17 @@ instant_python/templates/project_structure/readme.yml.j2,sha256=Km1zSVKfGwx7GHn0
171
174
  instant_python/templates/project_structure/synchronous_sqlalchemy.yml.j2,sha256=mC7WBchO0bzHcGkTw0k4woDstUvoQaJKlrCW82A96o8,467
172
175
  instant_python/templates/project_structure/value_objects.yml.j2,sha256=X5AyyZoRllCYdvRUaXSYlcZk_EQg2OyfdCS8pejjFpc,963
173
176
  instant_python/templates/project_structure/clean_architecture/main_structure.yml.j2,sha256=hh4bYTAmrOPWugWqDXX3qPrRJiTUG8iUNPKSo2RBwfQ,1395
174
- instant_python/templates/project_structure/clean_architecture/source.yml.j2,sha256=MT0HV_5-DhWt8vjry6z8FXnVHTjfsquVtw4QlU6uXXs,2307
177
+ instant_python/templates/project_structure/clean_architecture/source.yml.j2,sha256=EOlKRnuYigc49LqLFhCKlCrfrdW673doyGryWnQhHhU,2505
175
178
  instant_python/templates/project_structure/clean_architecture/test.yml.j2,sha256=q2Yqa4SXgEkg_xErGgESkObhRhPluA1fzKJgPMNIEOk,580
176
179
  instant_python/templates/project_structure/domain_driven_design/bounded_context.yml.j2,sha256=BTuT5fQBdw4o3Ev-iN8THAr2-bLlLG8mgLpbQOcL0x4,471
177
180
  instant_python/templates/project_structure/domain_driven_design/main_structure.yml.j2,sha256=NxA5Nw84DvJvfnag6-9jssZbe416fHXBzq4u1WeiDEY,1399
178
- instant_python/templates/project_structure/domain_driven_design/source.yml.j2,sha256=7gtu0CTJxGUqYY8-icHFFWc2TG_ykomS62dMH9DMuo4,2763
181
+ instant_python/templates/project_structure/domain_driven_design/source.yml.j2,sha256=L5N-C5EAQI8Nn4Nx6zEgTeaDbxHEm-zLKGEoFIcsdqA,2997
179
182
  instant_python/templates/project_structure/domain_driven_design/test.yml.j2,sha256=sUVO0jWeDEoShMXIDSTBw-14vStjoHCcTm5DuuI9V2A,841
180
183
  instant_python/templates/project_structure/standard_project/main_structure.yml.j2,sha256=Gy11qNOtTDzGgIbhDPmAUkipmjwJPHa33-_WL_xlR3U,1381
181
- instant_python/templates/project_structure/standard_project/source.yml.j2,sha256=NKY6763zZ1xxJnYyOxzqS6K0nJQP49EOkWzZOWp137M,1666
184
+ instant_python/templates/project_structure/standard_project/source.yml.j2,sha256=8QdB1AY22BzHRCidNdEJ9a6PRzq9ZWRPKIpqyoD6tmE,1748
182
185
  instant_python/templates/project_structure/standard_project/test.yml.j2,sha256=NxzsDeBKYzNaR3t8BY2VOuyhzwlp3Pa49OQNDF78gas,381
183
- instant_python-0.6.2.dist-info/METADATA,sha256=B2sU62LkmiH9DjoHVHfylT5LsqLzhkmo7TAlIzIQHiw,17574
184
- instant_python-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
185
- instant_python-0.6.2.dist-info/entry_points.txt,sha256=EdBTj3b3N9Pa4oNzPLPivE_AnMcQIFsmRC3RsSkoLLA,47
186
- instant_python-0.6.2.dist-info/licenses/LICENSE,sha256=kf7wA-1IsqXkzXjlsG95sdQJtsqUON_lNXombfPlklo,11353
187
- instant_python-0.6.2.dist-info/RECORD,,
186
+ instant_python-0.8.0.dist-info/METADATA,sha256=xfwYOwIugqrD-8Sk3XcyjcbmH_sbikQfAvuYEh7tIMU,17627
187
+ instant_python-0.8.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
188
+ instant_python-0.8.0.dist-info/entry_points.txt,sha256=EdBTj3b3N9Pa4oNzPLPivE_AnMcQIFsmRC3RsSkoLLA,47
189
+ instant_python-0.8.0.dist-info/licenses/LICENSE,sha256=kf7wA-1IsqXkzXjlsG95sdQJtsqUON_lNXombfPlklo,11353
190
+ instant_python-0.8.0.dist-info/RECORD,,