Skip to content

Commit

Permalink
Reduce binary sizes (#4862)
Browse files Browse the repository at this point in the history
* inspect assets sizes

* add -g0 to CFLAGS

* don't wait to build, add build to check
  • Loading branch information
samuelcolvin committed Dec 21, 2022
1 parent dc33b47 commit 4f13260
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -308,8 +308,6 @@ jobs:

build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
needs: [lint, test-linux-compiled, test-not-compiled, test-old-mypy, test-fastapi]
if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')"
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -379,6 +377,7 @@ jobs:
- test-not-compiled
- test-old-mypy
- test-fastapi
- build

runs-on: ubuntu-latest

Expand All @@ -388,6 +387,35 @@ jobs:
with:
jobs: ${{ toJSON(needs) }}

inspect-pypi-assets:
needs: [build]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist

- name: list dist files
run: |
ls -lh dist/
echo "`ls dist | wc -l` files"
- name: extract and list sdist file
run: |
mkdir sdist-files
tar -xvf dist/*.tar.gz -C sdist-files
tree -a sdist-files
- name: extract and list wheel file
run: |
ls dist/*cp310-manylinux*x86_64.whl | head -n 1
python -m zipfile --list `ls dist/*cp310-manylinux*x86_64.whl | head -n 1`
deploy:
name: Deploy
needs:
Expand Down
1 change: 1 addition & 0 deletions changes/2276-samuelcolvin.md
@@ -0,0 +1 @@
Reduce the size of binary wheels.
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -82,9 +82,9 @@ def extra(self):
compiler_directives = {}
if 'CYTHON_TRACE' in sys.argv:
compiler_directives['linetrace'] = True
# Set CFLAG to all optimizations (-O3)
# Set CFLAG to all optimizations (-O3), add `-g0` to reduce size of binaries, see #2276
# Any additional CFLAGS will be appended. Only the last optimization flag will have effect
os.environ['CFLAGS'] = '-O3 ' + os.environ.get('CFLAGS', '')
os.environ['CFLAGS'] = '-O3 -g0 ' + os.environ.get('CFLAGS', '')
ext_modules = cythonize(
'pydantic/*.py',
exclude=['pydantic/generics.py'],
Expand Down

0 comments on commit 4f13260

Please sign in to comment.