GithubHelp home page GithubHelp logo

conda / cookiecutter-conda-python Goto Github PK

View Code? Open in Web Editor NEW
101.0 101.0 40.0 150 KB

A cookiecutter template for conda packages using Python

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

cookiecutter-conda-python's Introduction

Conda Logo

Tests (GitHub Actions) Codecov Status CodSpeed Performance Benchmarks latest release version

Conda is a cross-platform, language-agnostic binary package manager. It is the package manager used by Anaconda installations, but it may be used for other systems as well. Conda makes environments first-class citizens, making it easy to create independent environments even for C libraries. Conda is written entirely in Python, and is BSD licensed open source.

Conda is enhanced by organizations, tools, and repositories created and managed by the amazing members of the conda community. Some of them can be found here.

Installation

Conda is a part of the Anaconda Distribution. Use Miniconda to bootstrap a minimal installation that only includes conda and its dependencies.

Updating conda

To update conda to the newest version, use the following command:

$ conda update -n base conda

Tip

It is possible that conda update does not install the newest version if the existing conda version is far behind the current release. In this case, updating needs to be done in stages.

For example, to update from conda 4.12 to conda 23.10.0, conda 22.11.1 needs to be installed first:

$ conda install -n base conda=22.11.1
$ conda update conda

Getting Started

If you install the Anaconda Distribution, you will already have hundreds of packages installed. You can see what packages are installed by running:

$ conda list

to see all the packages that are available, use:

$ conda search

and to install a package, use

$ conda install <package-name>

The real power of conda comes from its ability to manage environments. In conda, an environment can be thought of as a completely separate installation. Conda installs packages into environments efficiently using hard links by default when it is possible, so environments are space efficient, and take seconds to create.

The default environment, which conda itself is installed into, is called base. To create another environment, use the conda create command. For instance, to create an environment with PyTorch, you would run:

$ conda create --name ml-project pytorch

This creates an environment called ml-project with the latest version of PyTorch, and its dependencies.

We can now activate this environment:

$ conda activate ml-project

This puts the bin directory of the ml-project environment in the front of the PATH, and sets it as the default environment for all subsequent conda commands.

To go back to the base environment, use:

$ conda deactivate

Building Your Own Packages

You can easily build your own packages for conda, and upload them to anaconda.org, a free service for hosting packages for conda, as well as other package managers. To build a package, create a recipe. Package building documentation is available here. See AnacondaRecipes for the recipes that make up the Anaconda Distribution and defaults channel. Conda-forge and Bioconda are community-driven conda-based distributions.

To upload to anaconda.org, create an account. Then, install the anaconda-client and login:

$ conda install anaconda-client
$ anaconda login

Then, after you build your recipe:

$ conda build <recipe-dir>

you will be prompted to upload to anaconda.org.

To add your anaconda.org channel, or other's channels, to conda so that conda install will find and install their packages, run:

$ conda config --add channels https://conda.anaconda.org/username

(replacing username with the username of the person whose channel you want to add).

Getting Help

Contributing

open in gitpod for one-click development

Contributions to conda are welcome. See the contributing documentation for instructions on setting up a development environment.

cookiecutter-conda-python's People

Contributors

albertdefusco avatar chenghlee avatar conda-bot avatar jezdez avatar kenodegard avatar mandeep avatar msarahan avatar rdmolony avatar sodre avatar walkerh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookiecutter-conda-python's Issues

Failed CLI test

============================= test session starts ==============================
platform darwin -- Python 3.8.5, pytest-6.1.0, py-1.9.0, pluggy-0.13.1
rootdir: $SRC_DIR
plugins: cov-2.10.1
collected 1 item

tests/test_cli.py F [100%]

=================================== FAILURES ===================================
______________________________ test_cli_template _______________________________

def test_cli_template():
  assert cli.cli() is None

tests/test_cli.py:4:


../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.8/site-packages/pieparty/cli.py:16: in cli
args = p.parse_args(args)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.8/argparse.py:1771: in parse_args
self.error(msg % ' '.join(argv))
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.8/argparse.py:2521: in error
self.exit(2, _('%(prog)s: error: %(message)s\n') % args)


self = ArgumentParser(prog='pytest', usage=None, description='scRNA visualization tool', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='resolve', add_help=True)
status = 2, message = 'pytest: error: unrecognized arguments: tests\n'

def exit(self, status=0, message=None):
    if message:
        self._print_message(message, _sys.stderr)
  _sys.exit(status)

E SystemExit: 2

