Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce binary sizes #4862

Merged
merged 3 commits into from Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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