perceptic-core-client 0.5.0__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.
Potentially problematic release.
This version of perceptic-core-client might be problematic. Click here for more details.
- perceptic_core_client-0.5.0/MANIFEST.in +1 -0
- perceptic_core_client-0.5.0/PKG-INFO +38 -0
- perceptic_core_client-0.5.0/README.md +17 -0
- perceptic_core_client-0.5.0/pyproject.toml +39 -0
- perceptic_core_client-0.5.0/scripts/generate_client.py +143 -0
- perceptic_core_client-0.5.0/setup.cfg +4 -0
- perceptic_core_client-0.5.0/setup.py +102 -0
- perceptic_core_client-0.5.0/src/perceptic_core_client.egg-info/PKG-INFO +38 -0
- perceptic_core_client-0.5.0/src/perceptic_core_client.egg-info/SOURCES.txt +10 -0
- perceptic_core_client-0.5.0/src/perceptic_core_client.egg-info/dependency_links.txt +1 -0
- perceptic_core_client-0.5.0/src/perceptic_core_client.egg-info/requires.txt +12 -0
- perceptic_core_client-0.5.0/src/perceptic_core_client.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include scripts *
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: perceptic-core-client
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python client for Perceptic Core
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: urllib3<3.0.0,>=2.1.0
|
|
11
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
12
|
+
Requires-Dist: pydantic>=2
|
|
13
|
+
Requires-Dist: typing-extensions>=4.7.1
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff; extra == "dev"
|
|
18
|
+
Requires-Dist: mypy; extra == "dev"
|
|
19
|
+
Requires-Dist: build; extra == "dev"
|
|
20
|
+
Requires-Dist: requests; extra == "dev"
|
|
21
|
+
|
|
22
|
+
# Perceptic Core Python Client
|
|
23
|
+
|
|
24
|
+
This package provides a Python client for the Perceptic Core API.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
(Instructions will be added once packaging is set up)
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
(Example usage will be added)
|
|
33
|
+
|
|
34
|
+
## Building
|
|
35
|
+
|
|
36
|
+
This package requires Java and `openapi-generator-cli` to be installed for the build process, as it generates the client code from the OpenAPI specification during the build.
|
|
37
|
+
|
|
38
|
+
(Detailed build instructions will be added)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Perceptic Core Python Client
|
|
2
|
+
|
|
3
|
+
This package provides a Python client for the Perceptic Core API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
(Instructions will be added once packaging is set up)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
(Example usage will be added)
|
|
12
|
+
|
|
13
|
+
## Building
|
|
14
|
+
|
|
15
|
+
This package requires Java and `openapi-generator-cli` to be installed for the build process, as it generates the client code from the OpenAPI specification during the build.
|
|
16
|
+
|
|
17
|
+
(Detailed build instructions will be added)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"] # or hatchling / poetry-core / flit-core …
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "perceptic-core-client"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
description = "Python client for Perceptic Core"
|
|
9
|
+
authors = [{name = "Your Name", email = "you@example.com"}]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
license = {text = "Proprietary"}
|
|
13
|
+
classifiers = ["Programming Language :: Python :: 3"]
|
|
14
|
+
|
|
15
|
+
# Runtime dependencies
|
|
16
|
+
dependencies = [
|
|
17
|
+
"urllib3 >= 2.1.0, < 3.0.0",
|
|
18
|
+
"python-dateutil >= 2.8.2",
|
|
19
|
+
"pydantic >= 2",
|
|
20
|
+
"typing-extensions >= 4.7.1",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
# Development dependencies (install with 'pip install -e .[dev]')
|
|
25
|
+
dev = [
|
|
26
|
+
"pytest",
|
|
27
|
+
"pytest-cov",
|
|
28
|
+
"ruff",
|
|
29
|
+
"mypy",
|
|
30
|
+
"build",
|
|
31
|
+
"requests", # Also needed by the generate script itself
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.packages.find]
|
|
35
|
+
where = ["src"]
|
|
36
|
+
|
|
37
|
+
# Let setup.py handle dynamic versioning via the VERSION file
|
|
38
|
+
[tool.setuptools.dynamic]
|
|
39
|
+
version = { file = "VERSION" }
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
import os
|
|
5
|
+
import shutil
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import json # For reading version from spec (optional)
|
|
8
|
+
|
|
9
|
+
# --- Configuration ---
|
|
10
|
+
PACKAGE_NAME = "perceptic_core_client"
|
|
11
|
+
PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
|
12
|
+
OUTPUT_DIR = PROJECT_ROOT / "src" / PACKAGE_NAME
|
|
13
|
+
VERSION_FILE = PROJECT_ROOT / "VERSION"
|
|
14
|
+
# ---
|
|
15
|
+
|
|
16
|
+
def check_java():
|
|
17
|
+
"""Checks if Java is installed and accessible."""
|
|
18
|
+
try:
|
|
19
|
+
subprocess.run(["java", "-version"], check=True, capture_output=True)
|
|
20
|
+
print("Java installation found.")
|
|
21
|
+
return True
|
|
22
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
23
|
+
print("Error: Java Runtime Environment (JRE) not found.", file=sys.stderr)
|
|
24
|
+
print("openapi-generator-cli requires Java to run.", file=sys.stderr)
|
|
25
|
+
print("Please install Java and ensure it's in your PATH.", file=sys.stderr)
|
|
26
|
+
return False
|
|
27
|
+
|
|
28
|
+
def check_openapi_generator():
|
|
29
|
+
"""Checks if openapi-generator-cli is installed and accessible."""
|
|
30
|
+
try:
|
|
31
|
+
subprocess.run(["openapi-generator-cli", "list"], check=True, capture_output=True)
|
|
32
|
+
print("openapi-generator-cli found.")
|
|
33
|
+
return True
|
|
34
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
35
|
+
print("Error: openapi-generator-cli not found.", file=sys.stderr)
|
|
36
|
+
print("Please install it, e.g., using 'npm install @openapitools/openapi-generator-cli -g' or ensure it's in your PATH.", file=sys.stderr)
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
def run_generator(spec_path: Path, output_dir: Path, package_name: str):
|
|
40
|
+
"""Runs the openapi-generator-cli command."""
|
|
41
|
+
if not spec_path.is_file():
|
|
42
|
+
print(f"Error: OpenAPI spec file not found at: {spec_path}", file=sys.stderr)
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
# Ensure output directory exists and is empty
|
|
46
|
+
if output_dir.exists():
|
|
47
|
+
print(f"Cleaning existing output directory: {output_dir}")
|
|
48
|
+
if str(output_dir).startswith(str(PROJECT_ROOT / "src")): # Basic safety check
|
|
49
|
+
shutil.rmtree(output_dir)
|
|
50
|
+
else:
|
|
51
|
+
print(f"Error: Output directory {output_dir} seems unsafe to remove.", file=sys.stderr)
|
|
52
|
+
return False
|
|
53
|
+
output_dir.mkdir(parents=True)
|
|
54
|
+
(output_dir / "__init__.py").touch() # Make it a package immediately
|
|
55
|
+
|
|
56
|
+
additional_props = f"projectName={package_name},useOneOfDiscriminatorLookup=true,generateSourceCodeOnly=true,packageName={package_name}"
|
|
57
|
+
|
|
58
|
+
command = [
|
|
59
|
+
"openapi-generator-cli", "generate",
|
|
60
|
+
"-g", "python",
|
|
61
|
+
"-i", str(spec_path),
|
|
62
|
+
"-o", str(output_dir),
|
|
63
|
+
# "--package-name", package_name, # Handled by additional props
|
|
64
|
+
"--skip-validate-spec",
|
|
65
|
+
"--additional-properties", additional_props
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
print(f"Running generator command: {' '.join(command)}")
|
|
69
|
+
try:
|
|
70
|
+
process = subprocess.run(command, check=True, capture_output=True, text=True)
|
|
71
|
+
print("Generator output:")
|
|
72
|
+
print(process.stdout)
|
|
73
|
+
if process.stderr:
|
|
74
|
+
print("Generator errors/warnings:", file=sys.stderr)
|
|
75
|
+
print(process.stderr, file=sys.stderr)
|
|
76
|
+
print("Client generation successful.")
|
|
77
|
+
# Optionally read version from spec if --version wasn't provided
|
|
78
|
+
# spec_content = json.loads(spec_path.read_text())
|
|
79
|
+
# version_from_spec = spec_content.get("info", {}).get("version")
|
|
80
|
+
# print(f"Version found in spec: {version_from_spec}") # For info only
|
|
81
|
+
return True
|
|
82
|
+
except subprocess.CalledProcessError as e:
|
|
83
|
+
print(f"Error running openapi-generator-cli: {e}", file=sys.stderr)
|
|
84
|
+
print("Command output:", file=sys.stderr)
|
|
85
|
+
print(e.stdout, file=sys.stderr)
|
|
86
|
+
print(e.stderr, file=sys.stderr)
|
|
87
|
+
return False
|
|
88
|
+
except FileNotFoundError:
|
|
89
|
+
print("Error: 'openapi-generator-cli' command not found. Is it installed and in PATH?", file=sys.stderr)
|
|
90
|
+
return False
|
|
91
|
+
except Exception as e: # Catch other potential errors like JSON parsing
|
|
92
|
+
print(f"An unexpected error occurred during generation: {e}", file=sys.stderr)
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
def write_version_file(version: str, version_file_path: Path):
|
|
96
|
+
"""Writes the version to the VERSION file."""
|
|
97
|
+
print(f"Writing version '{version}' to {version_file_path}")
|
|
98
|
+
try:
|
|
99
|
+
version_file_path.write_text(version.strip() + "\n", encoding='utf-8')
|
|
100
|
+
return True
|
|
101
|
+
except IOError as e:
|
|
102
|
+
print(f"Error writing VERSION file: {e}", file=sys.stderr)
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
def main():
|
|
106
|
+
parser = argparse.ArgumentParser(description="Generate Python client from a local Perceptic Core OpenAPI spec file.")
|
|
107
|
+
parser.add_argument(
|
|
108
|
+
"--spec-path",
|
|
109
|
+
type=Path,
|
|
110
|
+
required=True,
|
|
111
|
+
help="Path to the local OpenAPI specification file (e.g., ../specs/openapi.yaml)"
|
|
112
|
+
)
|
|
113
|
+
parser.add_argument(
|
|
114
|
+
"--version",
|
|
115
|
+
type=str,
|
|
116
|
+
required=True,
|
|
117
|
+
help="The version string to assign to the package (e.g., 0.5.0)"
|
|
118
|
+
)
|
|
119
|
+
args = parser.parse_args()
|
|
120
|
+
spec_path = args.spec_path.resolve() # Get absolute path
|
|
121
|
+
version = args.version
|
|
122
|
+
|
|
123
|
+
print(f"--- Starting client generation from spec: {spec_path} for version: {version} ---")
|
|
124
|
+
|
|
125
|
+
# --- Pre-checks ---
|
|
126
|
+
if not check_java() or not check_openapi_generator():
|
|
127
|
+
sys.exit(1)
|
|
128
|
+
|
|
129
|
+
# --- Generate Client ---
|
|
130
|
+
if not run_generator(spec_path, OUTPUT_DIR, PACKAGE_NAME):
|
|
131
|
+
print("Client generation failed.", file=sys.stderr)
|
|
132
|
+
sys.exit(1)
|
|
133
|
+
|
|
134
|
+
# --- Write Version ---
|
|
135
|
+
if not write_version_file(version, VERSION_FILE):
|
|
136
|
+
sys.exit(1)
|
|
137
|
+
|
|
138
|
+
print(f"--- Client generation completed successfully for version: {version} ---")
|
|
139
|
+
print(f"Generated client code is in: {OUTPUT_DIR}")
|
|
140
|
+
print(f"Version file created at: {VERSION_FILE}")
|
|
141
|
+
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
main()
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from setuptools import setup, find_packages
|
|
7
|
+
from setuptools.command.build_py import build_py
|
|
8
|
+
from setuptools.command.egg_info import egg_info
|
|
9
|
+
from setuptools.command.sdist import sdist
|
|
10
|
+
|
|
11
|
+
# --- Configuration ---
|
|
12
|
+
PROJECT_ROOT = Path(__file__).parent.resolve()
|
|
13
|
+
SCRIPT_PATH = PROJECT_ROOT / "scripts" / "generate_client.py"
|
|
14
|
+
SPEC_ENV_VAR = "OPENAPI_SPEC_PATH"
|
|
15
|
+
VERSION_ENV_VAR = "PACKAGE_VERSION"
|
|
16
|
+
DEFAULT_SPEC_PATH = "specs/openapi.yaml"
|
|
17
|
+
DEFAULT_VERSION = "0.0.0.dev0"
|
|
18
|
+
# ---
|
|
19
|
+
|
|
20
|
+
def run_generation_script():
|
|
21
|
+
"""Runs the client generation script, getting config from env vars."""
|
|
22
|
+
spec_path = Path(os.environ.get(SPEC_ENV_VAR, DEFAULT_SPEC_PATH)).resolve()
|
|
23
|
+
version = os.environ.get(VERSION_ENV_VAR, DEFAULT_VERSION)
|
|
24
|
+
|
|
25
|
+
print("--- Running Pre-Build Client Generation ---", flush=True)
|
|
26
|
+
print(f"Using Spec Path: {spec_path} (Source: {'Env Var' if SPEC_ENV_VAR in os.environ else 'Default'})")
|
|
27
|
+
print(f"Using Version: {version} (Source: {'Env Var' if VERSION_ENV_VAR in os.environ else 'Default'})")
|
|
28
|
+
|
|
29
|
+
if not SCRIPT_PATH.is_file():
|
|
30
|
+
print(f"Error: Generation script not found at {SCRIPT_PATH}", file=sys.stderr, flush=True)
|
|
31
|
+
sys.exit(1)
|
|
32
|
+
|
|
33
|
+
if not spec_path.is_file() and SPEC_ENV_VAR not in os.environ:
|
|
34
|
+
# Only error if the *default* path doesn't exist AND the env var wasn't set
|
|
35
|
+
# If env var *was* set but file doesn't exist, generate_client.py will error out
|
|
36
|
+
print(f"Warning: Default spec file '{DEFAULT_SPEC_PATH}' not found and '{SPEC_ENV_VAR}' env var not set.", file=sys.stderr, flush=True)
|
|
37
|
+
print("Attempting build without generation. This might fail or use stale code.", file=sys.stderr, flush=True)
|
|
38
|
+
# Decide if you want to fail hard here instead:
|
|
39
|
+
# sys.exit(1)
|
|
40
|
+
return # Allow build to proceed, potentially failing later or using old code
|
|
41
|
+
|
|
42
|
+
if not spec_path.is_file() and SPEC_ENV_VAR in os.environ:
|
|
43
|
+
print(f"Warning: Spec file specified via {SPEC_ENV_VAR} ('{spec_path}') not found.", file=sys.stderr, flush=True)
|
|
44
|
+
print("Attempting build without generation. This might fail or use stale code.", file=sys.stderr, flush=True)
|
|
45
|
+
# Decide if you want to fail hard here instead:
|
|
46
|
+
# sys.exit(1)
|
|
47
|
+
return # Allow build to proceed, potentially failing later or using old code
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
command = [
|
|
51
|
+
sys.executable, # Use the same python interpreter that's running setup.py
|
|
52
|
+
str(SCRIPT_PATH),
|
|
53
|
+
"--spec-path", str(spec_path),
|
|
54
|
+
"--version", version
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
print(f"Executing: {' '.join(command)}", flush=True)
|
|
59
|
+
# Use check=True to raise CalledProcessError on failure
|
|
60
|
+
subprocess.run(command, check=True, text=True) #, capture_output=True) # capture can hide useful interactive output/errors
|
|
61
|
+
print("--- Client Generation Script Finished Successfully ---", flush=True)
|
|
62
|
+
except subprocess.CalledProcessError as e:
|
|
63
|
+
print("\n--- Client Generation Script Failed ---", file=sys.stderr, flush=True)
|
|
64
|
+
print(f"Command failed with exit code {e.returncode}", file=sys.stderr, flush=True)
|
|
65
|
+
# print("STDOUT:", file=sys.stderr, flush=True)
|
|
66
|
+
# print(e.stdout, file=sys.stderr, flush=True) # Often empty if text=True not fully compatible or error happens early
|
|
67
|
+
# print("STDERR:", file=sys.stderr, flush=True)
|
|
68
|
+
# print(e.stderr, file=sys.stderr, flush=True) # stderr might have more info
|
|
69
|
+
sys.exit(1) # Exit the build process if generation fails
|
|
70
|
+
except FileNotFoundError:
|
|
71
|
+
print(f"Error: Could not execute Python interpreter at '{sys.executable}' or script at '{SCRIPT_PATH}'.", file=sys.stderr, flush=True)
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# Custom command classes to ensure generation runs before standard commands
|
|
76
|
+
class CustomBuildPy(build_py):
|
|
77
|
+
def run(self):
|
|
78
|
+
run_generation_script()
|
|
79
|
+
super().run()
|
|
80
|
+
|
|
81
|
+
class CustomEggInfo(egg_info):
|
|
82
|
+
def run(self):
|
|
83
|
+
run_generation_script()
|
|
84
|
+
super().run()
|
|
85
|
+
|
|
86
|
+
class CustomSdist(sdist):
|
|
87
|
+
def run(self):
|
|
88
|
+
run_generation_script()
|
|
89
|
+
super().run()
|
|
90
|
+
|
|
91
|
+
# Run setup() with standard arguments and custom commands
|
|
92
|
+
setup(
|
|
93
|
+
# Most metadata is now in pyproject.toml
|
|
94
|
+
packages=find_packages(where='src'),
|
|
95
|
+
package_dir={'': 'src'},
|
|
96
|
+
cmdclass={
|
|
97
|
+
'build_py': CustomBuildPy,
|
|
98
|
+
'egg_info': CustomEggInfo,
|
|
99
|
+
'sdist': CustomSdist,
|
|
100
|
+
},
|
|
101
|
+
include_package_data=True,
|
|
102
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: perceptic-core-client
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python client for Perceptic Core
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: urllib3<3.0.0,>=2.1.0
|
|
11
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
12
|
+
Requires-Dist: pydantic>=2
|
|
13
|
+
Requires-Dist: typing-extensions>=4.7.1
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
17
|
+
Requires-Dist: ruff; extra == "dev"
|
|
18
|
+
Requires-Dist: mypy; extra == "dev"
|
|
19
|
+
Requires-Dist: build; extra == "dev"
|
|
20
|
+
Requires-Dist: requests; extra == "dev"
|
|
21
|
+
|
|
22
|
+
# Perceptic Core Python Client
|
|
23
|
+
|
|
24
|
+
This package provides a Python client for the Perceptic Core API.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
(Instructions will be added once packaging is set up)
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
(Example usage will be added)
|
|
33
|
+
|
|
34
|
+
## Building
|
|
35
|
+
|
|
36
|
+
This package requires Java and `openapi-generator-cli` to be installed for the build process, as it generates the client code from the OpenAPI specification during the build.
|
|
37
|
+
|
|
38
|
+
(Detailed build instructions will be added)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
scripts/generate_client.py
|
|
6
|
+
src/perceptic_core_client.egg-info/PKG-INFO
|
|
7
|
+
src/perceptic_core_client.egg-info/SOURCES.txt
|
|
8
|
+
src/perceptic_core_client.egg-info/dependency_links.txt
|
|
9
|
+
src/perceptic_core_client.egg-info/requires.txt
|
|
10
|
+
src/perceptic_core_client.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|