From 3670699ea253962c3fdcbdba15ff898cb5f2d04b Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 17:31:48 +0100 Subject: [PATCH 1/9] Add trusted publishing for next release --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dcd969c9..71334eca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -437,6 +437,11 @@ jobs: deploy: needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check, pre-commit ] runs-on: ubuntu-22.04 + environment: + name: release + url: https://pypi.org/p/freqtrade + permissions: + id-token: write if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' @@ -462,16 +467,11 @@ jobs: uses: pypa/gh-action-pypi-publish@v1.8.11 if: (github.event_name == 'release') with: - user: __token__ - password: ${{ secrets.pypi_test_password }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@v1.8.11 if: (github.event_name == 'release') - with: - user: __token__ - password: ${{ secrets.pypi_password }} - name: Dockerhub login env: From d6b43c5eed01ce626f9e4268bdcc5eb0104b514c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 20:06:18 +0100 Subject: [PATCH 2/9] re-work deploy CI --- .github/workflows/ci.yml | 69 ++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71334eca2..4a6d6a86c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -434,15 +434,65 @@ jobs: details: Test Completed! webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - deploy: + build: needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check, pre-commit ] runs-on: ubuntu-22.04 + + if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Build distribution + run: | + pip install -U setuptools wheel + python setup.py sdist bdist_wheel + + - name: Upload artifacts 📦 + uses: actions/upload-artifact@v3 + with: + name: freqtrade-${{ github.ref }} + path: | + dist + retention-days: 10 + + deploy-pypi: + needs: [ build ] + runs-on: ubuntu-22.04 + if: (github.event_name == 'release') environment: name: release url: https://pypi.org/p/freqtrade permissions: id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Download artifact 📦 + uses: actions/download-artifact@v3 + with: + name: freqtrade-${{ github.ref }} + path: dist + + - name: Publish to PyPI (Test) + uses: pypa/gh-action-pypi-publish@v1.8.11 + with: + repository-url: https://test.pypi.org/legacy/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.11 + + + deploy-docker: + needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check, pre-commit ] + runs-on: ubuntu-22.04 + if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' steps: @@ -458,21 +508,6 @@ jobs: run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" id: extract_branch - - name: Build distribution - run: | - pip install -U setuptools wheel - python setup.py sdist bdist_wheel - - - name: Publish to PyPI (Test) - uses: pypa/gh-action-pypi-publish@v1.8.11 - if: (github.event_name == 'release') - with: - repository-url: https://test.pypi.org/legacy/ - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.11 - if: (github.event_name == 'release') - - name: Dockerhub login env: DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} @@ -507,7 +542,7 @@ jobs: deploy_arm: permissions: packages: write - needs: [ deploy ] + needs: [ deploy-docker ] # Only run on 64bit machines runs-on: [self-hosted, linux, ARM64] if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' From 1d701967b7377fb6f158ad53f1481eebd1b1edd5 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 20:27:47 +0100 Subject: [PATCH 3/9] exclude tests from build --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index a14965c09..0ed6da0ca 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,5 @@ recursive-include freqtrade/templates/ *.j2 *.ipynb include freqtrade/exchange/binance_leverage_tiers.json include freqtrade/rpc/api_server/ui/fallback_file.html include freqtrade/rpc/api_server/ui/favicon.ico + +prune tests From 6ee0f16e4f43e4feed673ac0ea80574d9119d410 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 20:32:37 +0100 Subject: [PATCH 4/9] Migrate flake8 config to pyproject.toml --- .pre-commit-config.yaml | 1 + pyproject.toml | 15 +++++++++++++++ setup.cfg | 14 -------------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c6575e1a..298b66956 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: rev: "6.0.0" hooks: - id: flake8 + additional_dependencies: [Flake8-pyproject] # stages: [push] - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/pyproject.toml b/pyproject.toml index bcfc1e551..44a6f9158 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,3 +93,18 @@ max-complexity = 12 [tool.ruff.per-file-ignores] "tests/*" = ["S"] + +[tool.flake8] +# Default from https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-ignore +# minus E226 +ignore = ["E121","E123","E126","E24","E704","W503","W504"] +max-line-length = 100 +max-complexity = 12 +exclude = [ + ".git", + "__pycache__", + ".eggs", + "user_data", + ".venv", + ".env", +] diff --git a/setup.cfg b/setup.cfg index d4d70bc34..4cf8fbc61 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,17 +37,3 @@ python_requires = >=3.9 [options.entry_points] console_scripts = freqtrade = freqtrade.main:main - -[flake8] -# Default from https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-ignore -# minus E226 -ignore = E121,E123,E126,E24,E704,W503,W504 -max-line-length = 100 -max-complexity = 12 -exclude = - .git, - __pycache__, - .eggs, - user_data, - .venv - .env From b178cc5f311d0f203a237698fc14dbc581c94dad Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 20:51:46 +0100 Subject: [PATCH 5/9] Migrate from setup.cfg to pyproject.toml --- pyproject.toml | 44 ++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 39 --------------------------------------- setup.py | 1 + 3 files changed, 45 insertions(+), 39 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 44a6f9158..148032c31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,50 @@ requires = ["setuptools >= 64.0.0", "wheel"] build-backend = "setuptools.build_meta" +[project] +name = "freqtrade" +dynamic = ["version", "dependencies", "optional-dependencies"] + +authors = [ + {name = "Freqtrade Team"}, + {name = "Freqtrade Team", email = "freqtrade@protonmail.com"}, +] + +description = "Freqtrade - Crypto Trading Bot" +readme = "README.md" +requires-python = ">=3.9" +license = {text = "GPLv3"} +# license = "GPLv3" +classifiers = [ + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: MacOS", + "Operating System :: Unix", + "Topic :: Office/Business :: Financial :: Investment", +] + + +[project.urls] +Homepage = "https://github.com/freqtrade/freqtrade" +Documentation = "https://freqtrade.io" +"Bug Tracker" = "https://github.com/freqtrade/freqtrade/issues" + + +[project.scripts] +freqtrade = "freqtrade.main:main" + +[tool.setuptools] +include-package-data = true +zip-safe = false +packages = ["freqtrade"] + +[tool.setuptools.dynamic] +version = {attr = "freqtrade.__version__"} + [tool.black] line-length = 100 exclude = ''' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4cf8fbc61..000000000 --- a/setup.cfg +++ /dev/null @@ -1,39 +0,0 @@ -[metadata] -name = freqtrade -version = attr: freqtrade.__version__ -author = Freqtrade Team -author_email = freqtrade@protonmail.com -description = Freqtrade - Crypto Trading Bot -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/freqtrade/freqtrade -project_urls = - Bug Tracker = https://github.com/freqtrade/freqtrade/issues -license = GPLv3 -classifiers = - Environment :: Console - Intended Audience :: Science/Research - License :: OSI Approved :: GNU General Public License v3 (GPLv3) - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Operating System :: MacOS - Operating System :: Unix - Topic :: Office/Business :: Financial :: Investment - - -[options] -zip_safe = False -include_package_data = True -tests_require = - pytest - pytest-asyncio - pytest-cov - pytest-mock - -packages = find: -python_requires = >=3.9 - -[options.entry_points] -console_scripts = - freqtrade = freqtrade.main:main diff --git a/setup.py b/setup.py index e8215a3e2..8100f21ae 100644 --- a/setup.py +++ b/setup.py @@ -122,4 +122,5 @@ setup( 'freqai_rl': freqai_rl, 'all': all_extra, }, + url="https://github.com/freqtrade/freqtrade", ) From 8d231dbf3195598257b5eb20d72146e6493202f0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 20:54:30 +0100 Subject: [PATCH 6/9] Update build-system to use "build" insead of "setup.py" --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a6d6a86c..3068cdbfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -450,8 +450,8 @@ jobs: - name: Build distribution run: | - pip install -U setuptools wheel - python setup.py sdist bdist_wheel + pip install -U build + python -m build --sdist --wheel - name: Upload artifacts 📦 uses: actions/upload-artifact@v3 From 93e9c4fa6587461ec01bf58462e17109a85d2342 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 21:14:06 +0100 Subject: [PATCH 7/9] Update job names in ci.yml --- .github/workflows/ci.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3068cdbfb..c09bc4e13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: details: Freqtrade CI failed on ${{ matrix.os }} webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - build_macos: + build-macos: runs-on: ${{ matrix.os }} strategy: matrix: @@ -229,7 +229,7 @@ jobs: details: Test Succeeded! webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - build_windows: + build-windows: runs-on: ${{ matrix.os }} strategy: @@ -299,7 +299,7 @@ jobs: details: Test Failed webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} - mypy_version_check: + mypy-version-check: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -324,7 +324,7 @@ jobs: python-version: "3.10" - uses: pre-commit/action@v3.0.0 - docs_check: + docs-check: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -404,10 +404,10 @@ jobs: notify-complete: needs: [ build_linux, - build_macos, - build_windows, - docs_check, - mypy_version_check, + build-macos, + build-windows, + docs-check, + mypy-version-check, pre-commit, build_linux_online ] @@ -435,11 +435,10 @@ jobs: webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} build: - needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check, pre-commit ] + name: "Build" + needs: [ build_linux, build-macos, build-windows, docs-check, mypy-version-check, pre-commit ] runs-on: ubuntu-22.04 - if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' - steps: - uses: actions/checkout@v4 @@ -462,6 +461,7 @@ jobs: retention-days: 10 deploy-pypi: + name: "Deploy to PyPI" needs: [ build ] runs-on: ubuntu-22.04 if: (github.event_name == 'release') @@ -490,7 +490,7 @@ jobs: deploy-docker: - needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check, pre-commit ] + needs: [ build_linux, build-macos, build-windows, docs-check, mypy-version-check, pre-commit ] runs-on: ubuntu-22.04 if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade' @@ -539,7 +539,8 @@ jobs: run: | build_helpers/publish_docker_multi.sh - deploy_arm: + deploy-arm: + name: "Deploy Docker" permissions: packages: write needs: [ deploy-docker ] From d2e328b8bd68df6d70fa2e85979f27c941f47d22 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Dec 2023 21:32:36 +0100 Subject: [PATCH 8/9] Update artifact name --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c09bc4e13..959579c2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -455,7 +455,7 @@ jobs: - name: Upload artifacts 📦 uses: actions/upload-artifact@v3 with: - name: freqtrade-${{ github.ref }} + name: freqtrade-build path: | dist retention-days: 10 @@ -477,7 +477,7 @@ jobs: - name: Download artifact 📦 uses: actions/download-artifact@v3 with: - name: freqtrade-${{ github.ref }} + name: freqtrade-build path: dist - name: Publish to PyPI (Test) From 58470ba9d06c1a92200b9b642d4299d6d59d9621 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 17 Dec 2023 08:31:17 +0100 Subject: [PATCH 9/9] Fix missing files in wheels --- pyproject.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 148032c31..c446419e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,12 @@ freqtrade = "freqtrade.main:main" [tool.setuptools] include-package-data = true zip-safe = false -packages = ["freqtrade"] + +[tool.setuptools.packages.find] +where = ["."] +include = ["freqtrade*"] +exclude = ["tests", "tests.*"] +namespaces = true [tool.setuptools.dynamic] version = {attr = "freqtrade.__version__"}