../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.8/argparse.py:2508: SystemExit
----------------------------- Captured stderr call -----------------------------
usage: pytest [-h] [-V]
pytest: error: unrecognized arguments: tests
=========================== short test summary info ============================
FAILED tests/test_cli.py::test_cli_template - SystemExit: 2
============================== 1 failed in 0.17s ===============================

TypeError: 'NoneType' object is not callable

While building the package using 'conda build' command, i am getting error as below:

Traceback (most recent call last):
File "/home/lovekesh/anaconda3/bin/conda-build", line 11, in
sys.exit(main())
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 469, in main
execute(sys.argv[1:])
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 460, in execute
verify=args.verify, variants=args.variants)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/api.py", line 209, in build
notest=notest, need_source_download=need_source_download, variants=variants)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/build.py", line 2322, in build_tree
bypass_env_check=True)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/render.py", line 785, in render_recipe
m = MetaData(recipe_dir, config=config)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/metadata.py", line 863, in init
self.parse_again(permit_undefined_jinja=True, allow_no_other_outputs=True)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/metadata.py", line 940, in parse_again
bypass_env_check=bypass_env_check),
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/conda_build/metadata.py", line 1528, in _get_contents
rendered = template.render(environment=env)
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/lovekesh/anaconda3/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/home/lovekesh/repository_name/conda.recipe/meta.yaml", line 45, in top-level template code
requires:
TypeError: 'NoneType' object is not callable

Here's a list of my installed packages.

packages in environment at /home/lovekesh/.conda/envs/test-env:

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 0_gnu conda-forge
arrow 0.12.1 py35_2 conda-forge
asn1crypto 0.24.0 py35_3 conda-forge
beautifulsoup4 4.6.3 py35_0 conda-forge
binaryornot 0.4.4 py_1 conda-forge
bzip2 1.0.8 h516909a_2 conda-forge
ca-certificates 2019.11.28 hecc5488_0 conda-forge
certifi 2018.8.24 py35_1001 conda-forge
cffi 1.11.5 py35h5e8e0c9_1 conda-forge
chardet 3.0.4 py35_3 conda-forge
click 7.1.1 pyh8c360ce_0 conda-forge
conda 4.5.11 py35_0 conda-forge
conda-build 3.15.1 py35_0 conda-forge
conda-env 2.6.0 1 conda-forge
cookiecutter 1.5.1 py35_0 conda-forge
cryptography 2.3.1 py35hdffb7b8_0 conda-forge
cryptography-vectors 2.3.1 py35_0 conda-forge
filelock 3.0.10 py_0 conda-forge
future 0.16.0 py35_2 conda-forge
glob2 0.7 py_0 conda-forge
idna 2.9 py_1 conda-forge
jinja2 2.11.1 py_0 conda-forge
jinja2-time 0.2.0 py_2 conda-forge
libffi 3.2.1 he1b5a44_1007 conda-forge
libgcc-ng 9.2.0 h24d8f2e_2 conda-forge
libgomp 9.2.0 h24d8f2e_2 conda-forge
libstdcxx-ng 9.2.0 hdf63c60_2 conda-forge
markupsafe 1.0 py35h470a237_1 conda-forge
ncurses 6.1 hf484d3e_1002 conda-forge
openssl 1.0.2u h516909a_0 conda-forge
patchelf 0.10 he1b5a44_0 conda-forge
pip 20.0.2 py_2 conda-forge
pkginfo 1.5.0.1 py_0 conda-forge
poyo 0.5.0 py_0 conda-forge
psutil 5.4.7 py35h14c3975_1001 conda-forge
pycosat 0.6.3 py35h14c3975_1001 conda-forge
pycparser 2.20 py_0 conda-forge
pyopenssl 18.0.0 py35_0 conda-forge
python 3.5.5 h5001a0f_2 conda-forge
python-dateutil 2.8.1 py_0 conda-forge
pytz 2019.3 py_0 conda-forge
pyyaml 3.13 py35h470a237_1 conda-forge
readline 7.0 hf8c457e_1001 conda-forge
requests 2.13.0 py35_0 conda-forge
ruamel_yaml 0.15.71 py35h470a237_0 conda-forge
setuptools 40.4.3 py35_0 conda-forge
six 1.14.0 py_1 conda-forge
sqlite 3.28.0 h8b20d00_0 conda-forge
tk 8.6.10 hed695b0_0 conda-forge
tqdm 4.44.1 pyh9f0ad1d_0 conda-forge
wheel 0.34.2 py_1 conda-forge
whichcraft 0.6.1 py_0 conda-forge
xz 5.2.4 h516909a_1002 conda-forge
yaml 0.1.7 h14c3975_1001 conda-forge
zlib 1.2.11 h516909a_1006 conda-forge

Thanks

