Packaging supporting R code in a python module?

后端 未结 3 1169
天命终不由人
天命终不由人 2021-02-02 17:45

I am trying to package some of my Python code that calls R code using rpy2. That R code currently sits in a separate file which I source from the Python script. For

3条回答
  •  时光取名叫无心
    2021-02-02 18:23

    This question might be dated, but I ran into the same issue today and wanted to provide more detail for the question 1 solution suggested by @ivan_pozdeev and a new solution for question 2.

    1) Edit your setup.py file to:

    from setuptools import setup, find_packages
    
    setup(
        ...
        # If any package contains *.r files, include them:
        package_data={'': ['*.r', '*.R']},
        include_package_data=True)
        )
    

    2) Conda is quickly becoming a good option for dealing with package dependencies across both python and R. You can create an environment (http://conda.pydata.org/docs/using/envs), download all the r and python packages that you might need, and then generate an environment.yml file so that anyone can replicate your environment. Check out this blog for more info: https://www.continuum.io/content/conda-data-science

提交回复
热议问题