|
| 1 | +# Upload to anaconda.org |
| 2 | + |
| 3 | +These instructions explain how to build and upload the `rvt_py` package from PyPI to Anaconda.org. |
| 4 | + |
| 5 | +All commands should be executed from an activated Anaconda virtual environment. On Windows, use `Anaconda Prompt`.. |
| 6 | + |
| 7 | +> **Important:** |
| 8 | +> |
| 9 | +> - All build scripts are located in the `upload_to_conda` folder. |
| 10 | +> - Before starting a new build, always remove any folders containing previous builds. |
| 11 | +
|
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | + |
| 16 | +## Recommended Best Practice: |
| 17 | + |
| 18 | +* Always ensure **version consistency** between `noarch` and platform-specific (`win-64`) builds to avoid unexpected behavior. |
| 19 | +* Prefer **platform-specific builds** if your package depends on libraries with native binaries (e.g., GDAL, NumPy). |
| 20 | + |
| 21 | +This ensures compatibility, optimal performance, and predictable package selection by Conda. |
| 22 | + |
| 23 | +Starting from version **2.2.2**, we create two types of packages: |
| 24 | + |
| 25 | +- `win-64`: optimized specifically for Windows |
| 26 | +- `noarch`: platform-independent |
| 27 | + |
| 28 | +While Windows is our primary supported platform, we want the package accessible to users on other platforms. |
| 29 | + |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | + |
| 34 | +## Preparation |
| 35 | + |
| 36 | +### Step 1: Publish the new version to PyPI |
| 37 | + |
| 38 | +First, upload the new version of the package to PyPI (used as the source for the Conda build). |
| 39 | + |
| 40 | +### Step 2: Prepare your build environment |
| 41 | + |
| 42 | +Ensure necessary tools are installed: |
| 43 | + |
| 44 | +```bash |
| 45 | +conda install conda-build anaconda-client conda-verify |
| 46 | +``` |
| 47 | + |
| 48 | +### Step 3: Update `meta.yaml` |
| 49 | + |
| 50 | +Edit `meta.yaml`: |
| 51 | + |
| 52 | +- Update the package version number (**line 2**). |
| 53 | +- Update the SHA256 checksum to match the PyPI release: |
| 54 | + - Go to [PyPI rvt-py files](https://pypi.org/project/rvt-py/#files) |
| 55 | + - Click "View hashes" under the source distribution. |
| 56 | +- *Update dependencies in the `requirements` section if necessary.* |
| 57 | + |
| 58 | +### Step 4: Set working directory |
| 59 | + |
| 60 | +Ensure you’re in the correct directory: |
| 61 | + |
| 62 | +```bash |
| 63 | +cd upload_to_conda |
| 64 | +``` |
| 65 | + |
| 66 | +### Step 5: Login to Anaconda.org |
| 67 | + |
| 68 | +Log in using your credentials: |
| 69 | + |
| 70 | +```bash |
| 71 | +anaconda login --username rvtpy --password {*} |
| 72 | +``` |
| 73 | + |
| 74 | +Replace `{*}` with your Anaconda.org password. |
| 75 | + |
| 76 | +> **For rvt-py developers>** |
| 77 | +> |
| 78 | +> `rvt-py` is the shared user account, developers can also publish using their individual accounts |
| 79 | +
|
| 80 | +### Optional: Disable/enable automatic upload |
| 81 | + |
| 82 | +While automatic upload reduces manual steps, it also reduces control over the build process and increases the risk of |
| 83 | +accidentally publishing broken or incorrect builds. If on, the upload occurs automatically at the end of the build |
| 84 | +process, allowing you to skip the final step. |
| 85 | + |
| 86 | +Check your current configuration: |
| 87 | + |
| 88 | +```bash |
| 89 | +conda config --show anaconda_upload |
| 90 | +``` |
| 91 | + |
| 92 | +To disable (to enable change `no` to `yes`) run: |
| 93 | + |
| 94 | +```bash |
| 95 | +conda config --set anaconda_upload no |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Building and uploading `win-64` package |
| 101 | + |
| 102 | +### Step 1: Modify `meta.yaml` for a platform-specific build |
| 103 | + |
| 104 | +Remove or comment out this line in `meta.yaml`: |
| 105 | + |
| 106 | +```yaml |
| 107 | +# noarch: python |
| 108 | +``` |
| 109 | + |
| 110 | +### Step 2: Build the Windows package |
| 111 | + |
| 112 | +Run the following command: |
| 113 | + |
| 114 | +```bash |
| 115 | +conda build .\rvt-py --output-folder .\conda_packages |
| 116 | +``` |
| 117 | + |
| 118 | +The built package will appear here: |
| 119 | + |
| 120 | +``` |
| 121 | +.\conda_packages\win-64\rvt_py-<version>-pyXX.conda |
| 122 | +``` |
| 123 | + |
| 124 | +Replace `<version>` and `pyXX` with the correct details. |
| 125 | + |
| 126 | +### Step 3: Upload Windows package |
| 127 | + |
| 128 | +Upload the built package to your Anaconda.org channel (`rvtpy`): |
| 129 | + |
| 130 | +```bash |
| 131 | +conda upload .\conda_packages\win-64\rvt_py-<version>-*.conda |
| 132 | +``` |
| 133 | + |
| 134 | +Replace `<version>` appropriately. |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## Building and uploading `noarch` package |
| 139 | + |
| 140 | +### Step 1: Ensure `meta.yaml` specifies `noarch` |
| 141 | + |
| 142 | +Make sure `meta.yaml` includes (this line was removed or commented out when building for `win-64`): |
| 143 | + |
| 144 | +```yaml |
| 145 | +build: |
| 146 | + noarch: python |
| 147 | +``` |
| 148 | +
|
| 149 | +### Step 2: Build the package |
| 150 | +
|
| 151 | +Run the build: |
| 152 | +
|
| 153 | +```bash |
| 154 | +conda build rvt-py --output-folder .\conda_packages |
| 155 | +``` |
| 156 | + |
| 157 | +Built packages (`*.conda`) will appear in the `.\conda_packages` folder. |
| 158 | + |
| 159 | +### Step 3: Upload the package |
| 160 | + |
| 161 | +Upload the built package to Anaconda.org: |
| 162 | + |
| 163 | +```bash |
| 164 | +anaconda upload .\conda_packages\noarch\rvt_py-<version>-*.conda |
| 165 | +``` |
| 166 | + |
| 167 | +Replace `<package_name>` with the actual filename generated by the build. |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +You're done! The package is now available on Anaconda.org. |
0 commit comments