indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.41k stars 234 forks source link

Make 'pyoxidizer init-config-file .' behave more gracefully #404

Open njsmith opened 3 years ago

njsmith commented 3 years ago

Following the tutorial, I did:

$ pip install pyoxidizer
$ pyoxidizer init-config-file .
$ pyoxidizer run

Sadly, instead of a REPL, I get:

``` libpythonXY created building with Rust 1.52.0 Downloading crates ... Downloaded base64 v0.13.0 Downloaded dunce v1.0.1 Downloaded jemallocator v0.3.2 Downloaded quoted_printable v0.4.3 Downloaded paste v1.0.5 Downloaded walkdir v2.3.2 Downloaded regex v1.5.4 Downloaded itertools v0.10.0 Downloaded memchr v2.4.0 Downloaded byteorder v1.4.3 Downloaded embed-resource v1.6.2 Downloaded either v1.6.1 Downloaded once_cell v1.7.2 Downloaded regex-syntax v0.6.25 Downloaded python-packaging v0.9.0 Downloaded mailparse v0.13.4 Downloaded python3-sys v0.6.0 Downloaded jemalloc-sys v0.3.2 Downloaded charset v0.1.2 Downloaded tugger-licensing v0.3.0 Downloaded same-file v1.0.6 Downloaded spdx v0.4.0 Downloaded python-packed-resources v0.7.0 Downloaded fs_extra v1.2.0 Downloaded tugger-file-manifest v0.4.0 Downloaded pyembed v0.16.0 Downloaded base64 v0.10.1 Downloaded encoding_rs v0.8.28 Downloaded anyhow v1.0.40 Downloaded memmap v0.7.0 Downloaded aho-corasick v0.7.18 Downloaded cc v1.0.67 Downloaded cpython v0.6.0 error: no bin target named `.` error[PYOXIDIZER_PYTHON_EXECUTABLE]: adding PythonExecutable to FileManifest Caused by: 0: building Python executable 1: building executable with Rust project 2: reading cargo output 3: command ["/home/njs/.cache/pyoxidizer/rust/1.52.0-x86_64-unknown-linux-gnu/bin/cargo", "build", "--target", "x86_64-unknown-linux-gnu", "--target-dir", "/tmp/pyoxidizernsLcBS/build/target", "--bin", ".", "--locked", "--no-default-features", "--features", "build-mode-prebuilt-artifacts cpython-link-unresolved-static global-allocator-jemalloc allocator-jemalloc"] exited with code 101 --> ./pyoxidizer.bzl:271:5 | 271 | files.add_python_resource(".", exe) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PythonExecutable.to_file_manifest() error: adding PythonExecutable to FileManifest Caused by: 0: building Python executable 1: building executable with Rust project 2: reading cargo output 3: command ["/home/njs/.cache/pyoxidizer/rust/1.52.0-x86_64-unknown-linux-gnu/bin/cargo", "build", "--target", "x86_64-unknown-linux-gnu", "--target-dir", "/tmp/pyoxidizernsLcBS/build/target", "--bin", ".", "--locked", "--no-default-features", "--features", "build-mode-prebuilt-artifacts cpython-link-unresolved-static global-allocator-jemalloc allocator-jemalloc"] exited with code 101 ```

This is with:

PyOxidizer 0.16.2
commit: e91995636f8deed0a7d8e1917f96a7dc17309b63
source: https://github.com/indygreg/PyOxidizer.git
pyembed crate location: version = "0.16.0"
njsmith commented 3 years ago

On further investigation: the problem turned out to be that pyoxidizer init-config-file . generated this starlark code:

    exe = dist.to_python_executable(
        name=".",

        # If no argument passed, the default `PythonPackagingPolicy` for the
        # distribution is used.
        packaging_policy=policy,

        # If no argument passed, the default `PythonInterpreterConfig` is used.
        config=python_config,
    )

And the name="." caused things to fail with that confusing message. Changing it to name="somestring" makes everything work.

Possible fixes:

indygreg commented 3 years ago

Thanks for the bug report and the investigation.

I agree we should do something more user friendly here.