pypa / setuptools_scm

the blessed package to manage your versions by scm tags

Home Page:https://setuptools-scm.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setuptools_scm seems to be used even though it's not mentioned in pyproject.toml nor installed

rvsasseen opened this issue · comments

I'm setting up a new project using pyproject.toml rather than setup.py/setup.cfg which is used for most projects at my company. I am finding that setuptools_scm seems to be used even though it's not mentioned in pyproject.toml nor installed. I say that because only files that are checked into git are getting put into the distribution. I don't understand why that is happening. I've seen your issues like #190 and #561, but those suggest that that would happen if setuptools_scm is installed in the python environment, but not if it's not.

The following output is from a newly created conda environment where I do "python -m build", with setuptools_scm not installed. I get the same behavior from "python -m build" locally on my Mac and on Linux in our GitLab CI server. (CI is run in a docker container, and does not involve a conda env.)

$ conda list
# packages in environment at /Users/sasseen/miniforge3/envs/tmp1:
#
# Name                    Version                   Build  Channel
build                     1.0.3                    pypi_0    pypi
bzip2                     1.0.8                h93a5062_5    conda-forge
ca-certificates           2023.7.22            hf0a4a13_0    conda-forge
libexpat                  2.5.0                hb7217d7_1    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libsqlite                 3.44.0               h091b4b1_0    conda-forge
libzlib                   1.2.13               h53f4e23_5    conda-forge
ncurses                   6.4                  h463b476_2    conda-forge
openssl                   3.1.4                h0d3ecfb_0    conda-forge
packaging                 23.2                     pypi_0    pypi
pip                       23.3.1             pyhd8ed1ab_0    conda-forge
pyproject-hooks           1.0.0                    pypi_0    pypi
python                    3.12.0          h47c9636_0_cpython    conda-forge
readline                  8.2                  h92ec313_1    conda-forge
setuptools                68.2.2             pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h5083fa2_1    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
wheel                     0.41.3             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge

$ pip list
Package         Version
--------------- -------
build           1.0.3
packaging       23.2
pip             23.3.1
pyproject_hooks 1.0.0
setuptools      68.2.2
wheel           0.41.3

I originally started out with setuptools_scm mentioned both in the requires and as a section in pyproject.toml, but have experimented with variations where I leave those out. (The original pyproject.toml I borrowed from another project had setuptools_scm listed in the requires, so I was exploring what that was about.) No matter what, only files checked into git get put into the sdist and wheel.

[build-system]
requires = [
    "setuptools",
#     "setuptools_scm",                                                         
]
build-backend = "setuptools.build_meta"

# [tool.setuptools_scm]                                                         
# nothing here anyway

A couple more things. First, with or without setuptools_scm being mentioned or installed, I get warnings like

warning: no previously-included files found matching '.gitlab-ci.yml'

for files listed as exclude in MANIFEST.in. I expect that's not really related to setuptools_scm, though.

Second, with it being mentioned and/or installed, I get "errors" like

ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any

(during building of the wheel) but they don't seem to cause any real problems.

Sorry, the above is not reported entirely accurately. I figured out most of what was going on.

The main thing was that in between my "python -m build" commands, while I was varying pyproject.toml to include or not include mention of setuptools_scm, I was not deleting the src/myrootpackage.egg-info directory. As a result, state was being carried over between build commands unexpectedly, affecting the contents of the built sdist and wheel.

Another thing that was a bit unexpected is that while use of setuptools_scm seems to include additional files from SCM in the build result, it does not prevent files that are NOT in SCM from being included in the build result if setuptools wants to put them in the build -- for example, non-checked-in python files sitting next to checked-in ones in the python source areas.