indygreg / indygreg/PyOxidizer

Unable to install urwid: in-memory-only resources policy active

Open
#261 4 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

Hello,

I'm having trouble installing urwid with the below config, on MacOS 10.15.4, EDIT: pyoxidizer 0.7.0.

EDIT: To try to isolate the issue, the below config is nearly unchanged from the default; the only changes are to the pip_install urwid and run_eval lines.

Collecting urwid
  Downloading urwid-2.1.0.tar.gz (630 kB)
Installing collected packages: urwid
    Running setup.py install for urwid: started
    Running setup.py install for urwid: finished with status 'done'
Successfully installed urwid-2.1.0
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
error[PYOXIDIZER_BUILD]: in-memory-only resources policy active but in-memory extension module importing not supported by this configuration
  --> ./pyoxidizer.bzl:99:5
   |
99 |     exe.add_in_memory_python_resources(dist.pip_install(["urwid"]))
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ add_extension_module


error: in-memory-only resources policy active but in-memory extension module importing not supported by this configuration
# This file defines how PyOxidizer application building and packaging is
# performed. See the pyoxidizer crate's documentation for extensive
# documentation on this file format.

# Obtain the default PythonDistribution for our build target. We link
# this distribution into our produced executable and extract the Python
# standard library from it.
def make_dist():
    return default_python_distribution()

# Configuration files consist of functions which define build "targets."
# This function creates a Python executable and installs it in a destination
# directory.
def make_exe(dist):
    # This variable defines the configuration of the
    # embedded Python interpreter.
    python_config = PythonInterpreterConfig(
    #     bytes_warning=0,
    #     dont_write_bytecode=True,
    #     ignore_environment=True,
    #     inspect=False,
    #     interactive=False,
    #     isolated=False,
    #     legacy_windows_fs_encoding=False,
    #     legacy_windows_stdio=False,
    #     no_site=True,
    #     no_user_site_directory=True,
    #     optimize_level=0,
    #     parser_debug=False,
    #     stdio_encoding=None,
    #     unbuffered_stdio=False,
    #     filesystem_importer=False,
    #     sys_frozen=False,
    #     sys_meipass=False,
    #     sys_paths=None,
    #     raw_allocator=None,
    #     terminfo_resolution="dynamic",
    #     terminfo_dirs=None,
    #     use_hash_seed=False,
    #     verbose=0,
    #     write_modules_directory_env=None,
          run_eval='import urwid',
    #     run_module=None,
    #     run_noop=False,
    #     run_repl=True,
    )

    # The run_eval, run_module, run_noop, and run_repl arguments are mutually
    # exclusive controls over what the interpreter should do once it initializes.
    #
    # run_eval -- Run the specified string value via `eval()`.
    # run_module -- Import the specified module as __main__ and run it.
    # run_noop -- Do nothing.
    # run_repl -- Start a Python REPL.
    #
    # These arguments can be ignored if you are providing your own Rust code for
    # starting the interpreter, as Rust code has full control over interpreter
    # behavior.

    # Produce a PythonExecutable from a Python distribution, embedded
    # resources, and other options. The returned object represents the
    # standalone executable that will be built.
    exe = dist.to_python_executable(
        name="urwid",
        config=python_config,
        # Embed all extension modules, making this a fully-featured Python.
        extension_module_filter='all',

        # Only package the minimal set of extension modules needed to initialize
        # a Python interpreter. Many common packages in Python's standard
        # library won't work with this setting.
        #extension_module_filter='minimal',

        # Only package extension modules that don't require linking against
        # non-Python libraries. e.g. will exclude support for OpenSSL, SQLite3,
        # other features that require external libraries.
        #extension_module_filter='no-libraries',

        # Only package extension modules that don't link against GPL licensed
        # libraries.
        #extension_module_filter='no-gpl',

        # Include Python module sources. This isn't strictly required and it does
        # make binary sizes larger. But having the sources can be useful for
        # activities such as debugging.
        include_sources=True,

        # Whether to include non-module resource data/files.
        include_resources=False,

        # Do not include functionality for testing Python itself.
        include_test=False,
    )

    # Invoke `pip install` with our Python distribution to install a single package.
    # `pip_install()` returns objects representing installed files.
    # `add_in_memory_python_resources()` adds these objects to the binary,
    # marking them for in-memory loading.
    exe.add_in_memory_python_resources(dist.pip_install(["urwid"]))

    # Invoke `pip install` using a requirements file and add the collected resources
    # to our binary.
    #exe.add_in_memory_python_resources(dist.pip_install(["-r", "requirements.txt"]))



    # Read Python files from a local directory and add them to our embedded
    # context, taking just the resources belonging to the `foo` and `bar`
    # Python packages.
    #exe.add_in_memory_python_resources(dist.read_package_root(
    #    path="/src/mypackage",
    #    packages=["foo", "bar"],
    #))

    # Discover Python files from a virtualenv and add them to our embedded
    # context.
    #exe.add_in_memory_python_resources(dist.read_virtualenv(path="/path/to/venv"))

    # Filter all resources collected so far through a filter of names
    # in a file.
    #exe.filter_from_files(files=["/path/to/filter-file"]))

    # Return our `PythonExecutable` instance so it can be built and
    # referenced by other consumers of this target.
    return exe

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

def make_install(exe):
    # Create an object that represents our installed application file layout.
    files = FileManifest()

    # Add the generated executable to our install layout in the root directory.
    files.add_python_resource(".", exe)

    return files

# Tell PyOxidizer about the build targets defined above.
register_target("dist", make_dist)
register_target("exe", make_exe, depends=["dist"], default=True)
register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"])

# Resolve whatever targets the invoker of this configuration file is requesting
# be resolved.
resolve_targets()

# END OF COMMON USER-ADJUSTED SETTINGS.
#
# Everything below this is typically managed by PyOxidizer and doesn't need
# to be updated by people.

PYOXIDIZER_VERSION = "0.7.0"
PYOXIDIZER_COMMIT = "UNKNOWN"

Am I doing something wrong? I've read the blog post about 0.7.0 and tried search through the issues. urwid does include one C module called str_util that I presume is the problem, but after reading the blog post on 0.7 I wondered if perhaps I was just loading it wrong. Is there a switch somewhere in the config that I need to enable to use "in-memory extension module importing" as per the error message?

Many thanks in advance, such a cool project.

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 pyoxidizer.bzl at line 99, especially add_in_memory_python_resources(), run_eval, and extension_module_filter. Compare the reported policy error with PyOxidizer 0.7.0 documentation and inspect urwid's source/str_util.c module. Done means the configuration's support or limitation for importing urwid is clearly established and the reported build behavior is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, 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.