Skip to content

FIX: package libctranslate2.so in wheel to avoid build fail - #1920

Merged
jordimas merged 3 commits into
OpenNMT:masterfrom
yzewei:fix-build-pip
Dec 4, 2025
Merged

FIX: package libctranslate2.so in wheel to avoid build fail#1920
jordimas merged 3 commits into
OpenNMT:masterfrom
yzewei:fix-build-pip

Conversation

@yzewei

@yzewei yzewei commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

On Linux, installing the ctranslate2 wheel may fail to find the libctranslate2 shared library, causing import errors.

This patch updates setup.py to include libctranslate2.so in the wheel via package_data for Linux.

For detailed error information, see the related issue: [issue#1919]

Signed-off-by: yzewei <yangzewei@loongson.cn>
Comment thread python/setup.py
elif sys.platform == "linux":
cflags.append("-fPIC")
ldflags.append("-Wl,-rpath,-Wl,-rpath,/usr/local/lib64")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Two comments:

  • -Wl,-rpath is repeated twice in " ldflags.append("-Wl,-rpath,-Wl,-rpath"
  • ,/usr/local/lib64 may not work in some distros that use /usr/local/lib

A better solution may be:

ldflags.append("-Wl,-rpath,/usr/local/lib64:/usr/local/lib")

@jordimas
jordimas merged commit 600880d into OpenNMT:master Dec 4, 2025
16 checks passed
jordimas added a commit to jordimas/CTranslate2 that referenced this pull request Dec 17, 2025
…1920)

* package libctranslate2.so in wheel to avoid import errors

Signed-off-by: yzewei <yangzewei@loongson.cn>

* Fix based on PR discussion

---------

Signed-off-by: yzewei <yangzewei@loongson.cn>
Co-authored-by: Jordi Mas <jmas@softcatala.org>
Lanurence666 pushed a commit to Lanurence666/CTranslate2_backport_py38 that referenced this pull request May 23, 2026
…1920)

* package libctranslate2.so in wheel to avoid import errors

Signed-off-by: yzewei <yangzewei@loongson.cn>

* Fix based on PR discussion

---------

Signed-off-by: yzewei <yangzewei@loongson.cn>
Co-authored-by: Jordi Mas <jmas@softcatala.org>
veilnetwork pushed a commit to veilnetwork/CTranslate2 that referenced this pull request Aug 27, 2026
…1920)

* package libctranslate2.so in wheel to avoid import errors

Signed-off-by: yzewei <yangzewei@loongson.cn>

* Fix based on PR discussion

---------

Signed-off-by: yzewei <yangzewei@loongson.cn>
Co-authored-by: Jordi Mas <jmas@softcatala.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants