|
1 |
| -# Make your Python code pip installable |
| 1 | +# Make your Python code installable |
2 | 2 |
|
3 | 3 | In the previous lesson, you learned about both what a Python package is. You also learned about the [benefits of creating a Python
|
4 | 4 | package](tutorials/intro.html#why-create-a-python-package) including:
|
@@ -50,30 +50,47 @@ environment. You are welcome to use any environment manager that you choose.
|
50 | 50 | you are a scientist, we suggest that you use `conda`, particularly if you are working with any sort of spatial data.
|
51 | 51 | :::
|
52 | 52 |
|
53 |
| -## Make your package installable |
| 53 | + |
| 54 | + |
| 55 | +## Make a basic installable Python package |
54 | 56 |
|
55 | 57 |
|
56 | 58 | :::{figure-md} packages-environment
|
57 | 59 |
|
58 | 60 | <img src="../images/tutorials/environment-package-install.png" alt="This diagram has two smaller boxes with arrows pointing to the right to a python environment. The small boxes read your-package and pip install package. The environment box on the right reads - your python environment. It them lists your-package along with a few other core packages such as matplotlib, numpy, pandas, xarray and geopandas." width="700px">
|
59 | 61 |
|
60 |
| -Making your source code pip-installable is the first step towards creating a Python package. Once your code is pip-installable, it is a Python package and can be added to any Python environment on your computer and imported in the same way that you might import a package such as `Pandas` or `Geopandas`. |
| 62 | +Making your source code pip-installable is the first step towards creating a Python package. Once your code is pip-installable, it is a Python package and can be added to any Python environment on your computer and imported in the same way that you might import a package such as Pandas or GeoPandas. |
61 | 63 | :::
|
62 | 64 |
|
63 |
| -## Make a basic Python package |
64 |
| - |
65 | 65 | It’s time to create the most basic version of a Python package.
|
66 |
| -While this code can't be yet published to PyPI or conda and |
67 |
| -is not documented, it will be installable on your computer or |
68 |
| -anyone elses. |
| 66 | + |
| 67 | +What you'll be able to do with this package at the end of this lesson is: |
| 68 | + |
| 69 | +* Install it into any Python environment on your computer |
| 70 | +* If you share your code with someone else on GitHub or some other file/sharing or cloud based sharing platform, others will be able to install your package too. |
| 71 | + |
| 72 | +While installable code is the first step towards making a Python package, there are some limitations. What you won't be able to do |
| 73 | +by the end of this lesson is publish your package to PyPI and then conda-forge. |
| 74 | + |
| 75 | +The next 3 lessons in this series will teach you how to add the proper |
| 76 | +metadata and documentation that you will need to publish to PyPI. |
| 77 | + |
| 78 | +:::{admonition} Installing packages from GitHub |
| 79 | + |
| 80 | +If you wish to share your code without publishing to PyPI you can |
| 81 | +always install packages directly from GitHub using the syntax: |
| 82 | + |
| 83 | +`pip install git+https://github.com/user/repo.git@branch_or_tag`` |
| 84 | + |
| 85 | +::: |
69 | 86 |
|
70 | 87 | ### What does a basic package directory structure look like?
|
71 | 88 | To make your code installable you need:
|
72 | 89 |
|
73 |
| -- A `pyproject.toml` file |
74 |
| -- An (optional but recommended) `__init__.py` file in your code directory |
75 |
| -- A specific directory structure |
| 90 | +- A `pyproject.toml` file. |
| 91 | +- A specific directory structure. |
76 | 92 | - Some code.
|
| 93 | +- An `__init__.py` file in your code directory. |
77 | 94 |
|
78 | 95 | The directory structure you’ll create in this first section looks like this:
|
79 | 96 |
|
|
0 commit comments