Building a Debian package from a Python application (using pdm as build backend) does not work in gitlab-CI (proxy problem?)

I have a pdm-based Python app (let’s call it “myapp”) and I want to have it installed on Debian target system via a Debian package. The Debian package should be built in a gitlab CI process.

An illustration just to keep it in mind – this should happen in the gitlab CI process:

+--------------------+    +-----------+    +---------------------------+
| python app "myapp" | -> | pdm build | -> | deb package "myapp...deb" |
+--------------------+    +-----------+    +---------------------------+

The problem is that generating the Debian package like this works flawlessly when I perfom the steps from .gitlab-ci.yml interactively in a Docker container – but the gitlab CI process would always fail with:

[...]

Processing /builds/aye/_build_dir
  Installing build dependencies: started
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
[...]

make: *** [debian/rules:4: binary] Error 1
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b failed

The error message (pip failure) seems to point to an Internet connection problem, so that pip would be unable to fetch what it needs.

Here is the .gitlab-ci.yml file used:

variables:
  http_proxy: $CODE_PROXY
  https_proxy: $CODE_PROXY
  no_proxy: $CODE_NO_PROXY
  HTTP_PROXY: $http_proxy
  HTTPS_PROXY: $http_proxy
  NO_PROXY: $no_proxy

build_deb:
  image: debian:12
  script:
    - apt update && apt-get install -y dh-virtualenv devscripts python3-full python3-pip build-essential python3-dev python3-venv python3-pdm
    - mkdir -p _build_dir
    - cd _build_dir
    - cp -r ../* . || true # ignore error from copy _build_dir into itself
    - debuild -b -us -uc
    - cd ..
  artifacts:
      paths:
        - myapp*
  rules:
      - if: $CI_COMMIT_TAG

Well, if I perform these steps manually in a “debian:12” Docker container, everything, including the last step debuild, works like a charm.

But if I manipulate the proxy settings, the interactive build would also fail, showing the same behavior as the failed gitlab CI pipeline. => for me this is the prove that proxy settings are the cause of the problem.

However, as you can see, I do set proxy env variable at the beginning of the .gitlab-ci.yml script. The used variables ($CODE_PROXY etc.) are predefined variables from the gitlab installation. The used shared runners have no direct connection to the Internet, thus needing these proxy settings. The values of the proxy (corporate proxy) settings are proven correct and work – but just not in this case, as it seems.

So, the difference between the interactive build (working) and the automated CI build (not working) is:

  • the “debian:12” Docker container on my PC does not need any proxy settings – so, none are set
  • the gitlab CI process relies on a (corporate) proxy. This is set, but it fails anyway.

The debian/rules file – which dictates how the Debian package would be built – is:

#!/usr/bin/make -f

%:
    dh $@ --with python-virtualenv --python /usr/bin/python3

So the entire “debhelper” magic is within the dh command (more exactly, in the dh binary step invoked by dh).

All info I could find state that pdm (invoked by dh‘s “dh_auto_build” feature) would honor such env variables.

What could be the problem? I am stuck …

UPDATE 2024-08-31 14:15 UTC:

I tested some variants – the proxy behavior seems a little bit weird to me – because it looks inconsistent. Look at this:

I created a gitlab CI pipeline with 3 jobs. Each job performs the task of building a Debian package differently:

Job 1: call debuild

A simple debuild -b -us -ui

Job2: call dpkg-buildpackage

debuild would call dpkg-buildpackage and then lintian – so in this variant call the first one is called instead of using debuild:

dpkg-buildpackage -us -uc -ui -b

Job 3: call dh scripts

dpkg-buildpackage would involke several scripts. So in this variant the necessary dh_* scripts are called one after the other explicitly:

dh clean --with python-virtualenv --python /usr/bin/python3
dh build --with python-virtualenv --python /usr/bin/python3
dh binary --with python-virtualenv --python /usr/bin/python3

Result from the gitlab CI pipeline:

  • Job debuild: FAIL
  • Job dpkg-buildpackage: SUCCESS
  • Job dh scripts: SUCCESS

How can it be that debuild fails at the stage of calling dh binary when this steps works in the dpkg-buildpackage job and in the job which calls the dh_* scripts one after the other?

What does debuild do differently (with respect to proxy servers, as it seems …?)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật