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

Add support for building Debian packages #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

Expand Down
122 changes: 122 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cargo-ament-build (0.1.9-100) focal jammy noble bookworm trixie; urgency=low

* source package automatically created by stdeb 0.10.1

-- None <None> Sun, 08 Dec 2024 17:51:16 +0100
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
15 changes: 15 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: cargo-ament-build
Maintainer: Esteve Fernandez <[email protected]>
Section: python
Priority: optional
Build-Depends: dh-python, python3-setuptools, python3-setuptools-rust, python3-all-dev, debhelper (>= 9)
Standards-Version: 3.9.1
Homepage: None
X-Python3-Version: >= 3.6

Package: python3-cargo-ament-build
Architecture: any
Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends}
Description: Cargo plugin for use with colcon workspaces
Cargo plugin for use with colcon workspaces

23 changes: 23 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/make -f

# This file was automatically generated by stdeb 0.10.1 at
# Sun, 08 Dec 2024 17:51:16 +0100

%:
dh $@ --with python3 --buildsystem=python_distutils

override_dh_auto_clean:
python3 setup.py clean -a
find . -name \*.pyc -exec rm {} \;

override_dh_auto_build:
python3 setup.py build --force

override_dh_auto_install:
python3 setup.py install --force --root=debian/python3-cargo-ament-build --no-compile -O0 --install-layout=deb --prefix=/usr

override_dh_python2:
dh_python2 --no-guessing-versions

override_dh_strip:
dh_strip --no-automatic-dbgsym
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
1 change: 1 addition & 0 deletions debian/source/options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend-diff-ignore="\.egg-info$"
47 changes: 47 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os
import shlex

try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib
from setuptools import setup

from setuptools_rust import RustBin

# Force the wheel to be platform specific
# https://stackoverflow.com/a/45150383/3549270
# There's also the much more concise solution in
# https://stackoverflow.com/a/53463910/3549270,
# but that would require python-dev
try:
# noinspection PyPackageRequirements,PyUnresolvedReferences
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel

# noinspection PyPep8Naming,PyAttributeOutsideInit
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False

except ImportError:
bdist_wheel = None

with open("Cargo.toml", "rb") as fp:
cargo_data = tomllib.load(fp)
version = cargo_data["package"]["version"]
description = cargo_data["package"]["description"]

# Use `--no-default-features` by default for a minimal build to support PEP 517.
# `MATURIN_SETUP_ARGS` env var can be used to pass customized arguments to cargo.
cargo_args = ["--no-default-features"]
long_description = description

setup(
version=version,
cmdclass={"bdist_wheel": bdist_wheel},
rust_extensions=[RustBin("cargo-ament-build", args=cargo_args, cargo_manifest_args=["--locked"])],
zip_safe=False,
description=description,
long_description=long_description,
)
6 changes: 6 additions & 0 deletions stdeb.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[cargo-ament-build]
No-Python2:
Build-Depends: python3-setuptools-rust
Suite: focal jammy noble bookworm trixie
X-Python3-Version: >= 3.6
Debian-Version: 100
Loading