indygreg / indygreg/PyOxidizer

Error only when building a Fully Statically Linked Binary on Linux

Open
#450 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6.2k
Forks
256
PR merge metrics
No merged PRs in 30d

Description

I'm using PyOxidizer to build a binary for my project [Cifra](https://github.com/dante-signal31/cifra) (at my "pyoxidizer" branch).

My pyoxidizer.bzl is at root folder, next to setup.py:

```python
def make_exe():
dist = default_python_distribution()
policy = dist.make_python_packaging_policy()
policy.resources_location = "filesystem-relative:lib"
python_config = dist.make_python_interpreter_config()
python_config.run_command = "from cifra.cifra_launcher import main; main()"
exe = dist.to_python_executable(
name="cifra",
packaging_policy=policy,
config=python_config,
)
exe.add_python_resources(exe.setup_py_install(package_path=CWD))
return exe

def make_embedded_resources(exe):
return exe.to_embedded_resources()

def make_install(exe):
files = FileManifest()
files.add_python_resource(".", exe)
return files

def register_code_signers():
if not VARS.get("ENABLE_CODE_SIGNING"):
return

register_code_signers()

register_target("exe", make_exe)
register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"], default=True)

resolve_targets()
```

With that configuration I get a proper binary file with *"pyoxidizer build"*.

However, problem arises when I try to build a fully statically linked binary. I've followed [instructions page build static binaries](https://pyoxidizer.readthedocs.io/en/latest/pyoxidizer_packaging_static_linking.html). I've updated rust:

```bash
(venv)dante@Camelot:~/Projects/cifra$ rustup target add x86_64-unknown-linux-musl
```
But when I build process ends with this error:

```bash
(venv)dante@Camelot:~/Projects/cifra$ pyoxidizer build --target-triple x86_64-unknown-linux-musl
[...]
Running greenlet-1.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-futc9qp4/greenlet-1.1.1/egg-dist-tmp-zga041e7
no previously-included directories found matching 'docs/_build'
warning: no files found matching '*.py' under directory 'appveyor'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
warning: no previously-included files matching '.coverage' found anywhere in distribution
error: Setup script exited with error: command 'musl-clang' failed: No such file or directory
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "command [\"/home/dante/.cache/pyoxidizer/python_distributions/python.70974f0c6874/python/install/bin/python3.9\", \"setup.py\", \"install\", \"--prefix\", \"/tmp/pyoxidizer-setup-py-installvKsIUS/install\", \"--no-compile\"] exited with code 1" }', pyoxidizer/src/py_packaging/packaging_tool.rs:336:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

To make it work, I've installed musl, musl-dev an clang packages but error persists. I'm in a Linux Mint 20.2 (uma).

Is it a bug or am I doing something wrong?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the static-linking instructions and the pyoxidizer.bzl configuration, then inspect the setup.py installation of greenlet where the musl-clang command fails. Reproduce with pyoxidizer build --target-triple x86_64-unknown-linux-musl and verify whether the required toolchain is discoverable on Linux Mint. Done means the static build completes without the missing-command error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.