Skip to content

Commit a89c5e1

Browse files
authored
Python/Ruby ci (#31)
* wip: sdist job * wip: typo * wip: change sdist format * wip: linux build * wip: change file permissions * wip: change file permissions * wip: change directory * wip: add openssl-devel * wip: macos job * wip: add rtld flags * wip: typo fix * wip: test command * wip: test command * wip: test command * wip: test command * wip: revert cmd change * wip: change python version * wip: find_dylib function * wip: ruby rake tooling * wip(rbspy): rb-sys mkmf * wip: checkpoint * wip(rbspy): source build * wip(rbspy): fix binary paths * wip: checkpoint rbspy * wip: checkpoint * wip: ruby github action * wip: ruby github action * wip: Rakefile multi-platform * wip: linux build job * wip: fix paths * wip: change Rake spec order * wip: ruby macos job * wip: fix typo * wip: fix typo * wip: remove ext files * wip: bump version
1 parent c1e7cde commit a89c5e1

File tree

18 files changed

+750
-169
lines changed

18 files changed

+750
-169
lines changed

.github/workflows/python.yml

Lines changed: 79 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,94 @@ on:
1111
- '.github/workflows/python.yml'
1212

1313
jobs:
14-
build_wheels:
15-
name: Build wheels on ${{ matrix.os }}
16-
runs-on: ${{ matrix.os }}
14+
linux:
1715
strategy:
16+
fail-fast: false
1817
matrix:
19-
os: [ubuntu-latest, macos-latest]
20-
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin]
21-
exclude:
22-
- os: ubuntu-latest
23-
target: x86_64-apple-darwin
24-
- os: ubuntu-latest
25-
target: aarch64-apple-darwin
26-
- os: macos-latest
27-
target: x86_64-unknown-linux-gnu
28-
- os: macos-latest
29-
target: aarch64-unknown-linux-gnu
30-
31-
env:
32-
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && apt update && apt install -y libssl-dev libunwind8-dev"
33-
CIBW_BUILD_VERBOSITY: "1"
34-
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
35-
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux_2_24_x86_64:latest"
18+
build-arch:
19+
- manylinux2010_x86_64
20+
- manylinux2014_aarch64
21+
22+
name: Linux - ${{ matrix.build-arch }}
23+
runs-on: ubuntu-latest
3624

3725
steps:
3826
- uses: actions/checkout@v2
27+
with:
28+
submodules: recursive
3929

40-
- uses: actions/setup-python@v2
41-
42-
- name: Install cibuildwheel
43-
run: python -m pip install cibuildwheel==2.4.0
30+
- if: matrix.build-arch == 'manylinux2014_aarch64'
31+
uses: docker/setup-qemu-action@v1
32+
with:
33+
platforms: arm64
4434

45-
- name: Build wheels
46-
run: python pyroscope_ffi/python -m cibuildwheel --output-dir wheelhouse
35+
- name: Build in Docker
36+
run: pyroscope_ffi/python/scripts/docker.sh
37+
env:
38+
BUILD_ARCH: ${{ matrix.build-arch }}
4739

