indygreg / indygreg/PyOxidizer

Unable to package with setup_py_install

Open
#388 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
6.2k
Forks
256
PR merge metrics
No merged PRs in 30d

Description

Hey, I'm having some trouble packaging some code with `setup_py_install` and wondering if I've misunderstood how it should be used. If so I'm happy to propose docs updates to help out the next person.

Here's my build config (skipped everything that's the same from the example):

```starlark
def make_exe(dist):
policy = dist.make_python_packaging_policy()
python_config = dist.make_python_interpreter_config()
python_config.run_command = "import myapp.__main__"
exe = dist.to_python_executable(
name="myapp",
packaging_policy=policy,
config=python_config,
)
exe.add_python_resources(exe.pip_install(["-r", "requirements/app.txt"]))
application = exe.setup_py_install(
package_path=".",
extra_envs={"VERSION": "1"},
)
exe.add_python_resources(application)
return exe
```

And here's my setup.py (skipped irrelevant metadata):

```python
import os
from setuptools import find_packages, setup

setup(
name="myapp",
version=os.environ.get("VERSION", "dev"),
packages=find_packages(where="src"),
package_dir={"": "src"},
entry_points={"console_scripts": ["myapp=myapp.__main__:main"]},
)
```

And then finally I've got a package laid out like this:

```
setup.py
pyoxidizer.bzl
src >
myapp >
__init__.py
__main__.py
```

This build successfully, but when run gives the output:

```
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'myapp'
```

In addition, I can see in the build log the output:

```
collected 0 resources from setup.py install
```

This suggests to me that `setup_py_install` is running, completing successfully, but failing to actually add any resources, resulting in an empty list being returned, which means that nothing is added to the executable during the build. This would explain the fact that the module doesn't exist at runtime.

This works fine with `python setup.py install`, and `pip install -e .` – both result in an installed and working package, so I suspect this is an interaction between setuptools and the PyOxidizer build environment, or more likely I've just missed a step! I've also tried dropping the `src` directory – moving the module up to the top level, dropping the `package_dir` and the `where='src'`. It seems to fail in the same way.

I'm running PyOxidizer 0.13.2 on macOS 11.3, building for Python 3.9.

Any help is greatly appreciated. Happy to provide any more context I can give.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the pyoxidizer.bzl configuration and setup.py, then inspect the setup_py_install entry point and reproduce the build with PyOxidizer 0.13.2. Confirm why the build reports 0 collected resources and ensure the resulting executable can import myapp at runtime.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.