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: package-structure-code/publish-python-package-pypi-conda.md
+58-28Lines changed: 58 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,22 @@ from a public community repository such as PyPI or a conda channel such as
9
9
Below you will learn more about the various publishing options for your Python
10
10
package.
11
11
12
-
```{admonition} Take Aways
12
+
:::{admonition} Take Aways
13
13
14
14
* Installing packages in the same environment using both pip and conda can
15
15
lead to package conflicts.
16
16
* To minimize conflicts for users who may be using conda (or pip) to manage local environments, consider publishing your package to both PyPI and the conda-forge channel of the Anaconda Cloud.
17
17
18
18
Below you will learn more specifics about the differences between PyPI and conda publishing of your Python package.
19
-
```
19
+
:::
20
+
21
+
22
+
:::{figure-md} pypi-conda-channels
23
+
24
+
<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">
25
+
26
+
Once you have published both package distributions (the source distribution and the wheel) to PyPI, you can then publish to conda-forge. conda-forge requires a source distribution on PyPI in order to build your package on conda-forge. You do not need to rebuild your package to publish to conda-forge.
27
+
:::
20
28
21
29
## What is PyPI
22
30
@@ -32,6 +40,14 @@ a package is that conda can install any package regardless
32
40
of the language(s) that it is written in. Whereas `pip` can
33
41
only install Python packages.
34
42
43
+
:::{button-link} ../tutorials/publish-pypi.html
44
+
:color: primary
45
+
:class: sd-rounded-pill float-left
46
+
47
+
Click here for a tutorial on publishing your package to PyPI.
48
+
:::
49
+
50
+
35
51
```{tip}
36
52
On the package build page, we discussed the [two package distribution
37
53
types that you will create when making a Python package](python-package-distribution-files-sdist-wheel): SDist (packaged as a .tar.gz or .zip) and
@@ -40,6 +56,7 @@ be published on PyPI when you use [a standard build tool](python-package-build-t
40
56
your package.
41
57
```
42
58
59
+
(about-conda)=
43
60
## What is Anaconda Cloud and conda?
44
61
45
62
conda is an open source package and environment management tool.
Anaconda cloud (anaconda.org) contains public and private repositories for
50
67
packages. These repositories are known as channels (discussed below).
51
68
52
-
The most common public channels are:
69
+
:::{admonition} A brief history of conda's evolution
70
+
:class: note
53
71
54
-
- defaults
55
-
- conda-forge and
56
-
- bioconda
72
+
The conda ecosystem evolved years ago to provide support for and
73
+
simplify the process of managing software dependencies in scientific
74
+
The conda ecosystem evolved years ago to provide support for, and
75
+
simplify the process of, managing software dependencies in scientific
76
+
Python projects.
57
77
58
-
```{tip}
78
+
Many of the core scientific Python projects depend upon or wrap around tools and extensions that are written in other languages, such as C++. In the early stages of the scientific ecosystem's development, these non-Python extensions and tools were not well supported on PyPI, making publication difficult. In recent years there is more support for complex builds that allow developers to bundle non-Python code into a Python distribution using the [wheel distribution format](python-wheel).
79
+
80
+
Conda provides a mechanism to manage these dependencies and ensure that the required packages are installed correctly.
81
+
:::
82
+
83
+
:::{tip}
59
84
While conda was originally created to support Python packages, it
60
85
is now used across all languages. This cross-language support
61
86
makes it easier for some packages to include and have access to
62
-
tools written in other languages such as c/c++ (gdal), Julia, or R.
63
-
Creating environment that mixes all those packages are usually easier and more
64
-
consistent with fullfledged package managers like conda.
65
-
```
87
+
tools written in other languages, such as C/C++ (gdal), Julia, or R.
88
+
Creating an environment that mixes all of these packages is usually easier and more
89
+
consistent with full-fledged package managers like conda.
90
+
:::
66
91
67
92
### conda channels
68
93
69
94
conda built packages are housed within repositories that are called
70
95
channels. The conda package manager can install packages from different channels.
71
96
72
97
There are several core public channels that most people use to install
73
-
packages using conda including.
98
+
packages using conda, including:
74
99
75
-
-**defaults:** this is a channel managed by the Anaconda, inc. It is the version of the Python packages that you will install if you install the Anaconda Distribution.
76
-
-[**conda-forge:**](https://anaconda.org/conda-forge) this is a communitydriven channel that focuses on scientific packages. This channel is ideal for tools that support geospatial data
77
-
-[**bioconda**](https://anaconda.org/bioconda): this channel focuses on biomedical
100
+
-**defaults:** this is a channel managed by Anaconda. It is the version of the Python packages that you will install if you install the Anaconda Distribution. Anaconda decides what packages live on the default channel.
101
+
-[**conda-forge:**](https://anaconda.org/conda-forge) this is a community-driven channel that focuses on scientific packages. This channel is ideal for tools that support geospatial data. Anyone can publish a package to this channel.
102
+
-[**bioconda**](https://anaconda.org/bioconda): this channel focuses on biomedical tools.
78
103
79
104
**conda-forge** emerged as many of the scientific packages did not
<imgsrc="../images/python-pypi-conda-channels.png"alt="Graphic with the title Python package repositories. Below it says Anything hosted on PyPI can be installed using pip install. Packaging hosted on a conda channel can be installed using conda install. Below that there are two rows. the top row says conda channels. next to it are three boxes one with conda-forge, community maintained; bioconda and then default - managed by the anaconda team. Below that there is a row that says PyPI servers. PyPI - anyone can publish to pypi. and test pypi. a testbed server for you to practice. "width="700px">
85
110
86
-
ADD source: GeoHackWeek
111
+
Conda channels represent various repositories that you can install packages from. Because conda-forge is community maintained, anyone can submit a recipe there. PyPI 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.
87
112
:::
88
113
114
+
89
115
## conda channels, PyPI, conda, pip - Where to publish your package
90
116
91
117
You might be wondering why there are different package repositories
@@ -147,16 +173,16 @@ Once your package is on PyPI, the process to add your package to conda-forge
147
173
is straight forward to do. [You can follow the detailed steps provided
148
174
by the conda-forge maintainer team.](https://conda-forge.org/docs/maintainer/adding_pkgs.html#generating-the-recipe).
149
175
150
-
Generally those steps are:
151
176
152
-
1. Fork the staged recipes conda-forge GitHub repository
153
-
1. Create a new recipe using the `grayskull` tool. You can [learn more about grayskull here](https://conda.github.io/grayskull/).
154
-
1. Add the recipe file created by `grayskull` in a folder within the recipes/ directory of the [**conda-forge/staged-recipes**](https://github.com/conda-forge/staged-recipes) repository.
155
-
1. Open a pull request with your change. Your package will be tested on Windows, Mac and Linux using the repository CI.
Copy file name to clipboardExpand all lines: package-structure-code/python-package-distribution-files-sdist-wheel.md
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,24 @@
1
1
# Learn about Building a Python Package
2
2
3
-
:::{figure-md} build_workflow
4
-
<imgsrc="../images/python-package-development-process.png"alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testpypi or the real pypi. from pypi you can then connect to conda forge for an automated build that sends distributions from pypi to conda-forge. "width="700px">
5
3
6
-
You need to build your Python package in order to publish it to PyPI (or Conda). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users. NOTE: you need to publish a sdist to PyPI in order for conda-forge to properly build your package automatically.
4
+
:::{figure-md} pypi-conda-channels
5
+
6
+
<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">
7
+
8
+
Once you have published both package distributions (the source distribution and the wheel) to PyPI, you can then publish to conda-forge. conda-forge requires an source distribution on PyPI in order to build your package on conda-forge. You do not need to rebuild your package to publish to conda-forge.
9
+
:::
10
+
11
+
You need to build your Python package in order to publish it to PyPI (or a conda channel). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users. NOTE: you need to publish a sdist to PyPI in order for conda-forge to properly build your package automatically.
7
12
:::
8
13
9
14
(build-package)=
10
15
## What is building a Python package?
11
16
12
-
To [publish your Python package](build_workflow) and make it easy for anyone to install, you first need to build it.
17
+
To [publish your Python package](publish-python-package-pypi-conda) and make it easy for anyone to install, you first need to build it.
13
18
14
19
But, what does it mean to build a Python package?
15
20
16
-
[As shown in the figure above](build_workflow), when you build your Python package, you convert the source files into something called a distribution package. A distribution package contains your source code and metadata about the package, in the format required by the Python Package Index, so that it can be installed by tools like pip.
21
+
[As shown in the figure above](#pypi-conda-channels), when you build your Python package, you convert the source files into something called a distribution package. A distribution package contains your source code and metadata about the package, in the format required by the Python Package Index, so that it can be installed by tools like pip.
17
22
18
23
:::{note}
19
24
The term package used to mean many different things in Python and other languages. On this page, we adapt the convention of the [Python Packaging Authority](https://www.pypa.io/en/latest/) and refer to the product of the
@@ -87,7 +92,7 @@ represent on your PyPI landing page. These classifiers also allow users to sort
87
92
```
88
93
89
94
:::{figure-md} build-workflow
90
-
<img src="../images/python-package-development-process.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testpypi or the real pypi. from pypi you can then connect to condaforge for an automated build that sends distributions from pypi to conda-forge. " width="700px">
95
+
<img src="../images/python-package-development-process.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testpypi or the real pypi. from pypi you can then connect to conda-forge for an automated build that sends distributions from pypi to conda-forge. " width="700px">
91
96
92
97
You need to build your Python package in order to publish it to PyPI (or Conda). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users. NOTE: you need to publish a sdist to PyPI in order for conda-forge to properly build your package automatically.
Copy file name to clipboardExpand all lines: tutorials/intro.md
+16-10Lines changed: 16 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,16 @@
1
1
# Python packaging 101
2
2
*A start to finish beginner-friendly tutorial*
3
3
4
+
:::{toctree}
5
+
:hidden:
6
+
:caption: Python Packaging 101
7
+
8
+
What is a Python package? <self>
9
+
Make your code installable <1-installable-code>
10
+
Publish to PyPI <publish-pypi>
11
+
Publish to conda-forge <publish-conda-forge>
12
+
:::
13
+
4
14
Welcome to the pyOpenSci Python packaging tutorial series. The lessons
5
15
on the upcoming pages walk you through the core steps needed to
6
16
create a Python package.
@@ -38,6 +48,7 @@ Get to know Hatch <get-to-know-hatch>
38
48
What is a Python package? <self>
39
49
Make your code installable <1-installable-code>
40
50
Publish to PyPI <publish-pypi>
51
+
Publish to conda-forge <publish-conda-forge>
41
52
:::
42
53
43
54
@@ -306,25 +317,20 @@ If you want to make your package directly installable without having
306
317
to download the code to your computer locally then you need to
307
318
publish it in a repository such as **PyPI** or **conda-forge**.
308
319
320
+
Learn [how to publish your package to PyPI in this tutorial.](publish-pypi.md)
309
321
310
322
You will learn [how to publish your package to PyPI in this tutorial.](publish-pypi)
311
323
312
-
:::{todo}
313
-
This lesson is also not published - yet but will be reviewed soon.
314
-
:::
315
-
316
324
Then you can create a conda-forge recipe using the [Grayskull](https://github.com/conda/grayskull) tool. You can then submit this recipe to conda-forge.
317
325
318
-
:::{todo}
319
-
remove this todo when this page is published
320
-
[You will learn more about the conda-forge publication process here.](7-publish-conda-forge.md)
321
-
:::
326
+
[You will learn more about the conda-forge publication process here.](publish-conda-forge.md)
327
+
322
328
323
329
:::{figure-md} build-workflow-tutorial
324
-
<imgsrc="../images/tutorials/publish-package-pypi-conda.png"alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. Those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testPyPI or the real PyPI. From PyPI you can then connect to condaforge for an automated build that sends distributions from PyPI to conda-forge."width="700px">
330
+
<imgsrc="../images/tutorials/publish-package-pypi-conda.png"alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. Those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testPyPI or the real PyPI. From PyPI you can then connect to conda-forge for an automated build that sends distributions from PyPI to conda-forge."width="700px">
325
331
326
332
In the image above, you can see the steps associated with publishing
327
-
your package on PyPI and condaforge. Note that the distribution files that PyPI requires are the [sdist](#python-source-distribution) and [wheel](#python-wheel) files. Once you are ready to make your code publicly installable, you can publish it on PyPI. Once your code is on PyPI it is straight forward to then publish to condaforge. You create a recipe using the Grayskull package and then you open a pr in the conda-forge recipe repo. You will learn more about this process in the [conda-forge lesson](#).
333
+
your package on PyPI and conda-forge. Note that the distribution files that PyPI requires are the [sdist](#python-source-distribution) and [wheel](#python-wheel) files. Once you are ready to make your code publicly installable, you can publish it on PyPI. Once your code is on PyPI it is straight forward to then publish to conda-forge. You create a recipe using the Grayskull package and then you open a pr in the conda-forge recipe repo. You will learn more about this process in the [conda-forge lesson](#).
0 commit comments