Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build conda package from local python package

Tags:

I can't find a complete example of how to create a conda package from a python package that I wrote and also how to install the package using conda install, while it is on my computer and not on anaconda cloud. I'm looking for example that not using conda skeleton from pypi, but using a python package on my windows machine, the source code must be on my windows machine and not on pypi or other cloud. any help would be mostly appriciate. thanks very much

like image 665
user1470957 Avatar asked Feb 15 '17 20:02

user1470957


People also ask

Can conda install .WHL file?

Building a conda package from a wheel fileYou may download the . whl file in the source section of the conda recipe's meta. yaml file. You may instead put the URL directly in the pip install command.

Can I use pip to install packages in conda?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.


2 Answers

I think it should be trivial if you use the editable way to install packages with conda. I did:

conda develop .

in the project directory (where my setup.py file is).

If you want an example of a setup.py here is mine:

from setuptools import setup
from setuptools import find_packages

setup(
    name='ml', #project name
    version='0.1.0',
    description='ML',
    #url
    author='Me',
    author_email='[email protected]', #not a real e-mail
    license='MIT',
    packages=find_packages(),
    install_requires=['torch','numpy','scikit-learn','scipy','matplotlib','pyyml']
)

The file above is at the root of the project (I do a github repo named project and inside I make a project project with all the packages I develop there.

I believe pip -e . will do the same. You shouldn't need to sudo anything.

like image 118
Charlie Parker Avatar answered Sep 24 '22 04:09

Charlie Parker


A local source directory can be specified in the metadata file meta.yaml by using:

  source:
     path: ../src

https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#source-from-a-local-path

Additionally, to package your own program you have to define the steps needed to build and install it (for instance, running setup.py install for a python script that uses setuptools: https://setuptools.readthedocs.io/en/latest/index.html) in the files build.sh for linux and bld.bat for windows.

like image 28
Asta86 Avatar answered Sep 20 '22 04:09

Asta86