# For pip
https://realpython.com/pypi-publish-python-package/#preparing-your-package-for-publication 

1. Git clone ultraplex
2. cd to the directory with setup.py
3. run: python setup.py sdist bdist_wheel (activate conda env "twine")
(you may need to delete the ultraplex-1.0.4-cp39-cp39-linux_x86_64.whl from the dist/ folder)
4. run: twine upload dist/*  (or "twine upload --repository testpypi dist/*" for tests)

Done.


# For bioconda

Here we use the pip package as a skeleton

Download and fork bioconda:

1. git clone https://github.com/<USERNAME>/bioconda-recipes.git
2. cd bioconda-recipes
3. git remote add upstream https://github.com/bioconda/bioconda-recipes.git
4. git checkout master
5. git pull upstream master
6. git checkout -b ultraplex

Make the meta.yaml from the pip package

1. cd recipes
2. conda skeleton pypi ultraplex (maybe need "rm -r ultraplex/" first?)
3. Add noarch: python to the build section of the meta.yaml file that's generated (not correct any more due to cython)
4. git add ultraplex
5. git commit
6. git push (or maybe: git push --set-upstream origin ultraplex)

Then finally:

1. Create a pull request and make sure it passes the tests.
2. https://gitter.im/bioconda/lobby <- go here and ask for it to be merged
3. Once it's merged and definitely on Bioconda, delete the branch


Upgrading:

For pip, just follow the instructions above. Make sure to rename the version in the setup.py.

Bioconda will automatically create a "bump" once it detects that there's a new version on pip.
However, it will fail because the meta.yaml file created will be wrong. 

You'll want to:
1. Go to the meta file
2. change the meta file to something like the below, but ensure the correct version and sha key is listed (see below)
3. request that this patch is added
4. add comment "@bioconda bot request add label" or something (see instructions)


working meta.yaml:

{% set name = "ultraplex" %}
{% set version = "1.1.2" %}

package:
  name: "{{ name|lower }}"
  version: "{{ version }}"

source:
  url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
  sha256: a24e43d7698fe78a98c0ca4368ba66a5e377c7415b0b0b4e1b4789424d32954d


build:
  number: 0
  script: "{{ PYTHON }} -m pip install . --no-deps -vv"
  skip: True  # [py27]

requirements:
  build:
    - {{ compiler('c') }}
  host:
    - pip
    - python
    - cython
    - setuptools_scm
  run:
    - python
    - xopen >=1.0.0
    - dnaio >=0.5.0
    - dataclasses >=0.7  # [py36]
    - pigz

test:
  imports:
    - ultraplex
  commands:
    - ultraplex --help

about:
  home: "https://github.com/ulelab/ultraplex.git"
  license: MIT
  license_family: MIT
  summary: "fastq demultiplexer"

extra:
  recipe-maintainers:
    - Delayed-Gitification
