Skip to content
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

自行打包报错 #48

Closed
devome opened this issue Jun 14, 2024 · 12 comments
Closed

自行打包报错 #48

devome opened this issue Jun 14, 2024 · 12 comments

Comments

@devome
Copy link

devome commented Jun 14, 2024

Arch Linux使用系统本地Python 3.12,已在系统本地中安装好setuptools build wheel这几个pip包(不是虚拟环境),然后在仓库根目录执行python -m build --wheel --no-isolation -v来打包,但是报错:

* Getting build dependencies for wheel...
validate_pyproject.api.load_builtin_plugin defines `tool.distutils` schema
validate_pyproject.api.load_builtin_plugin defines `tool.setuptools` schema
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/packaging/requirements.py", line 35, in __init__
    parsed = _parse_requirement(requirement_string)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 64, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_parser.py", line 73, in _parse_requirement
    name_token = tokenizer.expect(
                 ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_tokenizer.py", line 140, in expect
    raise self.raise_syntax_error(f"Expected {expected}")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/_tokenizer.py", line 165, in raise_syntax_error
    raise ParserSyntaxError(
packaging._tokenizer.ParserSyntaxError: Expected package name at the start of dependency specifier
    -r basic.txt
    ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module>
    main()
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 134, in get_requires_for_build_wheel
    return hook(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 159, in setup
    dist.parse_config_files()
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 627, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 73, in apply_configuration
    return _apply(dist, config, filepath)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 62, in apply
    dist._finalize_requires()
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 364, in _finalize_requires
    self._normalize_requires()
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 381, in _normalize_requires
    k: list(map(str, _reqs.parse(v or []))) for k, v in extras_require.items()
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/packaging/requirements.py", line 37, in __init__
    raise InvalidRequirement(str(e)) from e
packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier
    -r basic.txt
    ^

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
@rexzhang
Copy link
Owner

刚刚我在macOS(Py3.12.3)测试了python -m build --wheel --no-isolation -v,能够正常打包.会不会是系统环境或者工具版本问题?试试用python -m venv venv创建一个虚环境试试?

另外,开报错的日志,应该是对requirements中的-r basic.txt这种格式解析错误

@devome
Copy link
Author

devome commented Jun 15, 2024

建了个虚拟环境,还是提示一样的错误。难道Arch Linux不支持读取-r来打包?

@rexzhang
Copy link
Owner

rexzhang commented Jun 15, 2024

我在Debian(AMD64)12.5/python3.11.2环境下用完全一样的命令测试了下,也是没有问题的

~/asgi-webdav# uname -a
Linux test 6.6.29-production+truenas #1 SMP PREEMPT_DYNAMIC Wed May 29 15:05:57 UTC 2024 x86_64 GNU/Linux

~/asgi-webdav# cat /etc/debian_version
12.5

~/asgi-webdav# python3 --version
Python 3.11.2

~/asgi-webdav# pip list
Package         Version
--------------- -------
build           1.2.1
packaging       24.1
pip             23.0.1
pyproject_hooks 1.1.0
setuptools      70.0.0
wheel           0.43.0

@devome
Copy link
Author

devome commented Jun 15, 2024

我知道了,我先 git checkout v1.4.0到v1.4.0这个tag下去了,在这个tag下不能成功打包,只有在main主线分支下打包才行。

@rexzhang
Copy link
Owner

这有点奇怪,不过也不用管了

@devome
Copy link
Author

devome commented Jun 15, 2024

用过这么多webdav服务程序,还是你的功能最全最好用。

经过努力,终于把asgi-webdav打包到AUR上了,其中asgi-webdav如果使用github上的tag,需要加上这个补丁,索性最后直接用pypi上的压缩包了。

https://aur.archlinux.org/packages/python-asgi-middleware-static-file
https://aur.archlinux.org/packages/python-asgi-webdav

现在Arch Linux用户可以直接一句命令安装了:paru -S python-asgi-webdav

@devome
Copy link
Author

devome commented Jun 15, 2024

顺便想问一下,如果不安装 uvicorn uvloop httptools这三个包会有什么影响吗?我看它们在pyproject.toml中是可选项,我没装好像也能跑?

@rexzhang
Copy link
Owner

rexzhang commented Jun 15, 2024

你的目的是什么?如果只是使用库,直接 pip 安装即可

@devome
Copy link
Author

devome commented Jun 15, 2024

Arch Linux 的依赖申明,一类是必须的依赖,一类是可选依赖。具体的文件在这里:https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python-asgi-webdav 。Arch Linux如果安装在系统中不能使用pip来安装。

@rexzhang
Copy link
Owner

如果你需要深入讨论,可以专门开一个issue,或者重新打开这个,现在这样很奇怪

@rexzhang
Copy link
Owner

另外,可能是大半夜的原因,漏看了你是为了「把asgi-webdav打包到AUR上」

  • uvicorn 是 ASGI server 实现
  • uvloop httptools 都是提升为了 ASGI Server 的性能的扩展,asgi-webdav并不依赖
  • 推荐 pip install -U ASGIWebDAV[full] 的方式安装
  • 如果不是特别应用场景自行打包是不建议的,因为项目未来演进你很难随时跟踪和同步,不可持续

我把 issue 重新打开了,如果交流完毕你可以自行关闭

@rexzhang rexzhang reopened this Jun 16, 2024
@devome
Copy link
Author

devome commented Jun 16, 2024

好的,我明白了,那我现在的打包方式是合理的,谢谢了。

@devome devome closed this as completed Jun 16, 2024
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