pam-python 0.1.41__tar.gz → 0.1.43__tar.gz

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.
Files changed (42) hide show
  1. {pam_python-0.1.41/pam_python.egg-info → pam_python-0.1.43}/PKG-INFO +3 -1
  2. {pam_python-0.1.41 → pam_python-0.1.43}/README.md +2 -0
  3. {pam_python-0.1.41 → pam_python-0.1.43}/pam/cli.py +39 -12
  4. {pam_python-0.1.41 → pam_python-0.1.43}/pam/logger.py +1 -2
  5. pam_python-0.1.43/pam/templates/init/requirements.txt +6 -0
  6. {pam_python-0.1.41 → pam_python-0.1.43/pam_python.egg-info}/PKG-INFO +3 -1
  7. {pam_python-0.1.41 → pam_python-0.1.43}/pam_python.egg-info/SOURCES.txt +1 -0
  8. {pam_python-0.1.41 → pam_python-0.1.43}/setup.py +1 -1
  9. {pam_python-0.1.41 → pam_python-0.1.43}/LICENSE.txt +0 -0
  10. {pam_python-0.1.41 → pam_python-0.1.43}/pam/__init__.py +0 -0
  11. {pam_python-0.1.41 → pam_python-0.1.43}/pam/api.py +0 -0
  12. {pam_python-0.1.41 → pam_python-0.1.43}/pam/interface_task_manager.py +0 -0
  13. {pam_python-0.1.41 → pam_python-0.1.43}/pam/models/__init__.py +0 -0
  14. {pam_python-0.1.41 → pam_python-0.1.43}/pam/models/request_command.py +0 -0
  15. {pam_python-0.1.41 → pam_python-0.1.43}/pam/request_file_format.py +0 -0
  16. {pam_python-0.1.41 → pam_python-0.1.43}/pam/server.py +0 -0
  17. {pam_python-0.1.41 → pam_python-0.1.43}/pam/service.py +0 -0
  18. {pam_python-0.1.41 → pam_python-0.1.43}/pam/sqlite.py +0 -0
  19. {pam_python-0.1.41 → pam_python-0.1.43}/pam/task_manager.py +0 -0
  20. {pam_python-0.1.41 → pam_python-0.1.43}/pam/temp_file_utils.py +0 -0
  21. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/buildcmd/pamb +0 -0
  22. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/buildcmd/pamb-base.sh +0 -0
  23. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/docker/Dockerfile +0 -0
  24. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/AGENT.md +0 -0
  25. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/dockerignore.tmpl +0 -0
  26. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/gitignore.tmpl +0 -0
  27. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/main.tmpl +0 -0
  28. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/pylintrc.tmpl +0 -0
  29. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/run_unit_test.bat +0 -0
  30. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/run_unit_test.ps1 +0 -0
  31. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/init/run_unit_test.sh +0 -0
  32. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/service/functions.tmpl +0 -0
  33. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/service/service.test.tmpl +0 -0
  34. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/service/service.yaml +0 -0
  35. {pam_python-0.1.41 → pam_python-0.1.43}/pam/templates/service/service_class.tmpl +0 -0
  36. {pam_python-0.1.41 → pam_python-0.1.43}/pam/tester_task.py +0 -0
  37. {pam_python-0.1.41 → pam_python-0.1.43}/pam/utils.py +0 -0
  38. {pam_python-0.1.41 → pam_python-0.1.43}/pam_python.egg-info/dependency_links.txt +0 -0
  39. {pam_python-0.1.41 → pam_python-0.1.43}/pam_python.egg-info/entry_points.txt +0 -0
  40. {pam_python-0.1.41 → pam_python-0.1.43}/pam_python.egg-info/requires.txt +0 -0
  41. {pam_python-0.1.41 → pam_python-0.1.43}/pam_python.egg-info/top_level.txt +0 -0
  42. {pam_python-0.1.41 → pam_python-0.1.43}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.41
3
+ Version: 0.1.43
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -106,6 +106,8 @@ When `requirements.txt` already exists, you will be prompted to choose how to pr
106
106
  - keep
107
107
  - merge
108
108
 
109
+ `pam init` now writes a project baseline `requirements.txt`. It pins `pam-python` to the scaffold version and includes core runtime/test dependencies used by the generated project. It does not copy the current machine's `pip freeze`.
110
+
109
111
  ---
110
112
 
111
113
  **Create a Service**
@@ -67,6 +67,8 @@ When `requirements.txt` already exists, you will be prompted to choose how to pr
67
67
  - keep
68
68
  - merge
69
69
 
70
+ `pam init` now writes a project baseline `requirements.txt`. It pins `pam-python` to the scaffold version and includes core runtime/test dependencies used by the generated project. It does not copy the current machine's `pip freeze`.
71
+
70
72
  ---
71
73
 
72
74
  **Create a Service**
@@ -2,8 +2,8 @@ import os
2
2
  import sys
3
3
  import re
4
4
  import shutil
5
- import subprocess
6
5
  import importlib.resources as resources
6
+ from importlib import metadata
7
7
 
8
8
  def main():
9
9
  args = sys.argv[1:]
@@ -52,6 +52,13 @@ def cpy(src, dest):
52
52
  src_file = os.path.join(template_dir, src)
53
53
  shutil.copy(src_file, dest)
54
54
 
