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

Remove setup.py #458

Merged
merged 4 commits into from
Jul 4, 2021
Merged

Remove setup.py #458

merged 4 commits into from
Jul 4, 2021

Conversation

cjolowicz
Copy link
Collaborator

@cjolowicz cjolowicz commented Jun 20, 2021

This PR removes the setup.py shim left after migrating to setup.cfg. It also updates the deploy job in CI to use python -m build to build the sdist and wheel for PyPI.

Note that with pip >= 21.1 (2021-04-24), editable installs for projects with a setup.cfg no longer require a setup.py shim.

Follow-up to #457

Editable installs for projects with a setup.cfg no longer require a setup.py
shim. This requires pip >= 21.1 (2021-04-24).
@cjolowicz cjolowicz requested a review from theacodes June 20, 2021 19:44
Comment on lines 59 to +65
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install setuptools and wheel
run: python -m pip install --upgrade --user setuptools wheel
- name: Install build
run: python -m pip install --user build
- name: Build sdist and wheel
run: python setup.py sdist bdist_wheel
run: python -m build
Copy link
Collaborator

@henryiii henryiii Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these lines can be replaced with:

- name: Build sdist and wheel
  run: pipx run build

GHA supports pipx without setup-python, and build supports pipx too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks! I'd like to keep the scope of this PR restricted to removing setup.py, but feel free to open an issue.

- name: Build sdist and wheel
run: python setup.py sdist bdist_wheel
run: python -m build
- name: Publish distribution PyPI
uses: pypa/gh-action-pypi-publish@master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend pinning this and then using dependabot to update it every so often (it doesn't change that often).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Dependabot is a great idea, I think there are more places where we could benefit from it. As with your other suggestion, I'd prefer to handle this in a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make those in a followup if (since) you like the ideas.

@DiddiLeija
Copy link
Collaborator

Hello @cjolowicz! Seems like you are trying to remove the setup.py in favor of setup.cfg. Just remember that pip will not longer support setup.cfg-only projects, see pypa/pip#9945 for the related discussion.

If you are going to remove setup.py, just keep the pyproject.toml.

@henryiii
Copy link
Collaborator

henryiii commented Jun 28, 2021

This is already a pyproject.toml based build, so it's safe to remove the setup.py - Pip is not "removing" support for anything except for a mistake that was introduced in a patch release of 21.1. That discussion was that only setup.cfg, with no pyproject.toml, should not be supported, because that's not technically valid for all valid PEP 517 backends, as a valid backend could call setup.py if pyproject.toml is missing (though most do not, most use the valid alternate method, which is directly calling a setuptools hook). This was not supported before the mistake in a patch release.

The downsides to removing setup.py is that older versions of pip (<21.1 IIRC) can't do an editable mode install, and you need a version of pip, 10+ or so, to install from SDist. Wheels are unaffected, so for a pure Python project, most users will not be affected at all. I do expect you will get questions or complaints from package managers who have workflows that call setup.py commands. But really, if they want to keep doing things the same (poor) way, they can just echo "import setuptools; setuptools.setup()" > setup.py to "fix" it. And it's better not to depend on setup.py.

@DiddiLeija
Copy link
Collaborator

Of course. I just wanted to say that you must not remove pyproject.toml since you delete setup.py.

@DiddiLeija
Copy link
Collaborator

But really, if they want to keep doing things the same (poor) way, they can just echo "import setuptools; setuptools.setup()" > setup.py to "fix" it.

Oh, thanks. I also wanted to ask that.

@cjolowicz
Copy link
Collaborator Author

@henryiii @DiddiLeija Thanks for your input!

@theacodes I'll merge this on the weekend if you don't shout "stop" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants