Skip to content

pyfolio-0.9.2.tar.gz #1320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Jason-ship opened this issue Feb 21, 2025 · 1 comment
Open

pyfolio-0.9.2.tar.gz #1320

Jason-ship opened this issue Feb 21, 2025 · 1 comment

Comments

@Jason-ship
Copy link

Using cached pyfolio-0.9.2.tar.gz (91 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
/private/var/folders/fh/htk44s8s3zn1_r69580xb8f80000gn/T/pip-install-xry9fjhj/pyfolio_56a77d3c176b4d7f9fcc6280843d200f/versioneer.py:468: SyntaxWarning: invalid escape sequence '\s'
LONG_VERSION_PY['git'] = '''
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/private/var/folders/fh/htk44s8s3zn1_r69580xb8f80000gn/T/pip-install-xry9fjhj/pyfolio_56a77d3c176b4d7f9fcc6280843d200f/setup.py", line 71, in
version=versioneer.get_version(),
^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fh/htk44s8s3zn1_r69580xb8f80000gn/T/pip-install-xry9fjhj/pyfolio_56a77d3c176b4d7f9fcc6280843d200f/versioneer.py", line 1407, in get_version
return get_versions()["version"]
^^^^^^^^^^^^^^
File "/private/var/folders/fh/htk44s8s3zn1_r69580xb8f80000gn/T/pip-install-xry9fjhj/pyfolio_56a77d3c176b4d7f9fcc6280843d200f/versioneer.py", line 1341, in get_versions
cfg = get_config_from_root(root)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fh/htk44s8s3zn1_r69580xb8f80000gn/T/pip-install-xry9fjhj/pyfolio_56a77d3c176b4d7f9fcc6280843d200f/versioneer.py", line 399, in get_config_from_root
parser = configparser.SafeConfigParser()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

从你给出的错误信息来看,在安装 pyfolio-0.9.2 时,由于 versioneer.py 文件里使用了 Python 2 中已弃用的 SafeConfigParser 类,而在 Python 3 中该类已不存在,从而引发了 AttributeError。以下是针对开发者的一些建议:

代码层面

  1. 更新代码以适配 Python 3
    • versioneer.py 文件中所有使用 SafeConfigParser 的地方替换为 ConfigParser,因为在 Python 3 里 ConfigParser 替代了 SafeConfigParser。示例如下:
# 原代码
parser = configparser.SafeConfigParser()

# 修改后的代码
parser = configparser.ConfigParser()
- 同时,处理代码中存在的 `SyntaxWarning`,例如 `invalid escape sequence '\s'`。可以使用原始字符串(在字符串前加 `r`)来避免这种警告,如 `LONG_VERSION_PY['git'] = r'''`。
  1. 版本兼容性检查
    • setup.py 或者项目的 README 文件中,明确标注项目支持的 Python 版本范围。并且在代码里添加版本兼容性检查逻辑,当用户使用不兼容的 Python 版本安装时,给出清晰的错误提示。示例代码如下:
import sys

if sys.version_info < (3, 0):
    raise RuntimeError("pyfolio requires Python 3 or higher.")
  1. 使用现代的打包工具和规范
    • 考虑使用 pyproject.toml 来替代传统的 setup.pypyproject.toml 是 Python 社区推荐的项目配置文件,它可以更好地管理项目的依赖和构建配置。同时,遵循 PEP 517 和 PEP 518 规范,确保项目在不同的 Python 环境中都能正确构建和安装。

文档层面

  1. 更新安装说明
    • 在项目的 README 文件或者官方文档中,明确指出安装项目所需的 Python 版本和依赖项。如果有特定的安装步骤或者注意事项,也要详细说明。
    • 对于可能出现的兼容性问题,提供相应的解决方案和错误处理指南。
  2. 添加版本更新日志
    • 维护一个详细的版本更新日志,记录每个版本的改动内容,包括修复的 bug、新增的功能以及兼容性方面的变化。这样用户在升级或者安装特定版本时,可以清楚地了解版本之间的差异。

测试和反馈机制

  1. 自动化测试
    • 建立完善的自动化测试体系,使用工具如 pytest 对项目进行单元测试、集成测试和兼容性测试。确保在不同的 Python 版本和操作系统环境下,项目都能正常运行。
    • 利用持续集成(CI)工具(如 GitHub Actions、Travis CI 等),在每次代码提交时自动运行测试,及时发现和解决兼容性问题。
  2. 用户反馈渠道
    • 提供方便的用户反馈渠道,如 GitHub 的 Issues 页面、项目的官方论坛或者邮件列表。鼓励用户在遇到问题时及时反馈,开发者可以根据用户反馈快速修复问题。

通过以上建议,开发者可以提高 pyfolio 项目的兼容性和稳定性,减少用户在安装和使用过程中遇到的问题。

@zhumingpassional
Copy link
Collaborator

Thanks for your valuable suggestions.

You can submit a PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants