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

python setup.py sdist only works with pyproject.toml when package is pre-installed in venv #487

Closed
jamesbraza opened this issue Oct 30, 2020 · 3 comments

Comments

@jamesbraza
Copy link
Contributor

jamesbraza commented Oct 30, 2020

I am hitting what seems to be an edge when combining python setup.py sdist, setup.py, and pyproject.toml.

Here is my pyproject.toml:

[build-system]

requires = ["setuptools", "wheel", "setuptools_scm[toml]"]


[tool.setuptools_scm]

write_to = "desired/path/to/__version__.py"
root = ".."
relative_to = '__file__'

And my venv at the beginning:

Python==3.7.9
pip==20.2.4
setuptools==47.1.0
setuptools-scm==4.1.2

Case 1: didn't pre-install package

python setup.py sdist

Result: version of 0.0.0 (didn't work)

#386 seems related.

Case 2: pre-installed package

pip install -e .
python setup.py sdist

Result: version of pkg-name-0.1.1.dev10+g28f91ce (works)

Case 3: didn't install package + added config directly to setup.py

I add the pyproject.toml config section to setup.py's setup function:

setup(
    use_scm_version={
        "write_to": "desired/path/to/__version__.py",
        "root": "..",
        "relative_to": __file__,
    },
)

And do not have to pre-install the package:

python setup.py sdist

Result: version of pkg-name-0.1.1.dev10+g28f91ce.d20201030 (works)

Note: this version has the date appended for some reason


The Issue

I would like to be able to use Case 1 above. Unfortunately, it doesn't seem to work. What might be the problem? I have tried combing through the docs several times over, and haven't found any solutions.

In the meantime, I will be going with Case 2.

@RonnyPfannschmidt
Copy link
Contributor

The sdist command of setuptools is unaware of pep 517/8,so preinstall is a required step

@jamesbraza
Copy link
Contributor Author

Well, that makes sense! Thank you @RonnyPfannschmidt !

@RonnyPfannschmidt
Copy link
Contributor

As extra tool add imports to setup.py

That way people cannot run it without installing setuptools_scm and toml

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

2 participants