← All tasks
pythonwaditu/czsc #230Reported task

全新环境直接从github安装会出错

envgap__waditu__czsc-230

01 / FAILURE SIGNATURE

Captured in a clean container

ModuleNotFoundError: No module named 'rs_czsc'

02 / ENVIRONMENT RECIPE

Base commit
34f6bcd990c1f9c1e4225758ce67929f5e5efaf1
Manifest
requirements.txt
Reproduce
cd /tmp && python3 -c 'import numpy as np; import czsc; from czsc.utils.ta import SMA; out=SMA(np.array([1.,2.,3.,4.,5.]),timeperiod=3); assert abs(float(out[-1])-4.0)<1e-9; print('"'"'CZSC'"'"',czsc.__version__,'"'"'SMA'"'"',float(out[-1]))'
Run under trace
cd /tmp && python3 -c 'import numpy as np; import czsc; from czsc.utils.ta import SMA; out=SMA(np.array([1.,2.,3.,4.,5.]),timeperiod=3); assert abs(float(out[-1])-4.0)<1e-9; print('"'"'CZSC'"'"',czsc.__version__,'"'"'SMA'"'"',float(out[-1]))'
Reference environment fix used for admission
diff --git a/setup.py b/setup.py
index 2d7087f..02432a3 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,15 @@
 # coding: utf-8
-import czsc
+import ast
+from pathlib import Path
+from types import SimpleNamespace
+
+# Read literal package metadata without importing runtime dependencies during build.
+_metadata = {}
+for _node in ast.parse(Path(__file__).with_name("czsc").joinpath("__init__.py").read_text(encoding="utf-8")).body:
+    if isinstance(_node, ast.Assign) and len(_node.targets) == 1 and isinstance(_node.targets[0], ast.Name):
+        if _node.targets[0].id in {"__version__", "__author__", "__email__"}:
+            _metadata[_node.targets[0].id] = ast.literal_eval(_node.value)
+czsc = SimpleNamespace(**_metadata)
 from os import path
 from setuptools import setup, find_packages

03 / ORIGINAL ISSUE TEXT

waditu/czsc #230 · read the original issue
CMD: pip install git+https://github.com/waditu/czsc.git@V0.9.67 -U

Error message:

> Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
> Collecting git+https://github.com/waditu/czsc.git@V0.9.67
>   Cloning https://github.com/waditu/czsc.git (to revision V0.9.67) to /tmp/pip-req-build-zj9le4dr
>   Running command git clone --filter=blob:none --quiet https://github.com/waditu/czsc.git /tmp/pip-req-build-zj9le4dr
>   Running command git checkout -b V0.9.67 --track origin/V0.9.67
>   Switched to a new branch 'V0.9.67'
>   Branch 'V0.9.67' set up to track remote branch 'V0.9.67' from 'origin'.
>   Resolved https://github.com/waditu/czsc.git to commit 096251e6222631ad1eec7740ef304faea4f3146f
>   Installing build dependencies ... done
>   Getting requirements to build wheel ... error
>   error: subprocess-exited-with-error
> 
>   × Getting requirements to build wheel did not run successfully.
>   │ exit code: 1
>   ╰─> [22 lines of output]
>       Traceback (most recent call last):
>         File "/home/eiffel/anaconda3/envs/py312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
>           main()
>         File "/home/eiffel/anaconda3/envs/py312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
>           json_out["return_val"] = hook(**hook_input["kwargs"])
>                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>         File "/home/eiffel/anaconda3/envs/py312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
>           return hook(config_settings)
>                  ^^^^^^^^^^^^^^^^^^^^^
>         File "/tmp/pip-build-env-qydka85c/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
>           return self._get_build_requires(config_settings, requirements=[])
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>         File "/tmp/pip-build-env-qydka85c/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
>           self.run_setup()
>         File "/tmp/pip-build-env-qydka85c/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 512, in run_setup
>           super().run_setup(setup_script=setup_script)
>         File "/tmp/pip-build-env-qydka85c/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
>           exec(code, locals())
>         File "<string>", line 2, in <module>
>         File "/tmp/pip-req-build-zj9le4dr/czsc/__init__.py", line 7, in <module>
>           from rs_czsc import (
>       ModuleNotFoundError: No module named 'rs_czsc'
>       [end of output]
> 
>   note: This error originates from a subprocess, and is likely not a problem with pip.
> error: subprocess-exited-with-error
> 
> × Getting requirements to build wheel did not run successfully.
> │ 
Continue on GitHub ↗

04 / LABELS

Labels checked by running the task · assistant reviewed

misspecificationunderspecification
Label rules and the text that matched
[
  {
    "category": "misspecification",
    "rule": "diff.changes_existing_manifest_line",
    "source": "manifest_diff:setup.py",
    "excerpt": "-import czsc\n+import ast\n+from pathlib import Path\n+from types import SimpleNamespace\n+\n+# Read literal package metadata without importing runtime dependencies during build.\n+_metadata = {}\n+for _node in ast.parse(Path(__file__).with_name(\"czsc\").joinpath(\"__init__.py\").read_text(encoding=\"utf-8\")).body:\n+    if isinstance(_node, ast.Assign) and len(_node.targets) == 1 and isinstance(_node.targets[0], ast.Name):\n+        if _node.targets[0].id in {\"__version__\", \"__author__\", \"__email__\"}:\n+            _metadata[_node.targets[0].id] = ast.literal_eval(_node.value)\n+czsc = SimpleNamespace(**_metadata)"
  },
  {
    "category": "underspecification",
    "rule": "diff.adds_omitted_runtime_requirement",
    "source": "manifest_diff:setup.py",
    "excerpt": "__author__, __email__, __init__.py, __version__, czsc, utf-8"
  }
]

Historical install-only results are not EnvGap validation.

The issue reports V0.9.67; this instance uses the required current-default-branch commit before the issue timestamp, version0.9.68, with the same setup.py import defect.

All runtime requirements are retained. Gold changes only the packaging metadata extraction; application source is unchanged.

This tests local import and numerical indicator computation, not market-data downloads or broker connections.

Preparation uses current registries. Historical package availability is not enforced here; execution metadata records this limitation separately from the oracle's date-bounding policy.