rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
131 stars 80 forks source link

Python requirements.txt file on Windows includes local file paths #494

Closed slodge closed 1 year ago

slodge commented 3 years ago

I'm using python inside connect for the first time this week - so apologies if these are "newbie" errors.

I'm working on Windows desktop and discovering that the generated pip requirements.txt file includes some nasty local file paths which cause pip on the server to fail.

For example, using a standard notebook like https://github.com/sol-eng/python-examples/tree/master/rmarkdown-notebook

This causes rsconnect::writeManifest("reticulate", "FirstAttempt.Rmd") to generate a requirements.txt file:

certifi==2020.12.5
numpy @ file:///D:/bld/numpy_1610324703282/work
pandas @ file:///D:/bld/pandas_1607423921518/work
python-dateutil==2.8.1
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1612179539967/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1590081179328/work
wincertstore==0.2

This will not upload to the server unless I manually edit it down to:

certifi==2020.12.5
numpy
pandas
python-dateutil==2.8.1
pytz
six
wincertstore==0.2

I think this is somehow related to https://github.com/pypa/pip/issues/8174 - it seems like the miniconda distribution that RStudio installed has pip --version of pip 21.0.1

For now I'm working around this by manually editing the requirements files.

Is this just a bug in pip? Or is it something rsconnect needs to be aware of too?

kevinushey commented 3 years ago

Do you know whether these packages were installed by pip, or via the conda package repository?

slodge commented 3 years ago

Not entirely sure I know what I'm doing so apologies if my answers are a little imprecise...

On this development box I didn't have a python installation configured, so the R console prompted me to install and use miniconda - which seemed to bundle most of these packages with it.

The only addition was pandas - i installed that using py_install from within R.

Not sure if that answers your question...

On Fri, 26 Mar 2021, 21:49 Kevin Ushey, @.***> wrote:

Do you know whether these packages were installed by pip, or via the conda package repository?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rstudio/rsconnect/issues/494#issuecomment-808531130, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJHSETTMAZIMUXYN432DTFT6ORANCNFSM4Z3R22UA .

jmcphers commented 3 years ago

@mmarchetti Do you know why this might happen?

mmarchetti commented 3 years ago

Yes. Conda leaves metadata hanging around, and pip (as of pip 20.1) picks it up and includes it in the output from pip freeze. See https://github.com/rstudio/rsconnect-python/issues/166. We've worked around this by using pip list --format=freeze, which omits the metadata paths, but that may change given https://github.com/pypa/pip/issues/8176 and https://github.com/pypa/pip/issues/7157.

Some options here:

hadley commented 1 year ago

Since there hasn't been any follow up in the last few months, and it sounds like there's a good chance this is fixed in main, I'm going to close this issue. Happy to reopen if there's more work to be done.