From 11e61dd6481582ab36519f1323f392cd2708a31c Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 6 Feb 2024 12:28:40 -0500 Subject: [PATCH] Build project with `build` & `pyproject.toml` --- .github/workflows/backend-production-deploy.yml | 6 ++++-- .github/workflows/backend-staging-deploy.yml | 6 ++++-- dev/django.Dockerfile | 3 ++- pyproject.toml | 4 ++++ setup.py | 1 - 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend-production-deploy.yml b/.github/workflows/backend-production-deploy.yml index e54d99fd4..510435085 100644 --- a/.github/workflows/backend-production-deploy.yml +++ b/.github/workflows/backend-production-deploy.yml @@ -44,10 +44,12 @@ jobs: run: heroku plugins:install heroku-builds - name: Build app into tarball - run: python setup.py sdist --formats=gztar + run: | + pip install build + python -m build --sdist - name: Create Heroku Build - run: heroku builds:create -a dandi-api --source-tar=dist/$(python setup.py --fullname).tar.gz + run: heroku builds:create -a dandi-api --source-tar dist/*.tar.gz env: HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} diff --git a/.github/workflows/backend-staging-deploy.yml b/.github/workflows/backend-staging-deploy.yml index aae8d7e01..4fe396f4d 100644 --- a/.github/workflows/backend-staging-deploy.yml +++ b/.github/workflows/backend-staging-deploy.yml @@ -31,10 +31,12 @@ jobs: run: heroku plugins:install heroku-builds - name: Build app into tarball - run: python setup.py sdist --formats=gztar + run: | + pip install build + python -m build --sdist - name: Create Heroku Build - run: heroku builds:create -a dandi-api-staging --source-tar=dist/$(python setup.py --fullname).tar.gz + run: heroku builds:create -a dandi-api-staging --source-tar dist/*.tar.gz env: HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }} diff --git a/dev/django.Dockerfile b/dev/django.Dockerfile index 947c05f46..9ac4d9ac2 100644 --- a/dev/django.Dockerfile +++ b/dev/django.Dockerfile @@ -9,10 +9,11 @@ RUN apt-get update && \ ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 -# Only copy the setup.py and setup.cfg, it will still force all install_requires to be installed, +# Only copy the pyproject.toml, setup.py, and setup.cfg. It will still force all install_requires to be installed, # but find_packages() will find nothing (which is fine). When Docker Compose mounts the real source # over top of this directory, the .egg-link in site-packages resolves to the mounted directory # and all package modules are importable. +COPY ./pyproject.toml /opt/django-project/pyproject.toml COPY ./setup.cfg /opt/django-project/setup.cfg COPY ./setup.py /opt/django-project/setup.py diff --git a/pyproject.toml b/pyproject.toml index b497b99d0..35b86c819 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + [tool.mypy] ignore_missing_imports = true show_error_codes = true diff --git a/setup.py b/setup.py index 1245f9ffc..71cb5b6ad 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ description='', # Determine version with scm use_scm_version={'version_scheme': 'post-release'}, - setup_requires=['setuptools_scm'], long_description=long_description, long_description_content_type='text/markdown', license='Apache 2.0',