beeware / briefcase

Tools to support converting a Python project into a standalone native application.
https://briefcase.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.5k stars 354 forks source link

ruamel.yaml doesn't work in requires for pyproject.toml #1718

Closed nwood21 closed 3 months ago

nwood21 commented 3 months ago

Describe the bug

For my Python project am attempting to use the module ruamel.yaml which runs fine in Python but when I compile the project the app always crashes and says the module is missing.

** Note This is my requires for my project in my pyproject.toml file:

requires = [
    "pyautogui",
    "python-dateutil",
    "PyYAML",
    "ruamel.yaml",
    "send2trash",
    "docx2txt",
]

Here are my imports:

import toga
import importlib
from toga.style import Pack
from toga.style.pack import COLUMN, ROW, LEFT, RIGHT, CENTER, SERIF, BOLD
from toga.sources import ListSource
import os
import pyautogui
import sys
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from dateutil.parser import parse
from calendar import monthrange
import yaml
import ruamel.yaml
import calendar
import itertools
import logging
import platform
import threading
import subprocess
import send2trash
import platform
import docx2txt
import asyncio
import shlex
import time
import shutil
import glob
import os
import re

The only thing I could get the app not to crash was to manually pip3 install the package into the app_packages. Then, after that, when I ran the app, no crashes:

pip3 install ruamel.yaml --target=/Users/myusernamekeptprivate/MyBin/Briefcase/tms/build/tms/macos/app/TMS.app/Contents/Resources/app_packages

How do I get ruamel.yaml to successfully get included in my requires without having to manually install it in the app_packages folder? Quite buggy.

Steps to reproduce

  1. pip3 install ruamel.yaml
  2. Create new briefcase project
  3. In your app.py 'import ruamel.yaml'
  4. Update your pyproject.toml to include 'ruamel.yaml'
  5. briefcase run or briefcase run -u to update.
  6. App crashes says it's missing the module. ruamel.yaml works perfectly fine in Python but requires fails to install in project.
  7. pip3 install ruamel.yaml --target=/Users/myusernamekeptprivate/MyBin/Briefcase/tms/build/tms/macos/app/TMS.app/Contents/Resources/app_packages
  8. App does not crash because module has been manually installed.

Expected behavior

App Crashes, can't find module.

Screenshots

No response

Environment

Logs

Additional context

No response

rmartin16 commented 3 months ago

Can you try running briefcase run -r? That will (re-)install all the requirements for the app before running it.

nwood21 commented 3 months ago

Solved! I was just running the briefcase -u command (I mistakenly thought that this would also update the briefcase requirements. It seems intuitive that when you run -u it also looks at the requirements and updates those too but I was mistaken. Might be worth adding in the manual for clarity that if "Changing your 'requires' in the pyproject.toml file by adding a new module you cannot simply using briefcase -u alone, must run briefcase -r." Anyway, thank you for the suggestion!!! Very kind.