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

Building using a pyproject.toml results in version being 0.0.0.0 #636

Closed
WhyNotHugo opened this issue Sep 20, 2021 · 13 comments
Closed

Building using a pyproject.toml results in version being 0.0.0.0 #636

WhyNotHugo opened this issue Sep 20, 2021 · 13 comments

Comments

@WhyNotHugo
Copy link
Contributor

I'm using a pyproject.toml that's pretty much like the example in the documentation.

My relevant setup.cfg and setup.py.

When I run python setup.py dist, the resulting wheel has version 0.0.0. If I use python -m build, the version is correct (e.g.: it's determined based on the git-tag as expected).

Is using setup.py sdist no longer supported, or is there something wrong with my setup?

@RonnyPfannschmidt
Copy link
Contributor

At first glance likely a issue with setuptools versions,
Too old setuptools breaks all the things, build can also do working sdists

Im not sure when I can debug more, but as a first item update setuptools_scm and setuptools with pip and try again

@RonnyPfannschmidt
Copy link
Contributor

@WhyNotHugo it seems that by switching to build you resolved the issue, can i close?

@thetic
Copy link

thetic commented Oct 14, 2021

I encounter the same issue with the latest setuptools and setuptools_scm.

@hameerabbasi
Copy link

I have the same issue, project repo at the exact commit. It seems even python -m build --sdist produces an sdist that then installs as package-0.0.0 instead of the correct version. python setup.py sdist produces package-0.0.0.tar.gz. In addition, setuptools and setuptools_scm is up-to-date.

Here's my environment
❯ mamba list
# packages in environment at /Users/hameerabbasi/mambaforge/envs/uarray:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                     py_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
black                     21.12b0            pyhd8ed1ab_0    conda-forge
bleach                    4.1.0              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py310he24745e_1003    conda-forge
build                     0.7.0              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
ca-certificates           2021.10.8            h033912b_0    conda-forge
certifi                   2021.10.8       py310h2ec42d9_1    conda-forge
cffi                      1.15.0          py310hcc37b68_0    conda-forge
chardet                   4.0.0           py310h2ec42d9_2    conda-forge
charset-normalizer        2.0.10             pyhd8ed1ab_0    conda-forge
click                     8.0.3           py310h2ec42d9_1    conda-forge
cmarkgfm                  0.7.0           py310he24745e_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
coverage                  6.2             py310he24745e_0    conda-forge
cryptography              36.0.1          py310ha82f1d4_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
doc8                      0.10.1             pyhd8ed1ab_0    conda-forge
docutils                  0.17.1          py310h2ec42d9_1    conda-forge
flake8                    4.0.1              pyhd8ed1ab_0    conda-forge
idna                      3.1                pyhd3deb0d_0    conda-forge
imagesize                 1.3.0              pyhd8ed1ab_0    conda-forge
importlib-metadata        4.10.0          py310h2ec42d9_0    conda-forge
importlib_metadata        4.10.0               hd8ed1ab_0    conda-forge
iniconfig                 1.1.1              pyh9f0ad1d_0    conda-forge
jinja2                    3.0.3              pyhd8ed1ab_0    conda-forge
keyring                   23.4.0          py310h2ec42d9_0    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libzlib                   1.2.11            h9173be1_1013    conda-forge
markupsafe                2.0.1           py310he24745e_1    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
more-itertools            8.12.0             pyhd8ed1ab_0    conda-forge
mypy_extensions           0.4.3           py310h2ec42d9_4    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
openssl                   1.1.1l               h0d85af4_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pbr                       5.8.0              pyhd8ed1ab_1    conda-forge
pep517                    0.12.0          py310h2ec42d9_1    conda-forge
pip                       21.3.1             pyhd8ed1ab_0    conda-forge
pkginfo                   1.8.2              pyhd8ed1ab_0    conda-forge
platformdirs              2.3.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0           py310h2ec42d9_2    conda-forge
py                        1.11.0             pyh6c4a22f_0    conda-forge
pycodestyle               2.8.0              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyflakes                  2.4.0              pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pyopenssl                 21.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.6              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1           py310h2ec42d9_4    conda-forge
pytest                    6.2.5           py310h2ec42d9_2    conda-forge
pytest-black              0.3.12                     py_0    conda-forge
pytest-cov                3.0.0              pyhd8ed1ab_0    conda-forge
pytest-flake8             1.0.7              pyhd3deb0d_0    conda-forge
python                    3.10.2          h1248fe1_0_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
pytz                      2021.3             pyhd8ed1ab_0    conda-forge
readline                  8.1                  h05e3726_0    conda-forge
readme_renderer           27.0               pyh9f0ad1d_0    conda-forge
regex                     2021.11.10      py310he24745e_0    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
requests-toolbelt         0.9.1                      py_0    conda-forge
restructuredtext_lint     1.3.2              pyhd3deb0d_0    conda-forge
rfc3986                   2.0.0              pyhd8ed1ab_0    conda-forge
setuptools                60.5.0          py310h2ec42d9_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snowballstemmer           2.2.0              pyhd8ed1ab_0    conda-forge
sphinx                    4.3.2              pyh6c4a22f_0    conda-forge
sphinx_rtd_theme          1.0.0              pyhd8ed1ab_0    conda-forge
sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_0    conda-forge
sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
sphinxcontrib-serializinghtml 1.1.5              pyhd8ed1ab_1    conda-forge
sqlite                    3.37.0               h23a322b_0    conda-forge
stevedore                 3.5.0           py310h2ec42d9_2    conda-forge
tk                        8.6.11               h5dbffcc_1    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     1.2.2              pyhd8ed1ab_0    conda-forge
tqdm                      4.62.3             pyhd8ed1ab_0    conda-forge
twine                     3.7.1              pyhd8ed1ab_0    conda-forge
typed-ast                 1.5.1           py310he24745e_0    conda-forge
typing_extensions         4.0.1              pyha770c72_0    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
uarray                    0.8.8                     dev_0    <develop>
urllib3                   1.26.8             pyhd8ed1ab_1    conda-forge
versioneer                0.21               pyhd8ed1ab_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zipp                      3.7.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h9173be1_1013    conda-forge

@RonnyPfannschmidt
Copy link
Contributor

Ill geht to this this afternoon, i believe it may require setuptools newer than 52 as well as setuptools_scm master

@hameerabbasi
Copy link

Here's some data: It seems one really needs setuptools_scm in the environment before running sdist or bdist_wheel, otherwise the version produced is really just 0.0.0.

@kasium
Copy link

kasium commented Mar 15, 2022

I can also reproduce the issue with the latest versions of pip, wheel, setuptools and setuptools-scm

@RonnyPfannschmidt
Copy link
Contributor

Basically setup.py has no way of getting the deps

Never invoke setup. Py, always use build or pip

The docs should recommend a stock setup.py that errors better

@hameerabbasi
Copy link

Should I open a new issue for the python -m build bug?

@ulidtko
Copy link

ulidtko commented May 24, 2022

Hitting the same issue. Followed the docs; version is 0.0.0 no matter which way I build: ./setup.py build, ./setup.py wheel, ./setup.py bdist, pip install . — all yield the same result: version 0.0.0.

python -m build says No module named build.__main__; 'build' is a package and cannot be directly executed

Curiously:

 $ python -m setuptools_scm
 /home/ulidtko/src/acme/project/venv/bin/python: No module named setuptools_scm

I can of course fix this by pip install setuptools_scm... However:

  • this does not fix the issue, version 0.0.0 stays;
  • I do have setuptools_scm[toml] >= 6.2, < 7 both in setup.cfg options.setup_requires and pyproject.toml build-system.requires. Neither is effective, setuptools_scm does not get installed.

Pip 22.0.4, setuptools 58.1.0, Python 3.10.

Upgrading to latest pip 22.1.0 & setuptools 62.3.2 does not help:

(venv)  ~/s/a/project> pip --version
pip 22.1.1 from /home/ulidtko/src/acme/project/venv/lib/python3.10/site-packages/pip (python 3.10)
(venv)  ~/s/a/project> pip show setuptools | grep -i version
Version: 62.3.2
(venv)  ~/s/a/project> ./setup.py --version
/home/ulidtko/src/acme/project/venv/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
  warnings.warn(
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
0.0.0
(venv)  ~/s/a/project> /bin/cat setup.py
#!/usr/bin/env python3

from setuptools import setup

setup()

I do get correct version returned from python -c 'import setuptools_scm; print(setuptools_scm.get_version())' — after hand-installing the "build-dependency" package. But even after that (and even after pip install wheel) — ./setup.py --version yields strictly 0.0.0.

Adding --verbose everywhere — does not produce much helpful hints.

Any suggestions?

@ulidtko
Copy link

ulidtko commented May 24, 2022

Solved.

There was a typo in my pyproject.toml: [tools.setuptools_scm] — and it was not being detected nor reported. Correct spelling: [tool.setuptools.scm].

... Next issue.

https://github.com/pypa/setuptools_scm/blob/ca3855ba66fa4cb100f5039eea909932f815a4a4/src/setuptools_scm/git.py#L198-L202

This code ☝️ obviously breaks on this (by all documented means, legitimate) config:

[tool.setuptools_scm]
git_describe_command = "git describe --always --long --dirty=-uncommitted --abbrev=7 --match 'v*'"

Removing --dirty=-uncommitted (especially after all of the above) leaves a salty feeling, but does help. After half a day of "fun", I'm getting the expected git tag version.

@RonnyPfannschmidt
Copy link
Contributor

closing as unplanned, my understanding is that the initial issue is resolved

a number of other comments are either new issues (that i will not create) or configuration mistakes

i will create extra cards for failing on custom describe commands that are outside of what can be handled

@jamesbraza
Copy link
Contributor

For posterity (and sorry for grave digging, but I was hitting this with python setup.py sdist tonight).

What I was seeing:

creating UNKNOWN-0.0.0
creating UNKNOWN-0.0.0/UNKNOWN.egg-info
...

As you can see, both the name and version weren't there! 😭

My Setup

MANIFEST.in

include pkgname/py.typed

pyproject.toml

[build-system]
requires = ["setuptools>=62.6", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "pkgname"
dynamic = ["version", "dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools_scm]
root = ".."

setup.py

setup(
    ...,
    include_package_data=True,
)
My Solution

I had setuptools==58.1.0, pip==22.2, pkgname==0.1.1.dev41..., and no setuptools_scm in my environment.

From #487 (comment), remember to have your pkgname installed when working with sdist.

Here were a few possible fixes I came across.

Fixing version propagation but not name:

  • pip install setuptools_scm
  • Adding setup_requires=["setuptools_scm"] to setup

Fixing name propagation but not version:

  • pip install -U setuptools>=62.6 (and we now get shown a bunch of warnings)
  • NOT adding setup_requires=["setuptools>=62.6"] to setup, this leads to ModuleNotFoundError: No module named 'setuptools.command.build'

How I fixed both:

  • pip install -U setuptools>=62.6
  • Adding setup_requires=["setuptools_scm"] to setup

I am not sure how to have setuptools>=62.6 requirement built-into setup, since I already have that called out in my [build-system]'s requires list, and calling it out in setup_requires blew up with ModuleNotFoundError...


Correct spelling: [tool.setuptools.scm].

I don't believe this is correct. The README.rst docs don't mention this, and I actually got errors if I used this.


And in other news, python -m build works without any changes, as both the OP and this answer suggest. Cheers!

doronbehar added a commit to doronbehar/pyrp3 that referenced this issue Aug 2, 2024
If trying to install this package in an offline manner (see also:
linien-org/linien#378 ), the metadata pip will
put for this installation might be 0.0.0, due to potential compatiblitiy
issues with setuptools on the target host (RedPitaya probably). See
also:

pypa/setuptools-scm#636
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

7 participants