pypa / setuptools-scm

the blessed package to manage your versions by scm tags
https://setuptools-scm.readthedocs.io/en/latest/
MIT License
859 stars 211 forks source link

LookupError: setuptools-scm was unable to detect version for #697

Closed 103-5 closed 2 years ago

103-5 commented 2 years ago

Sorry for bothering you while similar threads already exist (https://github.com/pypa/setuptools_scm/issues/536), but these methods not work in my case. I'm trying to install setup.py from https://github.com/GENESIS-EFRC/reaction-network in the python virtual environment 3.8 in conda. The original setup.py is:

 #!/usr/bin/env` python
from pathlib import Path
from setuptools import find_packages, setup
module_dir = Path(__file__).resolve().parent
with open(module_dir / "README.md") as f:
    long_desc = f.read()
setup(
    name="reaction-network",
    use_scm_version=True,
    setup_requires=["setuptools_scm"],
    description="Reaction-network is a Python package for predicting likely inorganic "
    "chemical reaction pathways using graph theory.",
    long_description=long_desc,
    long_description_content_type="text/markdown",
    url="https://github.com/GENESIS-EFRC/reaction-network",
    author="Matthew McDermott",
    author_email="mcdermott@lbl.gov",
    maintainer="Matthew McDermott",
    license="modified BSD",
    packages=find_packages("src"),
    package_dir={"": "src"},
    package_data={"rxn_network": ["py.typed"]},
    zip_safe=False,
    include_package_data=True,
    install_requires=[
        "setuptools",
        "pymatgen>=2022.0.16",
        "fireworks>=1.9.7",
        "maggma>=0.38.1",
        "numba>=0.53.0",
    ],
    extra_requires={"demo": ["jupyter>=1.0.0"]},
    classifiers=[
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Development Status :: 4 - Beta",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: BSD License",
        "Operating System :: OS Independent",
        "Topic :: Scientific/Engineering :: Information Analysis",
        "Topic :: Scientific/Engineering :: Physics",
        "Topic :: Scientific/Engineering :: Chemistry",
        "Topic :: Software Development :: Libraries :: Python Modules",
    ],
    tests_require=["pytest"],
    python_requires=">=3.8",
)

And the error information looks like this:

> C:\Users\86134>activate py37
(py37) C:\Users\86134>cd ipbes-analysis\ipbes-ndr
(py37) C:\Users\86134\ipbes-analysis\ipbes-ndr>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    language="c++",
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "F:\Anaconda3\envs\py37\lib\distutils\core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 433, in __init__
    k: v for k, v in attrs.items()
  File "F:\Anaconda3\envs\py37\lib\distutils\dist.py", line 292, in __init__
    self.finalize_options()
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 708, in finalize_options
    ep(self)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 715, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\integration.py", line 26, in version_keyword
    dist.metadata.version = _get_version(config)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\__init__.py", line 173, in _get_version
    parsed_version = _do_parse(config)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\__init__.py", line 142, in _do_parse
    "use git+https://github.com/user/proj.git#egg=proj" % config.absolute_root
LookupError: setuptools-scm was unable to detect version for 'C:\\Users\\86134\\ipbes-analysis\\ipbes-ndr'.
Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

I've tried to modify the "use_scm_version" term but still failed to fix this issue. It will be a great help if someone familiar with setuptools can give me some advices about how to get a correct setup.py

Thank you.

RonnyPfannschmidt commented 2 years ago

Going by the output there is a strangely name mangled file in the traceback that doesn't belong to setuptools_scm

Please list the packages installed that have setuptools in their name

RonnyPfannschmidt commented 2 years ago

with the code corrected it seems a normal issue

run SETUPTOOLS_SCM_DEBUG=1 python setup.py --version

also these days i strongly recommend using a installer over using setup.py install pip and others sort a number of issues that can happen in normal development

103-5 commented 2 years ago

@RonnyPfannschmidt Hi Ronny, thanks for your reply. I use python virtual environment 3.8 in conda and conda list shows that I've installed two packages related to setuptools

setuptools 61.2.0 pypi_0 pypi setuptools-scm 6.4.2 pypi_0 pypi

I tried SETUPTOOLS_SCM_DEBUG=1 python setup.py --version and got the following result.

(gt8) root@iZ8vb98m8jfeytc3k1bao2Z:/reaction-network-4.3.0# SETUPTOOLS_SCM_DEBUG=1 python setup.py --version /root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/dist.py:757: UserWarning: Usage of dash-separated 'index-url' will not be supported in future versions. Please use the underscore name 'index_url' instead warnings.warn( /root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'extra_requires' warnings.warn(msg) version keyword {'name': 'reaction-network', 'version': None, 'author': 'Matthew McDermott', 'author_email': 'mcdermott@lbl.gov', 'maintainer': 'Matthew McDermott', 'maintainer_email': None, 'url': 'https://github.com/GENESIS-EFRC/reaction-network', 'license': 'modified BSD', 'description': 'Reaction-network is a Python package for predicting likely inorganic chemical reaction pathways using graph theory.', 'long_description': '# ![Reaction Network](docs/images/logo.png)\n\n[![Pytest Status](https://github.com/GENESIS-EFRC/reaction-network/workflows/testing/badge.svg)](https://github.com/GENESIS-EFRC/reaction-network/actions?query=workflow%3Atesting)\n[![Code Coverage](https://codecov.io/gh/GENESIS-EFRC/reaction-network/branch/main/graph/badge.svg)](https://codecov.io/gh/GENESIS-EFRC/reaction-network)\n\nReaction network (rxn-network) is a Python package for predicting chemical reaction\npathways in solid-state materials synthesis using combinatorial and graph-theorteical methods.\n\n# Installation directions\n\nThe rxn-network package has several dependencies, most of which can be installed\nthrough PyPI. However, graph-tool must be installed through a more customized method;\nplease see https://graph-tool.skewed.de/ for more details. We recommend the\nfollowing installation procedure which creates a new conda environment with Python 3.9,\nactivates it, and then installs graph-tool through conda-forge.\n\n```properties\nconda create -n gt python=3.9\nconda activate gt\nconda install -c conda-forge graph-tool\n```\n\nTo install an editable version of the rxn-network code, simply download (clone) the\ncode from this repository, navigate to its directory, and then run the\nfollowing command to install the requirements:\n\n```properties\npip install -r requirements.txt\npip install -e .\n```\n\n# Tutorial notebooks\n\nThenotebooksfolder contains two (2) demonstration notebooks: \n- **enumerators.ipynb**: how to enumerate reactions from a set of entries; running\n enumerators using Fireworks\n- **network.ipynb**: how to build reaction networks from a list of enumerators and\n entries; how to perform pathfinding to recommend balanced reaction pathways; running\n reaction network analysis using Fireworks\n\n# Citation \n\nIf you use this code or Python package in your work, please consider citing the following paper:\n\n> McDermott, M. J., Dwaraknath, S. S., and Persson, K. A. (2021). A graph-based network for predicting chemical reaction pathways in solid-state materials synthesis. Nature Communications, 12(1). https://doi.org/10.1038/s41467-021-23339-x\n\n\n# Acknowledgements\n\nThis work was supported as part of GENESIS: A Next Generation Synthesis Center, an\nEnergy Frontier Research Center funded by the U.S. Department of Energy, Office of\nScience, Basic Energy Sciences under Award Number DE-SC0019212.\n\nLearn more about the GENESIS EFRC here: https://www.stonybrook.edu/genesis/\n', 'keywords': None, 'platforms': None, 'classifiers': ['Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: Scientific/Engineering :: Physics', 'Topic :: Scientific/Engineering :: Chemistry', 'Topic :: Software Development :: Libraries :: Python Modules'], 'download_url': None, 'provides': None, 'requires': None, 'obsoletes': None} abs root {'root': '.', 'relative_to': None} root '/reaction-network-4.3.0' relative_to None dist name: reaction-network version_from_ep setuptools_scm.parse_scm /reaction-network-4.3.0 looking for ep setuptools_scm.parse_scm /reaction-network-4.3.0 version_from_ep setuptools_scm.parse_scm_fallback /reaction-network-4.3.0 looking for ep setuptools_scm.parse_scm_fallback /reaction-network-4.3.0 found ep EntryPoint(name='setup.py', value='setuptools_scm.hacks:fallback_version', group='setuptools_scm.parse_scm_fallback') in /reaction-network-4.3.0 EntryPoint(name='setup.py', value='setuptools_scm.hacks:fallback_version', group='setuptools_scm.parse_scm_fallback') None Traceback (most recent call last): File "setup.py", line 12, in <module> setup( File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup return distutils.core.setup(**attrs) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 109, in setup _setup_distribution = dist = klass(attrs) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/dist.py", line 462, in __init__ _Distribution.__init__( File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 293, in __init__ self.finalize_options() File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/dist.py", line 886, in finalize_options ep(self) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools/dist.py", line 907, in _finalize_setup_keywords ep.load()(self, ep.name, value) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools_scm/integration.py", line 75, in version_keyword _assign_version(dist, config) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools_scm/integration.py", line 51, in _assign_version _version_missing(config) File "/root/anaconda3/envs/gt8/lib/python3.8/site-packages/setuptools_scm/__init__.py", line 106, in _version_missing raise LookupError( LookupError: setuptools-scm was unable to detect version for /reaction-network-4.3.0. Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work. For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

RonnyPfannschmidt commented 2 years ago

Is this in a docker container that lacks the git folder?

103-5 commented 2 years ago

Is this in a docker container that lacks the git folder?

Oh, that is exactly why I get these errors. The downloaded zip misses .git folder. Fortunately, by using the git clone command, the .git folder appears and the installation completes smoothly :D Thanks for your help! You saved my day!

RonnyPfannschmidt commented 2 years ago

thanks, closing as solved then