indygreg / indygreg/PyOxidizer
init_fs_encoding fails when include_distribution_sources = False
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
Hey :-) When I set `include_distribution_sources = False`, the interpreter fails to start:
```
$ pyoxidizer run --release --target-triple i686-pc-windows-msvc
[ ... ]
Python path configuration:
PYTHONHOME = 'C:\w\build\i686-pc-windows-msvc\release\install\foo'
PYTHONPATH = (not set)
program name = 'C:\w\build\i686-pc-windows-msvc\release\install\foo\foo.exe'
isolated = 1
environment = 0
user site = 0
import site = 1
sys._base_executable = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo\\foo.exe'
sys.base_prefix = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo'
sys.base_exec_prefix = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo'
sys.platlibdir = 'lib'
sys.executable = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo\\foo.exe'
sys.prefix = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo'
sys.exec_prefix = 'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo'
sys.path = [
'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo\\python310.zip',
'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo\\DLLs',
'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo\\lib',
'C:\\w\\build\\i686-pc-windows-msvc\\release\\install\\foo',
]
error instantiating embedded Python interpreter: during initializing Python main: init_fs_encoding: failed to get the Python codec of the filesystem encoding
error: cargo run failed
```
my `pyoxidizer.bzl` is:
```bazel
def make_exe():
dist = default_python_distribution()
policy = dist.make_python_packaging_policy()
policy.include_distribution_sources = False
python_config = dist.make_python_interpreter_config()
exe = dist.to_python_executable(
name="foo",
config=python_config,
packaging_policy=policy,
)
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
files = FileManifest()
files.add_python_resource("foo", exe)
return files
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()
```
At first I thought it was due to some other specifics of my bzl (static build, py3.8 for win7 support, windows_runtime_dlls_mode=never) but it still happens after simplifying it to this.
My assumption was that it would compile the source modules to bytecode and include those into the exe instead; maybe I'm mistaken? Seeing the `PYTHONHOME` in the output, is the intention to provide your own copy of the stdlib, similar to the zipfile in the official cpython windows-embedded-packages?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal pyoxidizer.bzl configuration in the report and reproduce the failure using `pyoxidizer run --release --target-triple i686-pc-windows-msvc` with `include_distribution_sources = False`. Trace the embedded Python startup failure around `init_fs_encoding`; done means the generated executable starts successfully with that policy setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100