4840
- uses: actions/upload-artifact@v2
4941
with:
50-
path: ./wheelhouse/*.whl
42+
name: ${{ github.sha }}
43+
path: pyroscope_ffi/python/dist/*
44+
macos:
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
include:
49+
- macos-version: "10.15"
50+
target: x86_64-apple-darwin
51+
py-platform: macosx-10_15_x86_64
52+
- macos-version: "11.0"
53+
target: aarch64-apple-darwin
54+
py-platform: macosx-11_0_arm64
55+
56+
name: macOS - ${{ matrix.py-platform }}
57+
runs-on: macos-${{ matrix.macos-version }}
58+
59+
steps:
60+
- uses: actions/checkout@v2
61+
62+
- uses: actions-rs/toolchain@v1
63+
with:
64+
toolchain: stable
65+
target: ${{ matrix.target }}
66+
profile: minimal
67+
override: true
68+
69+
- uses: actions/setup-python@v2
70+
with:
71+
python-version: 3.9
5172

52-
- name: Display repo
53-
shell: bash
73+
- name: Build Wheel
5474
run: |
55-
cd wheelhouse
56-
ls -la
75+
pip install wheel
76+
python setup.py bdist_wheel -p ${{ matrix.py-platform }}
77+
working-directory: pyroscope_ffi/python
78+
env:
79+
CARGO_BUILD_TARGET: ${{ matrix.target }}
80+
81+
- uses: actions/upload-artifact@v2
82+
with:
83+
name: ${{ github.sha }}
84+
path: pyroscope_ffi/python/dist/*
85+
86+
sdist:
87+
name: sdist
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- uses: actions/checkout@v2
92+
93+
- uses: actions/setup-python@v2
94+
with:
95+
python-version: 3.7
96+
97+
- name: Build sdist
98+
run: python setup.py sdist
99+
working-directory: pyroscope_ffi/python
100+
101+
- uses: actions/upload-artifact@v2
102+
with:
103+
name: ${{ github.sha }}
104+
path: pyroscope_ffi/python/dist/*

.github/workflows/ruby.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Ruby Package
2+
3+
on:
4+
push:
5+
paths:
6+
- 'pyroscope_ffi/ruby/**'
7+
- '.github/workflows/ruby.yml'
8+
pull_request:
9+
paths:
10+
- 'pyroscope_ffi/ruby/**'
11+
- '.github/workflows/ruby.yml'
12+
13+
jobs:
14+
linux:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
build-arch:
19+
- x86_64
20+
- aarch64
21+
22+
name: Linux - ${{ matrix.build-arch }}
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- if: matrix.build-arch == 'aarch64'
29+
uses: docker/setup-qemu-action@v1
30+
with:
31+
platforms: arm64
32+
33+
- uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: '3.1'
36+
37+
- name: Install bundles
38+
run: bundle
39+
working-directory: pyroscope_ffi/ruby
40+
41+
- name: Build native extensions
42+
run: rake rbspy_install
43+
working-directory: pyroscope_ffi/ruby
44+
45+
- name: Build native extensions
46+
run: rake thread_id_install
47+
working-directory: pyroscope_ffi/ruby
48+
49+
- if: matrix.build-arch == 'x86_64'
50+
name: Build linux gem
51+
run: rake x86_64_linux:gem
52+
working-directory: pyroscope_ffi/ruby
53+
54+
- if: matrix.build-arch == 'aarch64'
55+
name: Build linux gem
56+
run: rake aarch64_linux:gem
57+
working-directory: pyroscope_ffi/ruby
58+
59+
- uses: actions/upload-artifact@v2
60+
with:
61+
name: ${{ github.sha }}
62+
path: pyroscope_ffi/ruby/pkg/*.gem
63+
64+
macos:
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
include:
69+
- macos-version: "10.15"
70+
target: x86_64-apple-darwin
71+
py-platform: macosx-10_15_x86_64
72+
- macos-version: "11.0"
73+
target: aarch64-apple-darwin
74+
py-platform: macosx-11_0_arm64
75+
76+
name: macOS - ${{ matrix.platform }}
77+
runs-on: macos-${{ matrix.macos-version }}
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
82+
- uses: actions-rs/toolchain@v1
83+
with:
84+
toolchain: stable
85+
target: ${{ matrix.target }}
86+
profile: minimal
87+
override: true
88+
89+
- uses: ruby/setup-ruby@v1
90+
with:
91+
ruby-version: '3.1'
92+
93+
- name: Install bundles
94+
run: bundle
95+
working-directory: pyroscope_ffi/ruby
96+
97+
- name: Build native extensions
98+
run: rake rbspy_install
99+
working-directory: pyroscope_ffi/ruby
100+
101+
- name: Build native extensions
102+
run: rake thread_id_install
103+
working-directory: pyroscope_ffi/ruby
104+
105+
- if: matrix.target == 'x86_64-apple-darwin'
106+
name: Build macos gem
107+
run: rake x86_64_darwin:gem
108+
working-directory: pyroscope_ffi/ruby
109+
110+
- if: matrix.target == 'aarch64-apple-darwin'
111+
name: Build macos gem
112+
run: rake arm64_darwin:gem
113+
working-directory: pyroscope_ffi/ruby
114+
115+
- uses: actions/upload-artifact@v2
116+
with:
117+
name: ${{ github.sha }}
118+
path: pyroscope_ffi/ruby/pkg/*.gem
119+
120+
source:
121+
name: source
122+
runs-on: ubuntu-latest
123+
124+
steps:
125+
- uses: actions/checkout@v2
126+
127+
- uses: ruby/setup-ruby@v1
128+
with:
129+
ruby-version: '3.1'
130+
131+
- name: Install bundles
132+
run: bundle
133+
working-directory: pyroscope_ffi/ruby
134+
135+
- name: Build source gem
136+
run: rake source:gem
137+
working-directory: pyroscope_ffi/ruby
138+
139+
- uses: actions/upload-artifact@v2
140+
with:
141+
name: ${{ github.sha }}
142+
path: pyroscope_ffi/ruby/pkg/*.gem

pyroscope_ffi/python/manylinux.sh

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Install tooling
5-
yum -y -q install wget gcc libffi-devel
5+
yum -y -q install wget gcc libffi-devel openssl-devel
66

77
# Install Rust
88
curl https://sh.rustup.rs -sSf | sh -s -- -y
@@ -15,6 +15,7 @@ cd libunwind-1.6.2
1515
./configure --disable-minidebuginfo --enable-ptrace --disable-tests --disable-documentation
1616
make
1717
make install
18+
cd ..
1819

1920
# Build wheels
2021
/opt/python/cp37-cp37m/bin/python setup.py bdist_wheel
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
BUILD_DIR="/work"
5+
6+
docker run \
7+
-w /work/pyroscope_ffi/python \
8+
-v `pwd`:/work \
9+
quay.io/pypa/${BUILD_ARCH} \
10+
sh manylinux.sh

pyroscope_ffi/python/setup.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
from setuptools import find_packages, setup
34
from pathlib import Path
45

@@ -13,13 +14,24 @@ def build_native(spec):
1314
path=LIB_DIR
1415
)
1516

17+
def find_dylib():
18+
cargo_target = os.environ.get('CARGO_BUILD_TARGET')
19+
if cargo_target:
20+
in_path = 'target/%s/release' % (cargo_target)
21+
else:
22+
in_path = 'target/release'
23+
return build.find_dylib('pyroscope_ffi', in_path=in_path)
24+
1625
# Step 2: package the compiled library
26+
rtld_flags = ["NOW"]
27+
if sys.platform == "darwin":
28+
rtld_flags.append("NODELETE")
29+
1730
spec.add_cffi_module(module_path='pyroscope_beta._native',
18-
dylib=lambda: build.find_dylib('pyroscope_ffi',
19-
in_path='target/release'),
31+
dylib=find_dylib,
2032
header_filename=lambda:
2133
build.find_header('pyroscope_ffi.h',in_path='include'),
22-
rtld_flags=['NOW']
34+
rtld_flags=rtld_flags,
2335
)
2436

2537
setup(

pyroscope_ffi/ruby/.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
.DS_Store
33
**/target
44
*.so
5-
tmp
5+
*.bundle
6+
Gemfile.lock
7+
/pkg
8+
/doc
9+
/coverage
10+
/tmp
11+
/vendor
12+
/.bundle

pyroscope_ffi/ruby/Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
source 'https://rubygems.org'
22

3-
gem 'ffi'
4-
gem 'fiddle'
3+
gemspec

0 commit comments

Comments
 (0)