Skip to content

Commit b6c24ac

Browse files
committed
Multiple changes to try and address memory leaks
1 parent 3fbcef1 commit b6c24ac

34 files changed

+1491
-728
lines changed

.github/workflows/build_wheels.yml

Lines changed: 93 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,100 @@
11
name: Build
22

33
on:
4-
push:
5-
pull_request:
6-
release:
7-
types:
8-
- published
4+
push:
5+
pull_request:
6+
release:
7+
types:
8+
- published
99

1010
env:
11-
CIBW_ARCHS_MACOS: x86_64 arm64
12-
CIBW_BEFORE_BUILD_LINUX: "if command -v apk &> /dev/null; then apk add bsd-compat-headers; fi"
11+
CIBW_SKIP: cp36-* cp37-* cp38-* pp* *i686 *win32
12+
13+
# cibuildhweel macOS configuration
14+
CIBW_ARCHS_MACOS: native
15+
16+
# cibuildhweel linux configuration
17+
CIBW_ARCHS_LINUX: x86_64
18+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
19+
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
20+
# On Linux, wheels are built inside a container on the GitHub runner (unlike macOS and Windows which use the GitHub runner directly)
21+
# Any build dependencies must thus be installed on the container (using CIBW_BEFORE_ALL_LINUX), *not* on the runner with the regular workflow
22+
# This command must be compatible with manylinux_2_28 (AlmaLinux 8) and musllinux_1_2 (Alpine Linux 3.20)
23+
CIBW_BEFORE_ALL_LINUX: if command -v apk &> /dev/null; then apk add bsd-compat-headers; fi
24+
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH"'
1325

1426
jobs:
15-
build_wheels:
16-
name: Build wheels on ${{ matrix.os }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
matrix:
20-
os: [ubuntu-22.04, macos-12]
21-
steps:
22-
- uses: actions/checkout@v4
23-
with:
24-
submodules: true
25-
- name: Build wheels
26-
uses: pypa/[email protected]
27-
- uses: actions/upload-artifact@v3
28-
with:
29-
path: ./wheelhouse/*.whl
30-
build_sdist:
31-
name: Build source distribution
32-
runs-on: ubuntu-22.04
33-
steps:
34-
- uses: actions/checkout@v4
35-
with:
36-
submodules: true
37-
- name: Build sdist
38-
run: pipx run build --sdist
39-
- uses: actions/upload-artifact@v3
40-
with:
41-
path: dist/*.tar.gz
42-
upload_pypi:
43-
needs: [build_wheels, build_sdist]
44-
runs-on: ubuntu-22.04
45-
if: github.event_name == 'release' && github.event.action == 'published'
46-
steps:
47-
- uses: actions/download-artifact@v3
48-
with:
49-
name: artifact
50-
path: dist
51-
- uses: pypa/[email protected]
52-
with:
53-
password: ${{ secrets.PYPI_API_TOKEN }}
27+
build_wheels:
28+
name: Build wheels on ${{ matrix.os }}
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
# macos-13 is an Intel runner, macos-latest is an ARM runner
33+
os: [macos-13, macos-latest, ubuntu-latest]
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
submodules: true
38+
- run: cd astrometry.net && git apply ../astrometry.net.patch
39+
- run: python -m pip install cibuildwheel==2.21.3
40+
- run: python -m cibuildwheel
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: ${{ matrix.os }}
44+
path: wheelhouse
45+
test_library:
46+
name: Test library on ${{ matrix.os }} with Python ${{ matrix.python }}
47+
runs-on: ${{ matrix.os }}
48+
needs: [build_wheels]
49+
strategy:
50+
matrix:
51+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
52+
# macos-13 is an Intel runner, macos-latest is an ARM runner
53+
os: [macos-13, macos-latest, ubuntu-latest]
54+
steps:
55+
- uses: actions/setup-python@v5
56+
with:
57+
python-version: ${{ matrix.python }}
58+
- uses: actions/checkout@v4
59+
- uses: actions/download-artifact@v4
60+
with:
61+
name: ${{ matrix.os }}
62+
path: wheelhouse
63+
- run: python --version
64+
- run: python -m pip install toml
65+
- run: python .github/workflows/install_dependencies.py
66+
- run: ls wheelhouse
67+
- run: python -m pip install --no-index --find-links wheelhouse astrometry
68+
- run: python -c 'import astrometry'
69+
build_sdist:
70+
name: Build source distribution
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v4
74+
with:
75+
submodules: true
76+
- run: cd astrometry.net && git apply ../astrometry.net.patch
77+
- run: pipx run build --sdist
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: dist
81+
path: dist/*.tar.gz
82+
upload_pypi:
83+
name: Upload wheels and sidst to PyPI
84+
runs-on: ubuntu-latest
85+
needs: [build_wheels, test_library, build_sdist]
86+
if: github.event_name == 'release' && github.event.action == 'published'
87+
steps:
88+
- uses: actions/download-artifact@v4
89+
with:
90+
path: wheelhouse
91+
pattern: "*"
92+
merge-multiple: true
93+
- uses: actions/download-artifact@v4
94+
with:
95+
name: dist
96+
path: dist
97+
- run: mv wheelhouse/* dist/
98+
- uses: pypa/[email protected]
99+
with:
100+
password: ${{ secrets.PYPI_API_TOKEN }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pathlib
2+
import subprocess
3+
import sys
4+
5+
import toml
6+
7+
dirname = pathlib.Path(__file__).resolve().parent
8+
9+
print(f"load {dirname.parent.parent / 'pyproject.toml'}")
10+
with open(dirname.parent.parent / "pyproject.toml") as pyproject_file:
11+
pyproject = toml.load(pyproject_file)
12+
13+
dependencies = []
14+
if "project" in pyproject:
15+
project = pyproject["project"]
16+
if "dependencies" in project:
17+
dependencies += project["dependencies"]
18+
if "optional-dependencies" in project:
19+
optional_dependencies = project["optional-dependencies"]
20+
if "tests" in optional_dependencies:
21+
dependencies += optional_dependencies["tests"]
22+
23+
if len(dependencies) > 0:
24+
subprocess.run([sys.executable, "-m", "pip", "install"] + dependencies, check=True)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ build
55
wheelhouse
66
__pycache__
77
test/solution.json
8+
.venv

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include test.py
21
recursive-include astrometry.net/gsl-an *.h *.c
32
include astrometry.net/libkd/*.h
43
include astrometry.net/libkd/kdtree_internal.c

0 commit comments

Comments
 (0)