3

我在一个版本化文件夹中有两个或多个 Python 包:

.
├── .git
├── api
│   ├── mf_hub_api
│   │   └── __init__.py
│   └── setup.py
├── pkg
│   ├── mf_hub
│   │   └── __init__.py
│   └── setup.py
└── README.rst

./api 和 pkg python 包都运行pip install -e .良好,但pip install .给我回溯:

mf_hub/pkg$ pip install .
Processing .../mf_hub/pkg
...
LookupError: setuptools-scm was unable to detect version for '/tmp'.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我的config.py::

mf_hub$ cat pkg/setup.py
from setuptools import find_packages
from setuptools import setup

requirements = """
pip
setuptools
wheel
setuptools_scm
"""

setup(
    name="mf_hub",
    setup_requires=["setuptools_scm"],
    use_scm_version={
        "write_to": "../version.txt",
        "root": "..",
        "relative_to": __file__,
    },
    packages=find_packages(),
    test_suite="tests",
    install_requires=requirements,
    include_package_data=True,
    zip_safe=False,
)
mf_hub$

什么可能是临时解决方法?

我看到有一个与此相关的未解决问题:https ://github.com/pypa/setuptools_scm/issues/357

4

1 回答 1

1

你必须使用in-tree-build功能。它在较新的 pip 版本中默认启用。有两种解决方案:

  1. 更新点:
pip install -U pip
pip install .
  1. 或直接使用该功能:
pip install --use-feature=in-tree-build .
于 2021-12-17T10:28:00.487 回答