3

I have two or more Python packages in one versioned folder:

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

From both ./api and pkg python package pip install -e . work well but pip install . give me the traceback:

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.

My 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$

What could be a temporary workaround ?

I saw that there is an open issue related to that: https://github.com/pypa/setuptools_scm/issues/357

gerrit
  • 24,025
  • 17
  • 97
  • 170
user3313834
  • 7,327
  • 12
  • 56
  • 99
  • I had the same issue and fix it with the command **pip install --use-feature=in-tree-build .** – daniboy000 Jul 01 '21 at 21:37
  • 1
    in https://github.com/pypa/setuptools_scm/issues/357 they propose: SETUPTOOLS_SCM_PRETEND_VERSION="$(python3 setup.py --version)" pip install . – user3313834 Dec 19 '21 at 17:35

1 Answers1

1

You have to use in-tree-build feature. It's enabled by default in newer pip releases. There are two solutions:

  1. update pip:
pip install -U pip
pip install .
  1. or use the feature directly:
pip install --use-feature=in-tree-build .
  • It seems this feature was implemented in pip at some point, but it has been reverted and this approach no longer works (see https://github.com/pypa/setuptools_scm/issues/357). – tdpu Jun 20 '22 at 19:04