Skip to content

Commit e8e8942

Browse files
authored
Merge pull request #279 from mattip/pyproject.toml
move to pyproject.toml and meson, update to v0.5.0
2 parents ad07425 + 15b6185 commit e8e8942

9 files changed

Lines changed: 150 additions & 170 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
python-version: ${{ matrix.python }}
4040
- name: Install
4141
run: |
42-
python -m pip install --upgrade pip setuptools
43-
python -m pip install -e .
42+
python -m pip install --upgrade pip
43+
python -m pip install .
4444
python -m pip install -r test_requirements.txt
4545
- name: Display Python version
4646
run: python -c "import sys; print(sys.version)"

‎MANIFEST.in‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Setting up development can be done using the following commands:
2525

2626
$ virtualenv -p /usr/bin/python3 vmprof3
2727
$ source vmprof3/bin/activate
28-
$ python setup.py develop
28+
$ pip install meson-python meson ninja
29+
$ pip install --no-build-isolation --editable .
2930

3031
You need to install python development packages. In case of e.g. Debian or Ubuntu the package you need is `python3-dev` and `libunwind-dev`.
3132
Now it is time to write a test and implement your feature. If you want

‎docs/development.rst‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ An optional stage. It is only necessary if you want to co develop `vmprof-python
6565

6666
# install vmprof for development (only needed if you want to co develop vmprof-python)
6767
$ cd vmprof-python
68-
$ python setup.py develop
68+
$ pip install meson-python meson ninja
69+
$ pip install --no-build-isolation --editable .
6970

7071

7172
Now you are able to change both the python package and the server and see the results.

‎meson.build‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
project('vmprof', 'c',
2+
version: '0.5.0',
3+
license: 'MIT',
4+
meson_version: '>=1.1.0',
5+
)
6+
7+
py = import('python').find_installation(pure: false)
8+
py_dep = py.dependency()
9+
cc = meson.get_compiler('c')
10+
11+
# PyPy ships _vmprof as a built-in module, so the PyPy wheel is pure python.
12+
is_pypy = run_command(py, '-c',
13+
'import sys; print("__pypy__" in sys.builtin_module_names)',
14+
check: true,
15+
).stdout().strip() == 'True'
16+
17+
# The pure python packages. The test packages are not installed.
18+
python_dir = py.get_install_dir(pure: is_pypy)
19+
install_subdir('vmprof',
20+
install_dir: python_dir,
21+
exclude_directories: ['test', '__pycache__'],
22+
)
23+
install_subdir('jitlog',
24+
install_dir: python_dir,
25+
exclude_directories: ['test', '__pycache__'],
26+
)
27+
install_subdir('vmshare',
28+
install_dir: python_dir,
29+
exclude_directories: ['__pycache__'],
30+
)
31+
32+
if not is_pypy
33+
system = host_machine.system()
34+
35+
sources = files(
36+
'src/_vmprof.c',
37+
'src/machine.c',
38+
'src/compat.c',
39+
'src/vmp_stack.c',
40+
'src/vmprof_common.c',
41+
'src/vmprof_memory.c',
42+
)
43+
c_args = []
44+
deps = [py_dep]
45+
# libbacktrace ships a pre-generated config.h, so it is built as plain
46+
# sources without running its configure script.
47+
inc = include_directories('src', 'src/libbacktrace')
48+
49+
if system == 'windows'
50+
sources += files('src/vmprof_win.c')
51+
c_args += ['-DVMPROF_WINDOWS=1']
52+
elif system == 'darwin'
53+
sources += files(
54+
'src/symboltable.c',
55+
'src/vmprof_unix.c',
56+
'src/vmprof_mt.c',
57+
)
58+
c_args += ['-DVMPROF_APPLE=1', '-DVMPROF_UNIX=1']
59+
elif system == 'linux' or system == 'freebsd'
60+
sources += files(
61+
'src/symboltable.c',
62+
'src/vmprof_unix.c',
63+
'src/vmprof_mt.c',
64+
'src/libbacktrace/backtrace.c',
65+
'src/libbacktrace/state.c',
66+
'src/libbacktrace/elf.c',
67+
'src/libbacktrace/dwarf.c',
68+
'src/libbacktrace/fileline.c',
69+
'src/libbacktrace/mmap.c',
70+
'src/libbacktrace/mmapio.c',
71+
'src/libbacktrace/posix.c',
72+
'src/libbacktrace/sort.c',
73+
)
74+
c_args += ['-DVMPROF_UNIX=1']
75+
unwind_dep = dependency('libunwind', required: false)
76+
if not unwind_dep.found()
77+
unwind_dep = cc.find_library('unwind')
78+
endif
79+
deps += unwind_dep
80+
if system == 'linux'
81+
c_args += ['-DVMPROF_LINUX=1']
82+
deps += cc.find_library('dl', required: false)
83+
else
84+
c_args += ['-DVMPROF_BSD=1']
85+
inc = [inc, include_directories('/usr/local/include')]
86+
endif
87+
else
88+
error('platform "' + system + '" is not supported')
89+
endif
90+
91+
if system != 'windows'
92+
c_args += cc.get_supported_arguments('-Wno-unused')
93+
endif
94+
95+
if py.language_version().version_compare('>=3.11')
96+
sources += files('src/populate_frames.c')
97+
endif
98+
99+
py.extension_module('_vmprof',
100+
sources,
101+
c_args: c_args,
102+
include_directories: inc,
103+
dependencies: deps,
104+
install: true,
105+
)
106+
endif

‎pyproject.toml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
build-backend = "mesonpy"
3+
requires = ["meson-python>=0.17"]
4+
5+
[project]
6+
name = "vmprof"
7+
dynamic = ["version"]
8+
description = "Python's vmprof client"
9+
readme = "README.md"
10+
license = "MIT"
11+
license-files = ["LICENSE"]
12+
authors = [
13+
{name = "vmprof team", email = "fijal@baroquesoftware.com"},
14+
]
15+
requires-python = ">=3.9,<3.16"
16+
dependencies = [
17+
"requests",
18+
"six",
19+
"pytz",
20+
"colorama",
21+
]
22+
classifiers = [
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: Implementation :: CPython",
26+
"Programming Language :: Python :: Implementation :: PyPy",
27+
]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/vmprof/vmprof-python"
31+
Documentation = "https://vmprof.readthedocs.org/"
32+
33+
[project.scripts]
34+
vmprofshow = "vmprof.show:main"
35+
36+
[tool.meson-python.args]
37+
setup = ["--vsenv"]

‎setup.cfg‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎setup.py‎

Lines changed: 0 additions & 158 deletions
This file was deleted.

‎test_requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requests
33
urllib3==1.26.6 ; python_version < '3.9'
44
backports.shutil_which
55
cffi
6-
setuptools
6+
setuptools>=77
77
pytest
88
hypothesis
99
colorama

0 commit comments

Comments
 (0)