gradle-use-python-plugin icon indicating copy to clipboard operation
gradle-use-python-plugin copied to clipboard

Install artifact from another project

Open mceste-volume opened this issue 3 years ago • 3 comments

It would be nice if it were possible to specify a file as a module to install so that we can share modules between projects in a multi module project. I’m not a seasoned Python developer therefore they may be a better way to achieve this, ideally without sharing a virtual environment in the root project.

For context, we have a pythonBuild task that creates a source distribution that we’d like to pip install in a downstream project. Another option is add the source to the PYTHONPATH for the downstream project.

mceste-volume avatar Mar 27 '21 14:03 mceste-volume

For context, we have a pythonBuild task that creates a source distribution that we’d like to pip install in a downstream project. Another option is add the source to the PYTHONPATH for the downstream project.

This should be already possible with process-specific environment variables:

python {
   environment 'PYTHONPATH', project.file('path to file').getAbsolutePath()
}

This way it would be applied for all executed python tasks (including pipInstall). But maybe it should be put directly to pipInstall task only (pipInstall.environment 'PYTHONPATH', project.file('path to file').getAbsolutePath()): don't know if PYTHONPATH required only for module installation.


It would be nice if it were possible to specify a file as a module to install so that we can share modules between projects in a multi module project.

I suppose you refer to installation from local source tree. It should be easy to support (not supported now!) it with something like:

python.pip file('path to file')

which will become: python -m pip install <path to file>

But I need to know if -e (dev mode) could be ignored or it might be useful too. Also, I will need some hello world module (local dir to use as a module) which I can use for tests (I don't use python at all, and I, of course, could read docs and find out how to write such module, but it would be super awesome if real python user could save my time).

So if you need this feature, I'm open to discussion (of how it should be) and need some help (with a real case, I can test against).

xvik avatar Mar 27 '21 20:03 xvik

In case if anyone else needs local modules support, please provide a sample usage example (complete simplified use-case).

xvik avatar Apr 08 '21 11:04 xvik

Released version 3.0.0 with requirements file support.

It should be possible now to use any modules using native requirements syntax.

To enable native mode:

python.requirements.strict = false

(this way file would be loaded with pip: pip -r requirements.txt)

Requirements file, I suppose, would be like this (requirements.txt):

./submodule/build/something-1.0-cp34-none-win32.whl

xvik avatar Oct 22 '22 13:10 xvik

Assuming to be solved. Please reopen if required features still missed.

xvik avatar Apr 14 '24 07:04 xvik