From d187a497f9a9a8d8374997f8e4ff1be629fb3fd1 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 11 Jun 2021 12:51:20 +0200 Subject: [PATCH] Restructure dependencies (#2121) --- .github/workflows/docs.yml | 3 +- .github/workflows/strings.yml | 6 +- .github/workflows/style.yml | 6 +- .github/workflows/tests.yml | 3 +- Dockerfile | 9 +- doc/development/setup.rst | 2 +- doc/requirements.txt | 2 +- src/requirements.txt | 1 - src/requirements/dev.txt | 22 ----- src/requirements/memcached.txt | 1 - src/requirements/mysql.txt | 2 - src/requirements/production.txt | 73 -------------- src/requirements/redis.txt | 1 - src/setup.py | 169 +++++++++++++++++--------------- 14 files changed, 108 insertions(+), 192 deletions(-) delete mode 100644 src/requirements.txt delete mode 100644 src/requirements/dev.txt delete mode 100644 src/requirements/memcached.txt delete mode 100644 src/requirements/mysql.txt delete mode 100644 src/requirements/production.txt delete mode 100644 src/requirements/redis.txt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 93304f5938..51bbe67003 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -33,7 +33,8 @@ jobs: - name: Install system packages run: sudo apt update && sudo apt install enchant hunspell aspell-en - name: Install Dependencies - run: pip3 install -Ur doc/requirements.txt + run: pip3 install -Ur requirements.txt + working-directory: ./doc - name: Spellcheck docs run: make spelling working-directory: ./doc diff --git a/.github/workflows/strings.yml b/.github/workflows/strings.yml index dcb7cd06cb..3121a40ca1 100644 --- a/.github/workflows/strings.yml +++ b/.github/workflows/strings.yml @@ -31,7 +31,8 @@ jobs: - name: Install system packages run: sudo apt update && sudo apt install gettext - name: Install Dependencies - run: pip3 install -Ur src/requirements.txt + run: pip3 install -e ".[dev]" + working-directory: ./src - name: Compile messages run: python manage.py compilemessages working-directory: ./src @@ -56,7 +57,8 @@ jobs: - name: Install system packages run: sudo apt update && sudo apt install enchant hunspell hunspell-de-de aspell-en aspell-de - name: Install Dependencies - run: pip3 install -Ur src/requirements/dev.txt + run: pip3 install -e ".[dev]" + working-directory: ./src - name: Spellcheck translations run: potypo working-directory: ./src diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 7cf0825c3d..daa19051f0 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -29,7 +29,8 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - name: Install Dependencies - run: pip3 install -Ur src/requirements/dev.txt + run: pip3 install -e ".[dev]" mysqlclient psycopg2-binary + working-directory: ./src - name: Run isort run: isort -c . working-directory: ./src @@ -49,7 +50,8 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - name: Install Dependencies - run: pip3 install -r src/requirements.txt -Ur src/requirements/dev.txt + run: pip3 install -e ".[dev]" mysqlclient psycopg2-binary + working-directory: ./src - name: Run flake8 run: flake8 . working-directory: ./src diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a99ff2d0a0..dcfe48254c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,7 +57,8 @@ jobs: - name: Install system dependencies run: sudo apt update && sudo apt install gettext mysql-client - name: Install Python dependencies - run: pip3 install -r src/requirements.txt -Ur src/requirements/dev.txt mysqlclient psycopg2-binary + run: pip3 install -e ".[dev]" mysqlclient psycopg2-binary + working-directory: ./src - name: Run checks run: python manage.py check working-directory: ./src diff --git a/Dockerfile b/Dockerfile index 15f7ef07f8..7ac3ccc285 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,17 +41,14 @@ ENV LC_ALL=C.UTF-8 \ DJANGO_SETTINGS_MODULE=production_settings # To copy only the requirements files needed to install from PIP -COPY src/requirements /pretix/src/requirements -COPY src/requirements.txt /pretix/src +COPY src/setup.py /pretix/src/setup.py RUN pip3 install -U \ pip \ setuptools \ wheel && \ cd /pretix/src && \ - pip3 install \ - -r requirements.txt \ - -r requirements/memcached.txt \ - -r requirements/mysql.txt \ + PRETIX_DOCKER_BUILD=TRUE pip3 install \ + -e ".[memcached,mysql]" \ gunicorn django-extensions ipython && \ rm -rf ~/.cache/pip diff --git a/doc/development/setup.rst b/doc/development/setup.rst index d019846ff7..bef894aac6 100644 --- a/doc/development/setup.rst +++ b/doc/development/setup.rst @@ -54,7 +54,7 @@ Working with the code The first thing you need are all the main application's dependencies:: cd src/ - pip3 install -r requirements.txt -r requirements/dev.txt + pip3 install -e ".[dev]" Next, you need to copy the SCSS files from the source folder to the STATIC_ROOT directory:: diff --git a/doc/requirements.txt b/doc/requirements.txt index fc47fa5a81..60fc06b32c 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,4 @@ --r ../src/requirements.txt +-e ../src/ sphinx==2.3.* sphinx-rtd-theme sphinxcontrib-httpdomain diff --git a/src/requirements.txt b/src/requirements.txt deleted file mode 100644 index ea77c2d839..0000000000 --- a/src/requirements.txt +++ /dev/null @@ -1 +0,0 @@ --r requirements/production.txt diff --git a/src/requirements/dev.txt b/src/requirements/dev.txt deleted file mode 100644 index 8b25c3123b..0000000000 --- a/src/requirements/dev.txt +++ /dev/null @@ -1,22 +0,0 @@ -django-debug-toolbar==3.2.* -# Testing requirements -pycodestyle==2.5.* -pyflakes==2.1.* -pep8-naming -flake8==3.7.* -codecov -coverage -pytest-cov -pytest==6.* -pytest-django==4.* -isort -pytest-rerunfailures==9.* -pytest-mock==2.0.* -responses -potypo -freezegun - -# Not really required, just nice to have -pytest-xdist==1.31.* -pytest-cache -pytest-sugar diff --git a/src/requirements/memcached.txt b/src/requirements/memcached.txt deleted file mode 100644 index a19a29cf28..0000000000 --- a/src/requirements/memcached.txt +++ /dev/null @@ -1 +0,0 @@ -pylibmc diff --git a/src/requirements/mysql.txt b/src/requirements/mysql.txt deleted file mode 100644 index 93c8d852b9..0000000000 --- a/src/requirements/mysql.txt +++ /dev/null @@ -1,2 +0,0 @@ -mysqlclient - diff --git a/src/requirements/production.txt b/src/requirements/production.txt deleted file mode 100644 index cd0559267d..0000000000 --- a/src/requirements/production.txt +++ /dev/null @@ -1,73 +0,0 @@ -# Functional requirements -Django==3.2.* -djangorestframework==3.12.* -python-dateutil==2.8.* -isoweek -requests==2.25.0 -pytz -django-bootstrap3==15.0.* -django-formset-js-improved==0.5.0.2 -django-compressor==2.4.* -django-hierarkey==1.0.*,>=1.0.4 -django-filter==2.4.* -django-scopes==1.2.* -reportlab>=3.5.65 -PyPDF2==1.26.* -Pillow==8.* -django-libsass==0.8 -libsass==0.20.* -django-otp==0.7.*,>=0.7.5 -python-u2flib-server==4.* -webauthn==0.4.* -django-formtools==2.3 -celery==4.4.* -kombu==4.6.* -django-statici18n==1.9.* -inlinestyler==0.2.* -BeautifulSoup4==4.8.* -slimit -lxml -static3==0.7.* -dj-static -csscompressor -django-markup -markdown==3.3.* -bleach==3.3.* -sentry-sdk==1.1.* -babel -django-i18nfield==1.9.*,>=1.9.1 -django-hijack>=2.1.10,<2.2.0 -jsonschema -openpyxl==3.0.* -django-oauth-toolkit==1.2.* -oauthlib==3.1.* -psycopg2-binary -django-mysql -tqdm==4.* -# Stripe -stripe==2.42.* -# PayPal -paypalrestsdk==1.13.* -pycparser==2.13 # https://github.com/eliben/pycparser/issues/147 -# Banktransfer -chardet<3.1.0,>=3.0.2 -mt-940==3.2 -vobject==0.9.* -pycountry -django-countries>=7.2 -pyuca # for better sorting of country names in django-countries -defusedcsv>=1.1.0 -vat_moss_forked==2020.3.20.0.11.0 -django-localflavor==3.0.* -django-redis==4.11.* -redis==3.4.* -django-phonenumber-field==4.0.* -phonenumberslite==8.11.* -python-bidi==0.4.* # Support for arabic in reportlab -arabic-reshaper==2.0.15 # Support for Aabic in reportlab -packaging -tlds>=2020041600 -text-unidecode==1.* -protobuf==3.15.* -cryptography>=3.4.2 -sepaxml==2.4.*,>=2.4.1 diff --git a/src/requirements/redis.txt b/src/requirements/redis.txt deleted file mode 100644 index f343f828a5..0000000000 --- a/src/requirements/redis.txt +++ /dev/null @@ -1 +0,0 @@ -# Kept for compatibility diff --git a/src/setup.py b/src/setup.py index f46054b24d..10391a2ec8 100644 --- a/src/setup.py +++ b/src/setup.py @@ -44,7 +44,13 @@ from os import path from setuptools import find_packages, setup -from pretix import __version__ +try: + from pretix import __version__ +except: + if "PRETIX_DOCKER_BUILD" in os.environ: + __version__ = "0.0.0" # this is a hack to allow calling this file early in our docker build to make use of caching + else: + raise CURRENT_PYTHON = sys.version_info[:2] REQUIRED_PYTHON = (3, 6) @@ -92,6 +98,8 @@ def npm_install(): class CustomBuild(build): def run(self): + if "PRETIX_DOCKER_BUILD" in os.environ: + return # this is a hack to allow calling this file early in our docker build to make use of caching os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pretix.settings") os.environ.setdefault("PRETIX_IGNORE_CONFLICTS", "True") import django @@ -113,6 +121,8 @@ class CustomBuild(build): class CustomBuildExt(build_ext): def run(self): + if "PRETIX_DOCKER_BUILD" in os.environ: + return # this is a hack to allow calling this file early in our docker build to make use of caching npm_install() build_ext.run(self) @@ -131,7 +141,7 @@ setup( long_description=long_description, url='https://pretix.eu', author='Raphael Michel', - author_email='mail@raphaelmichel.de', + author_email='support@pretix.eu', license='GNU Affero General Public License v3 with Additional Terms', classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -143,99 +153,102 @@ setup( 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', - 'Framework :: Django :: 3.0' + 'Framework :: Django :: 3.2' ], keywords='tickets web shop ecommerce', install_requires=[ - 'Django==3.2.*', - 'djangorestframework==3.12.*', - 'python-dateutil==2.8.*', - 'isoweek', - 'requests==2.25.*', - 'pytz', - 'django-bootstrap3==15.0.*', - 'django-formset-js-improved==0.5.0.2', - 'django-compressor==2.4.*', - 'django-hierarkey==1.0.*,>=1.0.4', - 'django-filter==2.4.*', - 'django-scopes==1.2.*', - 'reportlab>=3.5.65', - 'Pillow==8.*', - 'PyPDF2==1.26.*', - 'django-libsass==0.8', - 'libsass==0.20.*', - 'django-otp==0.7.*,>=0.7.5', - 'webauthn==0.4.*', - 'python-u2flib-server==4.*', - 'django-formtools==2.3', - 'celery==4.4.*', - 'kombu==4.6.*', - 'django-statici18n==1.9.*', - 'inlinestyler==0.2.*', - 'BeautifulSoup4==4.8.*', - 'slimit', - 'lxml', - 'static3==0.7.*', - 'dj-static', - 'csscompressor', - 'django-markup', - 'markdown==3.3.*', - 'bleach==3.3.*', - 'sentry-sdk==1.1.*', - 'babel', - 'paypalrestsdk==1.13.*', - 'pycparser==2.13', - 'django-redis==4.11.*', - 'redis==3.4.*', - 'stripe==2.42.*', - 'chardet<3.1.0,>=3.0.2', - 'mt-940==3.2', - 'django-i18nfield==1.9.*,>=1.9.1', - 'psycopg2-binary', - 'django-mysql', - 'tqdm==4.*', - 'vobject==0.9.*', - 'pycountry', - 'django-countries>=7.2', - 'pyuca', - 'defusedcsv>=1.1.0', - 'vat_moss_forked==2020.3.20.0.11.0', - 'django-localflavor==3.0.*', - 'jsonschema', - 'django-hijack>=2.1.10,<2.2.0', - 'openpyxl==3.0.*', - 'django-oauth-toolkit==1.2.*', - 'oauthlib==3.1.*', - 'django-phonenumber-field==4.0.*', - 'phonenumberslite==8.11.*', - 'python-bidi==0.4.*', # Support for Arabic in reportlab 'arabic-reshaper==2.0.15', # Support for Arabic in reportlab - 'packaging', - 'tlds>=2020041600', - 'text-unidecode==1.*', - 'protobuf==3.15.*', + 'babel', + 'BeautifulSoup4==4.8.*', + 'bleach==3.3.*', + 'celery==4.4.*', + 'chardet<3.1.0,>=3.0.2', 'cryptography>=3.4.2', + 'csscompressor', + 'defusedcsv>=1.1.0', + 'dj-static', + 'Django==3.2.*', + 'django-bootstrap3==15.0.*', + 'django-compressor==2.4.*', + 'django-countries>=7.2', + 'django-filter==2.4.*', + 'django-formset-js-improved==0.5.0.2', + 'django-formtools==2.3', + 'django-hierarkey==1.0.*,>=1.0.4', + 'django-hijack>=2.1.10,<2.2.0', + 'django-i18nfield==1.9.*,>=1.9.1', + 'django-libsass==0.8', + 'django-localflavor==3.0.*', + 'django-markup', + 'django-mysql', + 'django-oauth-toolkit==1.2.*', + 'django-otp==0.7.*,>=0.7.5', + 'django-phonenumber-field==4.0.*', + 'django-redis==4.11.*', + 'django-scopes==1.2.*', + 'django-statici18n==1.9.*', + 'djangorestframework==3.12.*', + 'inlinestyler==0.2.*', + 'isoweek', + 'jsonschema', + 'kombu==4.6.*', + 'libsass==0.20.*', + 'lxml', + 'markdown==3.3.*', + 'mt-940==3.2', + 'oauthlib==3.1.*', + 'openpyxl==3.0.*', + 'packaging', + 'paypalrestsdk==1.13.*', + 'phonenumberslite==8.11.*', + 'Pillow==8.*', + 'protobuf==3.15.*', + 'psycopg2-binary', + 'pycountry', + 'pycparser==2.13', + 'PyPDF2==1.26.*', + 'python-bidi==0.4.*', # Support for Arabic in reportlab + 'python-dateutil==2.8.*', + 'python-u2flib-server==4.*', + 'pytz', + 'pyuca', + 'redis==3.4.*', + 'reportlab>=3.5.65', + 'requests==2.25.*', + 'sentry-sdk==1.1.*', 'sepaxml==2.4.*,>=2.4.1', + 'slimit', + 'static3==0.7.*', + 'stripe==2.42.*', + 'text-unidecode==1.*', + 'tlds>=2020041600', + 'tqdm==4.*', + 'vat_moss_forked==2020.3.20.0.11.0', + 'vobject==0.9.*', + 'webauthn==0.4.*', ], extras_require={ 'dev': [ + 'coverage', + 'coveralls', 'django-debug-toolbar==3.2.*', + 'flake8==3.7.*', + 'freezegun', + 'isort', + 'pep8-naming', + 'potypo', 'pycodestyle==2.5.*', 'pyflakes==2.1.*', - 'flake8==3.7.*', - 'pep8-naming', - 'coveralls', - 'coverage', - 'pytest==6.*', + 'pytest-cache', + 'pytest-cov', 'pytest-django==4.*', - 'pytest-xdist==1.31.*', - 'isort', 'pytest-mock==2.0.*', 'pytest-rerunfailures==9.*', + 'pytest-sugar', + 'pytest-xdist==1.31.*', + 'pytest==6.*', 'responses', - 'potypo', - 'freezegun', ], 'memcached': ['pylibmc'], 'mysql': ['mysqlclient'],