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
`conda` and `mamba` are open-source package and environment managers that are language and platform agnostic.
50
+
`mamba` is a newer and faster re-implementation of `conda` -- you can use either `conda` or `mamba`
51
+
in the commands below.
52
+
53
+
After you have followed [the `conda`/`mamba` installation instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) (we recommend Miniforge), you can create and activate the development environment with:
54
+
55
+
```bash
56
+
mamba env update -f environment.yml
57
+
mamba activate earthaccess
58
+
```
59
+
60
+
This will ensure the `earthaccess` environment exists and is up-to-date, and active it. The `earthaccess` package will
61
+
be installed into the environment in editable mode with the optional development dependencies.
62
+
63
+
??? note "2024-09-23: Conda environment name changed from `earthaccess-dev` -> `earthaccess`"
64
+
65
+
On Sept. 23, 2024, the name of the conda environment changed from `earthaccess-dev` to `earthacess` to align with
66
+
community best practices. If you have an `earthaccess-dev` environment, we recommend deleting it and creating a new one.
67
+
From the repository root, you can do that with these commands:
68
+
69
+
```bash
70
+
mamba env update -f environment.yml
71
+
mamba activate earthaccess
72
+
mamba env remove -n earthaccess-dev
73
+
```
74
+
75
+
=== "`pipx`+`nox`"
76
+
77
+
`pipx` is a tool to help you install and run end-user applications written in Python and `nox` is Python application
78
+
that automates testing in multiple Python environments. By using `pipx` to install `nox` and using `nox` to run common development tasks, some users can avoid the need to set up and manage a full development environment.
79
+
Once you have [installed `pipx` following the official instructions](https://github.com/pypa/pipx?tab=readme-ov-file#install-pipx), you can either run `nox` without installing it via:
80
+
81
+
```bash
82
+
pipx run nox [NOX_ARGS]
83
+
```
29
84
85
+
or install `nox` into an isolated environment and run it with:
86
+
87
+
```bash
88
+
pipx install nox
89
+
nox [NOX_ARGS]
90
+
```
91
+
92
+
`nox` handles everything for you, including setting up a temporary virtual environment for each task (e.g. running tests, building docs, etc.) you need to run.
93
+
94
+
Now that your development environment is set up, you can run the tests.
95
+
96
+
## Running tests
97
+
98
+
We recommend using `nox` to run the various "sessions" (`nox`'s term for tasks) provided by `earthaccess`. To use, run `nox` without
99
+
any arguments:
100
+
101
+
```bash
102
+
nox
103
+
```
104
+
105
+
This will run the type check and unit test sessions using your local (and active) Python
106
+
version. `nox` handles everything for you, including setting up a temporary virtual environment for each run.
107
+
108
+
You can see all available sessions with `nox --list`:
30
109
```
31
110
$ nox --list
32
111
Sessions defined in earthaccess/noxfile.py:
@@ -41,8 +120,7 @@ Sessions defined in earthaccess/noxfile.py:
41
120
sessions marked with * are selected, sessions marked with - are skipped.
42
121
```
43
122
44
-
You can also run individual tasks (_sessions_ in `nox` parlance, hence the `-s`
45
-
option below), like so:
123
+
You can also run individual sessions like so:
46
124
47
125
```bash
48
126
nox -s integration-tests
@@ -54,57 +132,74 @@ and pass options to the underlying session like:
54
132
nox -s integration-tests -- [ARGS]
55
133
```
56
134
57
-
!!! tip
58
-
59
-
In order to run integration tests locally, you must set the
60
-
environment variables `EARTHDATA_USERNAME` and `EARTHDATA_PASSWORD` to your
61
-
username and password, respectively, of your
62
-
[NASA Earthdata](https://urs.earthdata.nasa.gov/) account (registration is
63
-
free).
64
-
65
-
135
+
!!! info "Important"
66
136
67
-
## Manual development environment setup
137
+
In order to run integration tests locally, you must set the environment variables `EARTHDATA_USERNAME` and
138
+
`EARTHDATA_PASSWORD` to the username and password of your [NASA Earthdata](https://urs.earthdata.nasa.gov/)
139
+
account, respectively (registration is free).
68
140
69
-
While `nox` is the fastest way to get started, you will likely need a full
70
-
development environment for making code contributions, for example to test in a
71
-
REPL, or to resolve references in your favorite IDE. This development
72
-
environment also includes `nox`. You can create it with `venv`, `conda`, or `mamba`.
141
+
### IDE setup
73
142
74
-
=== "`venv`"
143
+
Integrated development environments (IDEs) like VS Code and PyCharm provide powerful refactoring, testing, and
144
+
debugging integrations, but they typically don't understand "task runners" like `nox` and won't know how to launch
145
+
debugging or testing sessions connected to the provided integrations.
75
146
76
-
`venv` is a virtual environment manager that's built into Python.
147
+
Fortunately, if you've set up a development environment you should be able to call the underlying testing tools
148
+
(e.g., `mypy` and `pytest`) directly, or run them via your IDE integrations. To understand how `nox` is running the
149
+
underlying tools in each test session you can read the `noxfile.py` in the repository root, or, run all the test directly
150
+
in your development environment like:
77
151
78
-
Create and activate the development environment with:
152
+
```bash
153
+
nox -fb none --no-install
154
+
```
79
155
80
-
```bash
81
-
python -m venv .venv
82
-
source .venv/bin/activate
83
-
```
156
+
This will force `nox` to not use an environment backend (will just use the active environment) and not attempt to install
157
+
any packages. When `nox` runs, it will describe the commands it executes:
84
158
85
-
Then install `earthaccess` into the environment in editable mode with the optional development dependencies:
159
+
```
160
+
$ nox -fb none --no-install
161
+
nox > Running session typecheck
162
+
nox > mypy
163
+
Success: no issues found in 35 source files
164
+
nox > Session typecheck was successful.
165
+
nox > Running session tests
166
+
nox > pytest tests/unit -rxXs
167
+
========================================== test session starts ==========================================
168
+
...
169
+
==================================== 43 passed, 1 xfailed in 24.01s =====================================
0 commit comments