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
@@ -57,8 +57,6 @@ Make a graphic to replace that geohackweek graphic that is also more specific.
57
57
Conda channels represent various repositories that you can install packages from. Because conda-forge is community maintained, anyone can submit a recipe there. PiPY is also a community maintained repository. Anyone can submit a package to PyPI and test PyPI. Unlike conda-forge there are no manual checks of packages submitted to PyPI.
58
58
:::
59
59
60
-
61
-
62
60
## Why publish to conda forge
63
61
64
62
There are many users, especially in the scientific Python ecosystem that use conda as their primary package manager / environment tool. Thus, having packages available to these users on the conda-forge channel is useful. In some cases packages on conda-forge can minimize dependency conflicts that can occur when mixing installations using pip and conda. This is particularly important for the spatial ecosystem.
@@ -77,9 +75,9 @@ Conda-forge will build your package from the source distribution which you [publ
<imgsrc="../images/pyopensci-python-package-pypi-to-conda-forge.png"alt="Image showing the steps associated with publishing to conda-forge. Check out the caption below for a detailed description."width="700px">
81
79
82
-
Caption
80
+
The steps for publishing to conda-forge begin with publishing your Python package to PyPI. Once you have published to PyPI you can then create a yaml file recipe that can be submitted to the conda-forge staged recipes repository for review. Once that recipe is accepted, your package will get it's on repository (known as a feedstock) on conda-forge.
83
81
:::
84
82
85
83
The steps to publish to conda-forge are:
@@ -91,56 +89,99 @@ The steps to publish to conda-forge are:
91
89
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.
92
90
93
91
92
+
Once your recipe is accepted and merged on conda-forge, users can install your package using:
94
93
94
+
`conda install -c conda-forge your-package`
95
95
96
-
Now your package is on conda-forge.
97
-
98
-
You only create the recipe once. Then you just maintain the repository.
99
-
96
+
You only create the recipe once. Once the recipe is accepted and merged, you only need to maintain the repository.
100
97
101
98
## Maintaining a conda-forge package
102
99
103
-
Once your package is on conda-forge, the repository will track activity on your PyPI repository for that package. Any time you make a new release to PyPI with a new source distribution, conda-forge will build and update your conda-forge repository.
100
+
Once your package is on conda-forge, the repository will track release activity on the package's PyPI repository. Any time you make a new PyPI release with a new source distribution, conda-forge will build and update your conda-forge repository (also known as a feedstock).
104
101
105
-
When that happens, conda-forge will create a new pull request with an updated distribution recipe.
102
+
When the update is processed, the friendly conda-forge bot will create a new pull request with an updated distribution recipe in your feedstock.
106
103
107
-
You can review that pull request and then merge it once all of the tests pass.
104
+
You can review that pull request and then merge it once all of the continuous integration tests pass.
108
105
109
-
## Publish your package to conda-forge
106
+
## <iclass="fa-regular fa-pen-to-square"></i> How to Publish your package on conda-forge
110
107
111
108
It's time to add your package to the conda-forge channel.
112
109
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.
113
110
114
-
* Please only submit your package to conda-forge if you intend to maintain it over time.
115
-
* Be sure that your package is on PyPI.org (not test.pypi.org) before you attempt to publish to PyPI.
111
+
* Be sure that your package is on PyPI.org (not test.pypi.org) before you attempt to publish to conda-forge.
116
112
117
-
### Step 1 - Install grayskull
113
+
:::{important}
114
+
Only submit your package to conda-forge if you intend to maintain it over time.
115
+
:::
118
116
119
-
To begin this process you need to [install grayskull](https://conda.github.io/grayskull/user_guide.html). You can install it using either pip
117
+
Note - this is a tutorial aimed to help you get your package onto conda-forge. The official conda documentation for this processed [is here](https://conda-forge.org/docs/maintainer/adding_pkgs.html).
120
118
121
-
```
122
-
pip install grayskull
119
+
### Step 1: Install grayskull
120
+
121
+
First, [install grayskull](https://conda.github.io/grayskull/user_guide.html). You can install it using either pip:
122
+
123
+
```bash
124
+
> pip install grayskull
123
125
```
124
126
125
127
or conda
126
128
127
-
```
128
-
conda install -c conda-forge grayskull
129
+
```bash
130
+
>conda install -c conda-forge grayskull
129
131
```
130
132
131
-
Use the shell / terminal that you have been using to run hatch
133
+
To run this command, use the same shell / terminal
134
+
that you have been using to run hatch
132
135
commands in the previous tutorials.
133
136
134
-
### Step 2: Create your recipe from PyPI
137
+
:::{note}
138
+
You can also install grayskull using pipx[^pipx]. pipx is a tool that allows you to install commonly used tools that you might want to have available across multiple Python environments rather than installing the package into every Python environment that ou create.
139
+
:::
140
+
141
+
### Step 2: Fork and clone the conda-forge staged-recipes repository
142
+
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.
146
+
147
+
`git checkout -b your-package-name `
148
+
149
+
* In bash, `cd` into the `staged-recipes/recipes` folder
Next, create a new branch in your `conda-forge/staged-recipes` cloned repository. You might want to make that branch the same name as your package.
135
158
136
-
Next, you can run grayskull on your package.
159
+
```bash
160
+
# Create a new branch called pyospackage
161
+
➜ git checkout -b pyospackage
162
+
➜ cd staged-recipes/recipes
163
+
➜ git branch
164
+
main
165
+
* pyospackage
166
+
```
137
167
138
-
Grayskull will pull information from PyPI
139
-
You don't need to work about what directory you are in when you run grayskull. Grayskull will look for your package on PyPI and will generate your recipe from the PyPI distribution.
168
+
### Step 3: Create your conda-forge recipe
140
169
141
-
Because it is pull from pypi.org, an internet connection is needed for this step.
170
+
* Next, navigate to the recipes directory
142
171
143
-
Run the command below in your favorite shell.
172
+
If you run `ls` here, you will notice there is an example directory with an example recipe for you to look at.
173
+
174
+
```bash
175
+
staged-recipes (☊ pyospackage) via 🐍 pyenv
176
+
➜ cd recipes
177
+
178
+
staged-recipes/recipes (☊ pyospackage)
179
+
➜ ls
180
+
example
181
+
182
+
```
183
+
184
+
* Next, run `grayskull pypi your-package-name` to generate a recipe.
144
185
145
186
```bash
146
187
➜ grayskull pypi pyospackage
@@ -175,18 +216,30 @@ Maintainers:
175
216
- lwasser
176
217
177
218
#### Recipe generated on /your/file/package/here/pyosPackage for pyospackage ####
219
+
220
+
# You should see a new directory created by grayskull after this run is completed.
221
+
staged-recipes/recipes (☊ pyospackage)
222
+
➜ ls
223
+
example pyospackage
178
224
```
179
225
226
+
227
+
:::{tip}
228
+
* 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
+
232
+
180
233
When you run grayskull, it will grab the latest distribution of your package from PyPI and will use that to create a new recipe.
181
234
182
235
The recipe will be saved in a directory named after your package's name, wherever you run the command.
183
236
184
-
`packagename/meta.yaml`
237
+
`recipes/packagename/meta.yaml`
185
238
186
239
At the very bottom of the grayskull output, it will also tell you
187
240
where it saved the recipe file.
188
241
189
-
This will create a meta.yaml file that looks like the example below:
242
+
Open the meta.yaml file. The finished `meta.yaml` file that grayskull creates should look like the example below:
190
243
191
244
```yaml
192
245
{% set name = "pyospackage" %}
@@ -222,7 +275,9 @@ test:
222
275
- pip
223
276
224
277
about:
225
-
license: MIT
278
+
summary: A package that adds numbers together
279
+
dev_url: https://github.com/pyopensci/pyospackage
280
+
license: BSD-3-Clause
226
281
license_file: LICENSE
227
282
228
283
extra:
@@ -231,9 +286,51 @@ extra:
231
286
232
287
```
233
288
234
-
### Step 3: tests for conda-forge
289
+
### Step 3b: Bug fix - add a home url to the about: section
290
+
291
+
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
+
293
+
294
+
295
+
```
296
+
Hi! This is the friendly automated conda-forge-linting service.
297
+
298
+
I wanted to let you know that I linted all conda-recipes in your PR (recipes/pyospackage) and found some lint.
299
+
300
+
Here's what I've got...
301
+
302
+
For recipes/pyospackage:
303
+
304
+
The home item is expected in the about section.
305
+
```
306
+
307
+
* to fix this, open your meta.yaml file in your favorite text editor.
308
+
* and add a home: element to the about section
309
+
310
+
The about section will look like this after you create your recipe.
311
+
312
+
```yaml
313
+
about:
314
+
summary: A package that adds numbers together
315
+
dev_url: https://github.com/pyopensci/pyospackage
316
+
license: BSD-3-Clause
317
+
license_file: LICENSE
318
+
```
319
+
320
+
Below you add a home: element. If you have a project home page / website you can use that url. Otherwise, you can also use your PyPI landing page.
321
+
322
+
```yaml
323
+
about:
324
+
home: https://pypi.org/project/pyospackage/
325
+
summary: A package that adds numbers together
326
+
dev_url: https://github.com/pyopensci/pyospackage
327
+
license: BSD-3-Clause
328
+
license_file: LICENSE
329
+
```
330
+
331
+
### Step 4: tests for conda-forge
235
332
236
-
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`.
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`.
237
334
238
335
`pip check`will ensure that your package installs properly with all of the proper dependencies.
239
336
@@ -247,40 +344,27 @@ test:
247
344
- pip
248
345
```
249
346
250
-
### Step 4: Submit a pull request to the staged-recipes repository
251
-
252
-
Finally, create a pull request in the staged-recipes GitHub repository.
347
+
If you have more advanced tests that you wish to run, you can add them here. However, you can also simple leave the tests section as it is.
253
348
254
-
To create your pull request:
255
-
256
-
1. Fork and clone this repo: https://github.com/conda-forge/staged-recipes
257
-
1. Create a branch in your fork rather than submitting from the main branch of your fork.
258
-
1. Within your fork's branch, create a new directory with the name of your package,
259
-
1. Add the meta.yaml file that you generated using grayskull to that directory.
349
+
### Step 4: Submit a pull request to the staged-recipes repository
260
350
261
-
`staged-recipes/recipes/pyospackage/meta.yaml`
351
+
Once you have completed all of the above, you are ready to open up a pull request in the `conda-forge/staged-recipes repository`.
262
352
263
353
1. Submit a pull request from your fork/branch of the staged-recipes repository.
264
354
1. Remember that the conda-forge maintainers are volunteers. Be patient for someone to respond and supportive in your communication with them.
265
355
266
-
When you do this, 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.
267
356
268
-
You can follow the [instructions here](https://conda-forge.org/docs/maintainer/adding_pkgs.html) to submit your package
@@ -346,6 +430,26 @@ url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/pyospackage-{{ ver
346
430
347
431
This is also why we don't suggest you publish to conda-forge as a practice run.
348
432
::::
433
+
:::::
434
+
435
+
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
+
437
+
438
+
439
+
440
+
:::{figure-md} pypi-conda-channels
441
+
442
+
<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
+
444
+
Wait until you have green checks on all of the CI steps in your pull request. At that point your pull request is ready for review.
445
+
:::
446
+
447
+
In some cases getting things to run properly on CI might take a bit of work. If you are struggling you can ping the conda-forge maintainer team for help.
448
+
449
+
Please be patient and wait for them to respond.
450
+
451
+
452
+
349
453
350
454
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.
351
455
@@ -362,37 +466,10 @@ Every time you create a new release on PyPI, the conda-forge bots will recognize
362
466
363
467
Once the conda-forge build it complete, all of the maintainers of your conda-forge feedstock will get a ping on GitHub that a new pull request has been opened.
364
468
365
-
Review the pull request. If all tests are passing, you can merge it. within the next day the conda-forge release will be available for users to install:
469
+
Review the pull request. If all tests are passing, you can merge it. Shortly after merging your pull request, the conda-forge release will be available for users to install:
366
470
367
471
`conda install -c conda-forge yourpackage`
368
472
369
-
:::{todo}
370
-
pr for our tutorial package is up as a draft. right now i'm the only maintainer.
371
-
372
-
<Create a pr on conda-forge - tag filipe (as it is a test package) and add screenshots here so people understand what maintaining a conda recipe entails >
373
-
374
-
375
-
Questions:
376
-
377
-
Pandas has this for their recipe -
378
-
about:
379
-
home: http://pandas.pydata.org
380
-
license: BSD-3-Clause
381
-
license_file: LICENSE
382
-
summary: >-
383
-
Powerful data structures for data analysis, time series, and statistics
0 commit comments