Unable to install cookiecutter-conda-python template

Unable to install cookiecutter-conda-python template :
subprocess.CalledProcessError: Command '['git', 'clone', 'https://github.com/conda/cookiecutter-conda-python.git']' returned non-zero exit status 1.


(keras) ninjawarrior@ninjas-MBP mymodules % cookiecutter https://github.com/conda/cookiecutter-conda-python.git
Traceback (most recent call last):
File "/Users/ninjawarrior/miniconda3/envs/keras/bin/cookiecutter", line 11, in
sys.exit(main())
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/cookiecutter/cli.py", line 120, in main
password=os.environ.get('COOKIECUTTER_REPO_PASSWORD')
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/cookiecutter/main.py", line 63, in cookiecutter
password=password
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/cookiecutter/repository.py", line 103, in determine_repo_dir
no_input=no_input,
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/site-packages/cookiecutter/vcs.py", line 99, in clone
stderr=subprocess.STDOUT,
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/Users/ninjawarrior/miniconda3/envs/keras/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'clone', 'https://github.com/conda/cookiecutter-conda-python.git']' returned non-zero exit status 1.

Example entry point outputs to stderr and returns an error to the OS

The file cli.py implements the one entry point which returns a string.

See: https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation

โ€ฆ their return value is passed to sys.exit(), so you can return an errorlevel or message to print to stderr.

Thus the affect of calling the command from a terminal is to print to stderr rather than stdout and also return an error level of 1.

Since this is the only example with no indication that it is supposed to constitute an error, I propose something more like this:

def cli():
    print("CLI template")
    # Return a value of 1 or higher to signify an error; 0 or None means good.
    return  # See https://docs.python.org/3/library/sys.html#sys.exit

__main__.py is broken

__main__.py imports the module {{cookiecutter.package_name}}.cli and then attempts to call the module rather than the function inside.

The name "cli" is both the name of a module and the name of a function inside that model.

Instead __main__.py should do this:

from temp.cli import cli

cli()

Here is a transcript of the problem and a hotfix:

dev$ cookiecutter cookiecutter-conda-python
full_name [Walker Hale]: 
email [[email protected]]: 
github_username [walkerh]: 
repo_name [repository_name]: temp
package_name [temp]: 
project_short_description [Short description]: 
version [0.1.1-a0]: 
dev$ cd temp
temp$ python -m temp
Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/hale/Documents/HGSC/dev/repo/third-party/temp/temp/__main__.py", line 3, in <module>
    cli()
TypeError: 'module' object is not callable
temp$ 
temp$ # And now a hotfix...
temp$ 
temp$ cat <<EOD > temp/__main__.py
> from temp.cli import cli
> 
> cli()
> EOD
temp$ 
temp$ # Test it.
temp$ python -m temp
CLI template
temp$ 

Issues with CLI and tests

Hello,
When I specify to have a CLI, I'm getting the error do conda build. Do I need to configure something else prior to doing the build?

=================================== FAILURES ===================================
______________________________ test_cli_template _______________________________

    def test_cli_template():
>       assert cli.cli() is None

tests/test_cli.py:4:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.9/site-packages/plpquantum/cli.py:16: in cli
    args = p.parse_args(args)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.9/argparse.py:1821: in parse_args
    self.error(msg % ' '.join(argv))
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.9/argparse.py:2575: in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = ArgumentParser(prog='pytest', usage=None, description='PLP-Quantum Computing Integration', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='resolve', add_help=True)
status = 2, message = 'pytest: error: unrecognized arguments: tests\n'

    def exit(self, status=0, message=None):
        if message:
            self._print_message(message, _sys.stderr)
>       _sys.exit(status)
E       SystemExit: 2

../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.9/argparse.py:2562: SystemExit
----------------------------- Captured stderr call -----------------------------
usage: pytest [-h] [-V]
pytest: error: unrecognized arguments: tests
=========================== short test summary info ============================
FAILED tests/test_cli.py::test_cli_template - SystemExit: 2
============================== 1 failed in 0.22s ===============================
Tests failed for plpquantum-0+unknown-py_0.tar.bz2 - moving package to /home/jhellmers/anaconda3/conda-bld/broken
WARNING:conda_build.build:Tests failed for plpquantum-0+unknown-py_0.tar.bz2 - moving package to /home/jhellmers/anaconda3/conda-bld/broken
WARNING conda_build.build:tests_failed(2895): Tests failed for plpquantum-0+unknown-py_0.tar.bz2 - moving package to /home/jhellmers/anaconda3/conda-bld/broken
TESTS FAILED: plpquantum-0+unknown-py_0.tar.bz2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.