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

Support pyproject.toml #834

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cjolowicz
Copy link
Contributor

@cjolowicz cjolowicz commented Aug 24, 2019

Support PEP 517 package builds using the pyproject.toml file. This adds support for build backends other than setuptools, such as poetry and flit. This PR is a follow-up to #833.

There is not much to do here, because pip 19 already implements PEP 517-based builds.

  • Detect Python projects having only pyproject.toml and no requirements.txt or Pipfile.
  • Avoid editable installs, which are not compatible with pyproject.toml-style projects.
  • Add test cases for pyproject.toml-style projects managed by setuptools, poetry, and flit.

Note that while this PR does allow deploying poetry-based projects to Heroku, it does not use the pinned requirements from the poetry.lock file. Implementing support for poetry.lock is build backend-specific, and therefore left to be addressed by a follow-up PR.

See #796

Follow-ups:


CI is broken for PRs from another repository, see this comment. Please check the corresponding PR in my fork to verify CI:

@cjolowicz cjolowicz requested a review from a team as a code owner August 24, 2019 12:03
@cjolowicz
Copy link
Contributor Author

cjolowicz commented Aug 25, 2019

It would be good to add a test case for a pyproject.toml using setuptools as the build backend end.

There could be a problem here because the buildpack uses a vendorized setuptools pinned at 39.0.1. On second thoughts, this should be fine because pip will use an isolated build using the setuptools version specified in the pyproject.toml.

Update: done (f845208)

@cjolowicz
Copy link
Contributor Author

cjolowicz commented Sep 25, 2019

Rebased onto master (v157).

  • Tests were moved from test/run to test/run-features

@cjolowicz cjolowicz mentioned this pull request Sep 26, 2019
@cjolowicz cjolowicz force-pushed the support-pyproject-toml branch from 524f2c7 to 84534a0 Compare October 3, 2019 15:17
@cjolowicz
Copy link
Contributor Author

Rebased onto master (af860be)

@cjolowicz cjolowicz force-pushed the support-pyproject-toml branch from 84534a0 to b8ed157 Compare November 24, 2019 14:46
@cjolowicz
Copy link
Contributor Author

Rebased onto master (93a620e)

Add two test cases for projects using poetry as the build backend:

- testPoetry: project without dependencies

- testPoetryLock: project with dependencies, using a poetry.lock file
Add two test cases for projects using flit as the build backend:

- testFlit: project without dependencies

- testFlitRequires: project with dependencies
@licht1stein
Copy link

Hi guys! Could you please add a comment on status of this and #796 Support for Poetry?

@edmorley edmorley changed the base branch from master to main August 3, 2020 13:29
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

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

Hi! Sorry for the delay in replying here. We're in the process of moving to Cloud Native Buildpacks, so all development effort is focused there at the moment, and eventually they will replace the current buildpacks. As such, we're only making minimal changes to the current buildpacks for now.

If you'd like to follow along with the development, our new CNB framework is here (which is now mostly complete):
https://github.com/heroku/libcnb.rs

And the Python CNB will (once it's beyond a local prototype), live here:
https://github.com/heroku/buildpacks-python
(My work in progress CNB has handling for pyproject.toml if it's any consolation!)

For more about CNBs, see:
https://buildpacks.io/

Copy link
Contributor

@codingjoe codingjoe left a comment

Choose a reason for hiding this comment

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

Hi @cjolowicz, thanks for the contribution. Let's try to push this over the finish line. I'd really love to use the modern project setup on Heroku.

The only thing needed to make this work, is the change in bin/detect.
Took make things easier for the maintainers, I'd suggest dropping all other changes.

I'd also recommend updating the README file. It should probably mention pyproject.toml support.

Comment on lines +272 to +278
if [ ! -f requirements.txt ] && [ ! -f Pipfile ] ; then
if [ -f pyproject.toml ] ; then
# Editable installs are not supported for pyproject.toml-style projects.
echo "." > requirements.txt
else
echo "-e ." > requirements.txt
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change is needed. Editable installations are supported.

@codingjoe
Copy link
Contributor

codingjoe commented Sep 9, 2022

For everyone who needs a quick fix:

You can either add an empty setup.py file to your project or a requirements.txt file with a dot (.) in it.

@dhdaines

This comment was marked as off-topic.

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

Successfully merging this pull request may close these issues.

6 participants