Skip to content

Separate development and release python environments #247

Open
@touilleMan

Description

@touilleMan

Something I'm still not sure about is how to make the difference between the development installation and the release installation of python dependencies.

For instance you could install cython, black and numpy when developing on your project, but when doing the release you would only want numpy (given cython is only needed at compile time and black is a tool to keep the code clean).

It feels like we would need two virtualenv (one dev, on release) preconfigured, so instead of doing:

$  .\addons\pythonscript\windows-64\python.exe -m pip install cython black numpy

we would do:

$  .\addons\pythonscript\windows-64\python.exe -m pip install --target=python_deps_release numpy
$  .\addons\pythonscript\windows-64\python.exe -m pip install --target=python_deps_dev cython black

Here the --target=... install the packages in the given folder, so we keep the addons/pythonscript folder unchanged (it site-packages folder still contains nothing and doing .\addons\pythonscript\windows-64\python.exe -m cython will complain the module is not installed)

From there we could have two separate DEV_PYTHON_PATH and PROD_PYTHON_PATH options in the godot python settings.

Some issues on this though:

  • pip is not provided with pythonscript, so the user has to do python -m ensurepip prior to any pip install. It would be better to automatically do this on install (or maybe ship directly pip, but given it's not something CPython is doing I guess it's not a good idea to do it ourselves)
  • addons/pythonscript/window-64/python.exe -m pip install --target=<> is a complex command, it would be much better to have a script wrapping this (typically using the godot --script=my_script.gd command, though is this really simpler if user has to type godot --path my_project --script res://addons/pythonscripts/pip_for_dev install black ?)

On top of that, it could be good to add support for requirements.txt (having DEV_REQUIREMENTS_PATH/RELEASE_REQUIREMENTS_PATH in godot python settings).
A full setup.py support seems to much of a hassle from my point of view given how messy this format is (cf. pyproject.toml, setup.py, setup.cfg, setuptools, distutils, poetry and other buzzwords ^^).

I'm currently working on install manager for pythonscript: you would install this installer from the assetlib (it's only a couple of .gd files and is designed not to changes too often), then it would be responsible for downloading&installing the last version of pythonscript compatible with your OS and Godot version.
On top of that the installer could also be responsible for doing the python -m ensurepip and python -m pip install --target=python_deps_release -r $RELEASE_REQUIREMENTS_PATH && python -m pip install --target=python_dev_release -r $DEV_REQUIREMENTS_PATH

This seems like a good way to bootstrap your project on a new computer (hence the user wouldn't have to save pythonscript and the python dependencies as part of it game project, but only the requirements.txt and potentially a small config file specifying which version of pythonscript should be used)

However this ask the question on how to add/remove dependencies to the requirements.txt and update the virtualenvs accordingly... Should we leave this to the command line or can we provide a GUI within Godot to allow user to do this in a user friendly way ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions