From 4678cef32ae7949c8a7a9652c5ab022859e4ed79 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sat, 13 May 2023 12:40:16 +0200 Subject: [PATCH] Fix pyproject.toml wheel build issues (#3313) --- .github/workflows/build.yml | 49 +++++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 2 +- MANIFEST.in | 19 +++++++------- _build/backend.py | 12 +++++++++ pyproject.toml | 30 +++-------------------- setup.py | 26 +++++++++++++++++++- 6 files changed, 101 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 _build/backend.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..8b8480fcb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,49 @@ +name: Build + +on: + push: + branches: [ master ] + paths-ignore: + - 'doc/**' + - 'src/pretix/locale/**' + pull_request: + branches: [ master ] + paths-ignore: + - 'doc/**' + - 'src/pretix/locale/**' + +permissions: + contents: read # to fetch code (actions/checkout) + +env: + FORCE_COLOR: 1 + +jobs: + test: + runs-on: ubuntu-22.04 + name: Packaging + strategy: + matrix: + python-version: ["3.11"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install system dependencies + run: sudo apt update && sudo apt install gettext unzip + - name: Install Python dependencies + run: pip3 install -U setuptools build pip check-manifest + - name: Run check-manifest + run: check-manifest + - name: Run build + run: python -m build + - name: Check files + run: unzip -l dist/pretix*whl | grep node_modules || exit 1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc2adefb8..288e20609 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ pypi: - make npminstall - cd .. - check-manifest - - python setup.py sdist bdist_wheel + - python -m build - twine check dist/* - twine upload dist/* tags: diff --git a/MANIFEST.in b/MANIFEST.in index 794d2d88d..331555b61 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include LICENSE include README.rst include src/Makefile +include _build/backend.py global-include *.proto recursive-include src/pretix/static * recursive-include src/pretix/static.dist * @@ -32,15 +33,15 @@ recursive-include src/pretix/plugins/returnurl/templates * recursive-include src/pretix/plugins/returnurl/static * recursive-include src/pretix/plugins/webcheckin/templates * recursive-include src/pretix/plugins/webcheckin/static * - recursive-include src *.cfg - recursive-include src *.csv - recursive-include src *.gitkeep - recursive-include src *.jpg - recursive-include src *.json - recursive-include src *.py - recursive-include src *.svg - recursive-include src *.txt - recursive-include src Makefile +recursive-include src *.cfg +recursive-include src *.csv +recursive-include src *.gitkeep +recursive-include src *.jpg +recursive-include src *.json +recursive-include src *.py +recursive-include src *.svg +recursive-include src *.txt +recursive-include src Makefile recursive-exclude doc * recursive-exclude deployment * diff --git a/_build/backend.py b/_build/backend.py new file mode 100644 index 000000000..d827280a2 --- /dev/null +++ b/_build/backend.py @@ -0,0 +1,12 @@ +import tomli +from setuptools import build_meta as _orig +from setuptools.build_meta import * + + +def get_requires_for_build_wheel(config_settings=None): + with open("pyproject.toml", "rb") as f: + p = tomli.load(f) + return [ + *_orig.get_requires_for_build_wheel(config_settings), + *p['project']['dependencies'] + ] diff --git a/pyproject.toml b/pyproject.toml index 5123e8cd0..c37b47453 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ classifiers = [ ] dependencies = [ - # Note that many of these are repeated as build-time dependencies down below -- change them too in case of updates! "arabic-reshaper==3.0.0", # Support for Arabic in reportlab "babel", "BeautifulSoup4==4.12.*", @@ -113,13 +112,9 @@ mysql = ["mysqlclient"] dev = [ "coverage", "coveralls", - "django-debug-toolbar==4.0.*", - "django-formset-js-improved==0.5.0.3", - "django-oauth-toolkit==2.2.*", "flake8==6.0.*", "freezegun", "isort==5.12.*", - "oauthlib==3.2.*", "pep8-naming==0.13.*", "potypo", "pycodestyle==2.10.*", @@ -140,31 +135,14 @@ build = "pretix._build:CustomBuild" build_ext = "pretix._build:CustomBuildExt" [build-system] +build-backend = "backend" +backend-path = ["_build"] requires = [ "setuptools", "setuptools-rust", "wheel", "importlib_metadata", - - # These are runtime dependencies that we unfortunately need to be import in the step that generates - # all CSS and JS asset files. We should keep their versions in sync with the definition above. - "babel", - "Django==3.2.*,>=3.2.18", - "django-bootstrap3==23.1.*", - "django-compressor==4.3.*", - "django-countries==7.5.*", - "django-formtools==2.4", - "django-hierarkey==1.1.*", - "django-i18nfield==1.9.*,>=1.9.4", - "django-libsass==0.9", - "django-phonenumber-field==7.1.*", - "django-statici18n==2.3.*", - "djangorestframework==3.14.*", - "libsass==0.22.*", - "phonenumberslite==8.13.*", - "pycountry", - "pyuca", - "slimit", + "tomli", ] [project.urls] @@ -182,4 +160,4 @@ version = {attr = "pretix.__version__"} [tool.setuptools.packages.find] where = ["src"] include = ["pretix*"] -namespaces = false \ No newline at end of file +namespaces = false diff --git a/setup.py b/setup.py index a03f67665..d8998b695 100644 --- a/setup.py +++ b/setup.py @@ -19,8 +19,32 @@ # You should have received a copy of the GNU Affero General Public License along with this program. If not, see # . # +import sys +from pathlib import Path import setuptools + +sys.path.append(str(Path.cwd() / 'src')) + + +def _CustomBuild(*args, **kwargs): + print(sys.path) + from pretix._build import CustomBuild + return CustomBuild(*args, **kwargs) + + +def _CustomBuildExt(*args, **kwargs): + from pretix._build import CustomBuildExt + return CustomBuildExt(*args, **kwargs) + + +cmdclass = { + 'build': _CustomBuild, + 'build_ext': _CustomBuildExt, +} + if __name__ == "__main__": - setuptools.setup() + setuptools.setup( + cmdclass=cmdclass, + )