You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/publish-conda-forge.md
+39-54Lines changed: 39 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,14 @@ In the previous lessons, you've learned:
4
4
5
5
1. How to [create the most basic version of a Python package](1-installable-code.md). This entailed making your code installable.
6
6
2.[How to publish your Python package to PyPI](publish-pypi)
7
-
2. How to add a `README` and `LICENSE` file to your package
8
-
3. How to setup your `pyproject.toml` file with all of the metadata that PyPI requires and also metadata that will be helpful for users to find your package.
7
+
3. How to add a `README` and `LICENSE` file to your package
8
+
4. How to setup your `pyproject.toml` file with all of the metadata that PyPI requires and also metadata that will be helpful for users to find your package.
9
9
10
10
If you have gone through all of the above lessons, you are now ready to
11
11
publish your package on conda-forge.
12
12
13
13
**IMPORTANT:** Please do not practice publishing your package to conda-forge. You should only publish to conda-forge when you have a package on pypi.org that you plan to maintain.
14
14
15
-
16
15
:::{admonition} Learning Objectives
17
16
:class: tip
18
17
@@ -28,8 +27,6 @@ for conda, conda-forge will build from your PyPI source distribution file (sdist
28
27
29
28
:::
30
29
31
-
32
-
33
30
:::{figure-md} pypi-conda-publication
34
31
35
32
<imgsrc="../images/publish-python-package-pypi-conda.png"alt="Image showing the progression of creating a Python package, building it and then publishing to PyPI and conda-forge. You take your code and turn it into distribution files (sdist and wheel) that PyPI accepts. then there is an arrow towards the PyPI repository where ou publish both distributions. From PyPI if you create a conda-forge recipe you can then publish to conda-forge. "width="700px">
@@ -38,6 +35,7 @@ Once you have published both package distributions (the source distribution and
38
35
:::
39
36
40
37
## What is conda-forge?
38
+
41
39
conda is an open source package and environment management tool that
42
40
can be used to install tools from the different channels within the Anaconda Cloud repository.
43
41
@@ -67,11 +65,6 @@ Once you have built and published your package to PyPI, you have everything that
67
65
68
66
Conda-forge will build your package from the source distribution which you [published to PyPI in the previous lesson](publish-pypi) using the recipe that you will create below.
69
67
70
-
:::{todo}
71
-
<graphic for this???>
72
-
:::
73
-
74
-
75
68
### Conda-forge publication steps
76
69
77
70
:::{figure-md} publish-pypi-conda-forge
@@ -88,7 +81,6 @@ The steps to publish to conda-forge are:
88
81
89
82
4. Once someone from the conda-forge team reviews your pull request, you may need to make some changes. Eventually the pull request will be approved and merged.
90
83
91
-
92
84
Once your recipe is accepted and merged on conda-forge, users can install your package using:
93
85
94
86
`conda install -c conda-forge your-package`
@@ -108,7 +100,7 @@ You can review that pull request and then merge it once all of the continuous in
108
100
It's time to add your package to the conda-forge channel.
109
101
Remember that your package needs to be on PyPI before the steps below will work. And also remember that the team managing conda-forge are all volunteers.
110
102
111
-
* Be sure that your package is on PyPI.org (not test.pypi.org) before you attempt to publish to conda-forge.
103
+
- Be sure that your package is on PyPI.org (not test.pypi.org) before you attempt to publish to conda-forge.
112
104
113
105
:::{important}
114
106
Only submit your package to conda-forge if you intend to maintain it over time.
@@ -140,13 +132,13 @@ You can also install grayskull using pipx[^pipx]. pipx is a tool that allows you
140
132
141
133
### Step 2: Fork and clone the conda-forge staged-recipes repository
142
134
143
-
* Next, open your shell and `cd` to a location where you want to clone the **conda-forge/staged-recipes** repository.
144
-
* fork and clone the [conda-forge/staged-recipes GitHub repository](https://github.com/conda-forge/staged-recipes).
145
-
* Create a new branch in your fork rather than submitting from the main branch of your fork. We suggest naming the branch your package's name.
135
+
- Next, open your shell and `cd` to a location where you want to clone the **conda-forge/staged-recipes** repository.
136
+
- fork and clone the [conda-forge/staged-recipes GitHub repository](https://github.com/conda-forge/staged-recipes).
137
+
- Create a new branch in your fork rather than submitting from the main branch of your fork. We suggest naming the branch your package's name.
146
138
147
139
`git checkout -b your-package-name `
148
140
149
-
* In bash, `cd` into the `staged-recipes/recipes` folder
141
+
- In bash, `cd` into the `staged-recipes/recipes` folder
150
142
151
143
```bash
152
144
staged-recipes/recipes (☊ pyospackage)
@@ -167,7 +159,7 @@ Next, create a new branch in your `conda-forge/staged-recipes` cloned repository
167
159
168
160
### Step 3: Create your conda-forge recipe
169
161
170
-
* Next, navigate to the recipes directory
162
+
- Next, navigate to the recipes directory
171
163
172
164
If you run `ls` here, you will notice there is an example directory with an example recipe for you to look at.
173
165
@@ -181,7 +173,7 @@ example
181
173
182
174
```
183
175
184
-
* Next, run `grayskull pypi your-package-name` to generate a recipe.
176
+
- Next, run `grayskull pypi your-package-name` to generate a recipe.
* Grayskull will pull metadata about your package from PyPI. It does not use your local installation of the package.
229
-
* An internet connection is needed to run the `grayskull pypi your-package-name` step.
230
-
:::
231
219
220
+
- Grayskull will pull metadata about your package from PyPI. It does not use your local installation of the package.
221
+
- An internet connection is needed to run the `grayskull pypi your-package-name` step.
222
+
:::
232
223
233
224
When you run grayskull, it will grab the latest distribution of your package from PyPI and will use that to create a new recipe.
234
225
@@ -290,8 +281,6 @@ extra:
290
281
291
282
There is currently a small bug in Grayskull where it doesn't populate the home: element of the recipe. if you don't include this, [you will receive an error message](https://github.com/conda-forge/staged-recipes/pull/25173#issuecomment-1917916528) from the friendly conda-forge linter bot.
292
283
293
-
294
-
295
284
```
296
285
Hi! This is the friendly automated conda-forge-linting service.
297
286
@@ -304,8 +293,8 @@ For recipes/pyospackage:
304
293
The home item is expected in the about section.
305
294
```
306
295
307
-
* to fix this, open your meta.yaml file in your favorite text editor.
308
-
* and add a home: element to the about section
296
+
- to fix this, open your meta.yaml file in your favorite text editor.
297
+
- and add a home: element to the about section
309
298
310
299
The about section will look like this after you create your recipe.
311
300
@@ -330,7 +319,7 @@ about:
330
319
331
320
### Step 4: tests for conda-forge
332
321
333
-
Next, have a look at the tests section in your **meta.yaml** file. At a minimum you should import your package and run `pip check`.
322
+
Next, have a look at the tests section in your **meta.yaml** file. At a minimum you should import your package or the main modules associated with your package and run `pip check`.
334
323
335
324
`pip check`will ensure that your package installs properly with all of the proper dependencies.
336
325
@@ -353,8 +342,6 @@ Once you have completed all of the above, you are ready to open up a pull reques
353
342
1. Submit a pull request from your fork/branch of the staged-recipes repository.
354
343
1. Remember that the conda-forge maintainers are volunteers. Be patient for someone to respond and supportive in your communication with them.
355
344
356
-
357
-
358
345
:::::{dropdown} Conda-forge checklist help
359
346
:icon: unlock
360
347
:color: secondary
@@ -383,35 +370,42 @@ Below we break down each element of that list.
383
370
384
371
> -[x] Package does not vendor other packages. (If a package uses the source of another package, they should be separate packages or the licenses of all packages need to be packaged).
385
372
386
-
**Translation:** If the code base in your package is your own and it all shares the same LICENSE then you are in good shape. If you have code taken from other packages then you may need to declare that and include licenses for that code if it is different. If you followed these tutorials then you do not have any vendored code.
387
-
373
+
**Translation:** If the code base in your package is your own and it all shares the same LICENSE then you are in good shape. If you have code taken from other packages then you may need to declare that and include licenses for that code if it is different. If you followed these tutorials then you do not have any vendored code.
388
374
389
375
> -[x] If static libraries are linked in, the license of the static library is packaged.
390
376
>
391
377
> -[x] Package does not ship static libraries. If static libraries are needed, [follow CFEP-18](https://github.com/conda-forge/cfep/blob/main/cfep-18.md).
392
378
379
+
:::{note}
393
380
394
-
395
-
:::{todo}
396
-
From leah - Can someone validate that this description is accurate or suggest alternative language please? i don't fully understand static library links
397
381
:::
398
382
399
-
**Translation:** The pyOpenSci tutorials did not include any static libraries in a linked or shipped format. If your package is pure Python you likely don't need to worry about this. However, some packages with more complex builds may include links to extensions written in other languages such as C++. If your package does have such extensions you will need to include the LICENSE(s) for those extensions.
383
+
**Translation:** A static library refers to a copy of a package built into your package. If your package is a pure Python package, then you can check that your package does not ship static libraries as this does not apply to you.
384
+
385
+
The pyOpenSci tutorials are all pure Python and as such do not use static libraries in a linked or shipped (included in the package distribution) format.
386
+
387
+
If your package has a more complex builds that includes
388
+
links to extensions written in other languages such as
389
+
C++, then be sure that include the proper LICENSE(s) for those extensions in your metadata.
390
+
391
+
:::{note}
392
+
If you want to learn more about static libraries, then [this overview](https://pypackaging-native.github.io/background/compilation_concepts/#shared-vs-static-libraries) might help.
393
+
:::
400
394
401
395
> -[ ] Build number is 0.
402
396
403
-
**Translation:** The build number in your recipe is right below the source location of your package's source distribution. `number: 0` is what you should see in that section of your recipe.
397
+
**Translation:** The build number in your recipe is right below the source location of your package's source distribution. `number: 0` is what you should see in that section of your recipe.
404
398
405
-
```bash
406
-
source:
407
-
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/pyospackage-{{ version }}.tar.gz
> - [x] A tarball (`url`) rather than a repo (e.g. `git_url`) is used in your recipe (see [here](https://conda-forge.org/docs/maintainer/adding_pkgs.html#build-from-tarballs-not-repos) for more details).
417
411
@@ -420,6 +414,7 @@ build:
420
414
```yaml
421
415
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/pyospackage-{{ version }}.tar.gz
422
416
```
417
+
423
418
> - [x] GitHub users listed in the maintainer section have posted a comment confirming they are willing to be listed there.
424
419
425
420
**Translation** Once you have submitted your recipe, be sure that all maintainers listed in your recipe respond acknowledging that they are ok with being listed as a maintainer for the conda-forge version of your package.
@@ -434,17 +429,13 @@ This is also why we don't suggest you publish to conda-forge as a practice run.
434
429
435
430
Once you create your pull request, a suite of CI actions will run that build and test the build of your package. A conda-forge maintainer will work with you to get your recipe in good shape and merged.
436
431
437
-
438
-
439
-
440
432
:::{figure-md} pypi-conda-channels
441
433
442
434
<img src="../images/conda-forge-staged-recipes-ci.png" alt="Image showing the 5 CI tasks that will run against your package in the GitHub interface after you'ce created a pull request. " width="700px">
443
435
444
436
Wait until all of the CI steps in your pull request have run. At that point your pull request is ready for review by a conda-forge maintainer.
445
437
:::
446
438
447
-
448
439
In some cases getting all of the checks to run successfully in CI might take a bit of work. If you are struggling to get your recipe to build properly, you can ping the conda-forge maintainer team for help.
449
440
450
441
Please be patient and wait for them to respond.
@@ -457,10 +448,6 @@ If your package is a pure Python package that can be installed on any type of co
457
448
So if tests for Windows and MAC OS fail, that is to be expected. In this case, don't worry about failing tests, the maintainer team can help you get your package published.
458
449
:::
459
450
460
-
461
-
462
-
463
-
464
451
Once you have submitted your recipe, you can wait for the CI build to pass. If it's not passing, and you aren't sure why, a conda-forge maintainer can likely help you figure things out.
465
452
466
453
Once your recipe is built and merged, the conda team will create a new package repository for you similar to [this one for the GemGIS package](https://github.com/conda-forge/gemgis-feedstock).
@@ -495,6 +482,4 @@ The above are the basic steps that you need to take to create and publish a Pyth
0 commit comments