Skip to content

Commit 7c8e984

Browse files
committed
Improve README and reduce the pypatch required
1 parent e0d14f5 commit 7c8e984

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
Starting from fresh Raspberry Pi OS 32bit
1+
# Pylibcamera
2+
This package is for the libcamera python bindings only. It requires you to already have installed a version of libcamera onto your system.
23

3-
Required apt packages for pylibcamera build:
4-
- libcamera-dev
4+
## Installation Instructions
5+
These instructions are designed for use in a python virtual environment. If you are using the system python then it is much simpler to install the system apt package for the libcamera python bindings (eg `sudo apt install python3-libcamera`), as these will match the version of libcamera correctly.
6+
7+
The default installation instructions (which work on Raspberry Pi OS) are:
8+
```
9+
sudo apt install -y libcamera-dev
10+
pip install libcamera
11+
```
12+
If you have an older release of libcamera on your system then you may need to use `libcamera==version` to install the correct release.
13+
14+
### If that doesn't work...
15+
16+
If you have built your own version of libcamera, or your system has a version which is not compatible with a release version, then you may need to pass the repository and revision to meson. The arguments to do this are `-C setup-args="-Drepository=https://my.repository.git"` for the repository and `-C setup-args="-Drevision=branch"` for the revision. These are passed directly into `git clone` and `git checkout` respectively, so and strings that work with those will work here. The `-C, --config-settings` argument require an up to date version of `pip>=23.1` so you may first need to run `pip install --upgrade pip`
17+
18+
For example, the if you have built the master version of libcamera on your system, then you would run:
19+
```
20+
pip install libcamera -C setup-args="-Drevision=master"
21+
```
22+
23+
If you have built the main version from the Raspberry Pi repository then you would use:
24+
```
25+
pip install libcamera -C setup-args="-Drepository=https://github.com/raspberrypi/libcamera.git" -C setup-args="-Drevision=main"
26+
```
27+
28+
## How it works
29+
This package works by building just the libcamera python bindings against your existing version of libcamera. It does this by cloning the libcamera repository and checking out the specified revision. A patch (pypatch.patch) is then applied to modify the src/py/libcamera/meson.build file to prevent building of the existing python bindings and allow for the building of custom ones using the meson-python build system. Finally, the build includes the subdirectory libcamera/src/py to only include the files required for the python bindings, rather than building the whole of libcamera.

meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ message('Cloning from: @0@, revision @1@'.format(get_option('repository'), get_o
1515
r = run_command('clone-libcamera.sh', get_option('repository'), get_option('revision'), get_option('patch'), check : true)
1616

1717
libcamera_includes = include_directories('libcamera/include')
18-
libcamera_private = dependency('libcamera', required : true)
18+
libcamera_private = dependency(
19+
'libcamera', required : true,
20+
not_found_message : 'Requires libcamera-dev package to be installed - apt install libcamera-dev'
21+
)
1922

2023
py = import('python').find_installation()
2124

2225
subdir('libcamera/src/py')
2326

27+
pycamera_args += '-DLIBCAMERA_BASE_PRIVATE'
28+
2429
message('Using python version @0@ from @1@'.format(py.version(), py.path()))
2530

2631
py.install_sources(

pypatch.patch

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
2-
index f58c719..071e6f6 100644
2+
index f58c7198..c65fc044 100644
33
--- a/src/py/libcamera/meson.build
44
+++ b/src/py/libcamera/meson.build
55
@@ -1,13 +1,13 @@
@@ -18,11 +18,9 @@ index f58c719..071e6f6 100644
1818

1919
if not pybind11_dep.found()
2020
pycamera_enabled = false
21-
@@ -76,31 +76,5 @@ pycamera_args = [
22-
'-fvisibility=hidden',
21+
@@ -77,30 +77,3 @@ pycamera_args = [
2322
'-Wno-shadow',
2423
'-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT',
25-
+ '-DLIBCAMERA_BASE_PRIVATE',
2624
]
2725
-
2826
-destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ requires = ['meson-python', 'pyyaml', 'pybind11']
44

55
[project]
66
name = 'libcamera'
7-
version = '0.1.0'
8-
description = 'Libcamera python bindings'
7+
version = '0.1.0a1'
8+
description = 'libcamera python bindings'
9+
readme = 'README.md'
10+
11+
[project.urls]
12+
Source = "https://github.com/will-v-pi/pylibcamera"
13+
libcamera = "https://git.libcamera.org/libcamera/libcamera.git"
914

1015
[tool.meson-python.args]
1116
setup = [

0 commit comments

Comments
 (0)