55
+
56
+ def read_template_text(src: str) -> str:
57
+ template_dir = resources.files("pam") / "templates"
58
+ src_file = os.path.join(template_dir, src)
59
+ with open(src_file, "r", encoding="utf-8") as file:
60
+ return file.read()
61
+
55
62
  def replace_template_content(service_name, class_name, file_name):
56
63
  file_path = os.path.join(service_name, file_name)
57
64
  with open(file_path, 'r+', encoding='utf-8') as file:
@@ -109,6 +116,7 @@ def init_project():
109
116
 
110
117
  requirements_path = "requirements.txt"
111
118
  has_requirements = os.path.exists(requirements_path)
119
+ template_requirements = _build_project_requirements().splitlines()
112
120
 
113
121
  mode = "overwrite"
114
122
  if has_requirements:
@@ -125,20 +133,13 @@ def init_project():
125
133
  if mode == "keep":
126
134
  print("Keeping existing requirements.txt")
127
135
  else:
128
- freeze = subprocess.run(
129
- ["pip", "freeze"],
130
- check=True,
131
- text=True,
132
- capture_output=True
133
- ).stdout.splitlines()
134
-
135
136
  if mode == "overwrite" or not has_requirements:
136
137
  with open(requirements_path, "w", encoding="utf-8") as f:
137
- f.write("\n".join(freeze) + ("\n" if freeze else ""))
138
+ f.write(_build_project_requirements())
138
139
  elif mode == "merge":
139
140
  with open(requirements_path, "r", encoding="utf-8") as f:
140
141
  existing_lines = f.read().splitlines()
141
- merged_lines = _merge_requirements(existing_lines, freeze)
142
+ merged_lines = _merge_requirements(existing_lines, template_requirements)
142
143
  with open(requirements_path, "w", encoding="utf-8") as f:
143
144
  f.write("\n".join(merged_lines) + ("\n" if merged_lines else ""))
144
145
 
@@ -155,12 +156,38 @@ def _parse_requirement_name(line: str) -> str:
155
156
  return ""
156
157
  if line.startswith("-"):
157
158
  return line
159
+ line = line.split(";", 1)[0].strip()
158
160
  # Normalize common requirement formats like pkg==1.2, pkg>=1.2, pkg[extra]==1.2
159
161
  splitters = ["==", ">=", "<=", "~=", ">", "<"]
160
162
  for splitter in splitters:
161
163
  if splitter in line:
162
- return line.split(splitter, 1)[0].strip()
163
- return line
164
+ line = line.split(splitter, 1)[0].strip()
165
+ break
166
+ return line.split("[", 1)[0].strip().lower()
167
+
168
+
169
+ def _get_installed_pam_version() -> str:
170
+ setup_py = os.path.join(os.path.dirname(os.path.dirname(__file__)), "setup.py")
171
+ if os.path.exists(setup_py):
172
+ with open(setup_py, "r", encoding="utf-8") as file:
173
+ content = file.read()
174
+ match = re.search(r'version="([^"]+)"', content)
175
+ if match:
176
+ return match.group(1)
177
+
178
+ try:
179
+ return metadata.version("pam-python")
180
+ except metadata.PackageNotFoundError:
181
+ return "0.0.0"
182
+
183
+
184
+ def _build_project_requirements() -> str:
185
+ pam_version = _get_installed_pam_version()
186
+ template = read_template_text("init/requirements.txt")
187
+ rendered = template.replace("#PAM_VERSION#", pam_version)
188
+ if not rendered.endswith("\n"):
189
+ rendered += "\n"
190
+ return rendered
164
191
 
165
192
 
166
193
  def _merge_requirements(existing_lines, frozen_lines):
@@ -5,8 +5,7 @@ from threading import Lock
5
5
  from typing import Any
6
6
 
7
7
  from pam.utils import log as stdout_log
8
- from service import Service
9
-
8
+ from pam.service import Service
10
9
 
11
10
  class Logger:
12
11
  def __init__(self, service: Service, buffer_size: int = 20, source: str = "worker"):
@@ -0,0 +1,6 @@
1
+ pam-python==#PAM_VERSION#
2
+ Flask>=3.0.2
3
+ gunicorn>=23.0.0
4
+ pandas>=2.2.3
5
+ dask>=2024.12.1
6
+ Faker>=33.1.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.41
3
+ Version: 0.1.43
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -106,6 +106,8 @@ When `requirements.txt` already exists, you will be prompted to choose how to pr
106
106
  - keep
107
107
  - merge
108
108
 
109
+ `pam init` now writes a project baseline `requirements.txt`. It pins `pam-python` to the scaffold version and includes core runtime/test dependencies used by the generated project. It does not copy the current machine's `pip freeze`.
110
+
109
111
  ---
110
112
 
111
113
  **Create a Service**
@@ -24,6 +24,7 @@ pam/templates/init/dockerignore.tmpl
24
24
  pam/templates/init/gitignore.tmpl
25
25
  pam/templates/init/main.tmpl
26
26
  pam/templates/init/pylintrc.tmpl
27
+ pam/templates/init/requirements.txt
27
28
  pam/templates/init/run_unit_test.bat
28
29
  pam/templates/init/run_unit_test.ps1
29
30
  pam/templates/init/run_unit_test.sh
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pam-python",
5
- version="0.1.41",
5
+ version="0.1.43",
6
6
  author="Narongrit Kanhanoi",
7
7
  author_email="narongrit@pams.ai",
8
8
  description="Pam Python Library",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes