Skip to content

briefcase dev does not always install required dependencies #1733

@mwchase

Description

@mwchase

Describe the bug

I managed to get briefcase into a state where my app is missing dependencies like toga, but briefcase dev does not reinstall, and simply fails.

Steps to reproduce

  1. Follow the tutorial at https://docs.beeware.org/en/latest/tutorial/tutorial-1.html, but use pipx to install briefcase instead of explicitly managing a virtual environment
  2. Before running briefcase dev, see what's in the virtual environment currently (via pipx runpip briefcase freeze)
  3. Run briefcase dev (and rerun pipx runpip briefcase freeze)
  4. Uninstall briefcase
  5. Reinstall briefcase
  6. Run briefcase dev

Expected behavior

The first briefcase dev run installs dependencies and runs successfully. The second such run should do the same.

Screenshots

No response

Environment

  • Operating System: Ubuntu 22.04
  • Python version: 3.12.2
  • Software versions:
    • Briefcase: 0.3.17

Logs

First freeze output:

arrow==1.3.0
binaryornot==0.4.4
briefcase==0.3.17
build==1.2.1
certifi==2024.2.2
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
cookiecutter==2.6.0
gitdb==4.0.11
GitPython==3.1.43
idna==3.7
Jinja2==3.1.3
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
packaging==24.0
platformdirs==4.2.0
psutil==5.9.8
Pygments==2.17.2
pyproject_hooks==1.0.0
python-dateutil==2.9.0.post0
python-slugify==8.0.4
PyYAML==6.0.1
requests==2.31.0
rich==13.7.1
setuptools==69.0.3
six==1.16.0
smmap==5.0.1
text-unidecode==1.3
tomli_w==1.0.0
types-python-dateutil==2.9.0.20240316
urllib3==2.2.1
wheel==0.42.0

Second freeze output:

arrow==1.3.0
binaryornot==0.4.4
briefcase==0.3.17
build==1.2.1
certifi==2024.2.2
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
cookiecutter==2.6.0
gbulb==0.6.4
gitdb==4.0.11
GitPython==3.1.43
idna==3.7
iniconfig==2.0.0
Jinja2==3.1.3
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
packaging==24.0
platformdirs==4.2.0
pluggy==1.4.0
psutil==5.9.8
pycairo==1.26.0
Pygments==2.17.2
PyGObject==3.48.2
pyproject_hooks==1.0.0
pytest==8.1.1
python-dateutil==2.9.0.post0
python-slugify==8.0.4
PyYAML==6.0.1
requests==2.31.0
rich==13.7.1
setuptools==69.0.3
six==1.16.0
smmap==5.0.1
text-unidecode==1.3
toga-core==0.4.2
toga-gtk==0.4.2
tomli_w==1.0.0
travertino==0.3.0
types-python-dateutil==2.9.0.20240316
urllib3==2.2.1
wheel==0.42.0

Final dev output:

[helloworld] Starting in dev mode...
===========================================================================
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/home/maxchase/beeware-tutorial/helloworld/src/helloworld/__main__.py", line 1, in <module>
    from helloworld.app import main
  File "/home/maxchase/beeware-tutorial/helloworld/src/helloworld/app.py", line 4, in <module>
    import toga
ModuleNotFoundError: No module named 'toga'

Problem running app helloworld.

Log saved to /home/maxchase/beeware-tutorial/helloworld/logs/briefcase.2024_04_15-18_26_06.dev.log

Additional context

In a sense, a lot of this is self-inflicted, but it's weird that I was able to self-inflict it. I ended up going down this path because I wanted to see what would happen if I avoided making a virtual environment explicitly, and simply relied on other tools to manage it. But when I saw that it was installing packages in its virtual environment, I didn't want just one briefcase install.

I feel like what briefcase is doing here is at odds with the direction the Python ecosystem is going. Lots of tools and projects are focused around the idea of lockfiles or explicit requirements, and briefcase dev just kind of YOLOs its own virtual environment. Are there any tools beyond just virtualenv/venv that briefcase dev is meant to work with?

(Also, how is it getting into a state where it won't try to install the dependencies? I "fixed" it by blowing away the project directory and creating it from scratch...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions