|
| 1 | +# Publishing NeqSim to Conda-Forge |
| 2 | + |
| 3 | +This guide explains how to publish NeqSim to conda-forge for easy installation via Anaconda. |
| 4 | + |
| 5 | +## Option 1: Submit to conda-forge (Recommended) |
| 6 | + |
| 7 | +### Step 1: Ensure PyPI Package is Published |
| 8 | + |
| 9 | +The conda-forge recipe pulls from PyPI, so ensure the latest version is published: |
| 10 | + |
| 11 | +```bash |
| 12 | +poetry build |
| 13 | +poetry publish |
| 14 | +``` |
| 15 | + |
| 16 | +### Step 2: Fork and Clone staged-recipes |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/conda-forge/staged-recipes.git |
| 20 | +cd staged-recipes |
| 21 | +git checkout -b neqsim |
| 22 | +``` |
| 23 | + |
| 24 | +### Step 3: Create the Recipe |
| 25 | + |
| 26 | +Copy the recipe from the `conda/` directory: |
| 27 | + |
| 28 | +```bash |
| 29 | +mkdir recipes/neqsim |
| 30 | +cp /path/to/neqsim-python/conda/meta.yaml recipes/neqsim/ |
| 31 | +``` |
| 32 | + |
| 33 | +### Step 4: Get the SHA256 Hash |
| 34 | + |
| 35 | +After publishing to PyPI, get the hash: |
| 36 | + |
| 37 | +```bash |
| 38 | +curl -sL https://pypi.io/packages/source/n/neqsim/neqsim-3.1.5.tar.gz | sha256sum |
| 39 | +``` |
| 40 | + |
| 41 | +Update `meta.yaml` with the hash. |
| 42 | + |
| 43 | +### Step 5: Test Locally (Optional) |
| 44 | + |
| 45 | +```bash |
| 46 | +conda build recipes/neqsim |
| 47 | +``` |
| 48 | + |
| 49 | +### Step 6: Submit Pull Request |
| 50 | + |
| 51 | +Push your branch and create a PR to conda-forge/staged-recipes: |
| 52 | + |
| 53 | +```bash |
| 54 | +git add recipes/neqsim |
| 55 | +git commit -m "Add neqsim recipe" |
| 56 | +git push origin neqsim |
| 57 | +``` |
| 58 | + |
| 59 | +Then open a PR at https://github.com/conda-forge/staged-recipes |
| 60 | + |
| 61 | +### Step 7: Maintenance |
| 62 | + |
| 63 | +Once accepted, a feedstock repository will be created at: |
| 64 | +https://github.com/conda-forge/neqsim-feedstock |
| 65 | + |
| 66 | +For version updates, submit PRs to the feedstock. |
| 67 | + |
| 68 | +## Option 2: Personal Anaconda Channel |
| 69 | + |
| 70 | +For quick testing or private distribution: |
| 71 | + |
| 72 | +### Step 1: Create Anaconda Account |
| 73 | + |
| 74 | +Register at https://anaconda.org |
| 75 | + |
| 76 | +### Step 2: Build the Package |
| 77 | + |
| 78 | +```bash |
| 79 | +cd neqsim-python |
| 80 | +conda build conda/ |
| 81 | +``` |
| 82 | + |
| 83 | +### Step 3: Upload to Anaconda |
| 84 | + |
| 85 | +```bash |
| 86 | +anaconda login |
| 87 | +anaconda upload /path/to/conda-bld/noarch/neqsim-*.tar.bz2 |
| 88 | +``` |
| 89 | + |
| 90 | +### Step 4: Install from Your Channel |
| 91 | + |
| 92 | +```bash |
| 93 | +conda install -c YOUR_USERNAME neqsim |
| 94 | +``` |
| 95 | + |
| 96 | +## Option 3: Using environment.yml (Immediate Solution) |
| 97 | + |
| 98 | +Users can install immediately using the provided environment file: |
| 99 | + |
| 100 | +```bash |
| 101 | +conda env create -f environment.yml |
| 102 | +conda activate neqsim-env |
| 103 | +``` |
| 104 | + |
| 105 | +This installs all dependencies via conda (including Java) and neqsim via pip. |
| 106 | + |
| 107 | +## Key Benefits of Conda Distribution |
| 108 | + |
| 109 | +1. **Automatic Java Installation**: OpenJDK is installed as a conda dependency |
| 110 | +2. **Cross-platform**: Works on Windows, macOS, and Linux |
| 111 | +3. **Environment Management**: Easy to create isolated environments |
| 112 | +4. **Reproducibility**: Pin exact versions for reproducible builds |
| 113 | + |
| 114 | +## Testing the Installation |
| 115 | + |
| 116 | +```python |
| 117 | +import neqsim |
| 118 | +from neqsim.thermo import fluid |
| 119 | + |
| 120 | +# Create a simple fluid |
| 121 | +gas = fluid('srk') |
| 122 | +gas.addComponent('methane', 0.9) |
| 123 | +gas.addComponent('ethane', 0.1) |
| 124 | +gas.setTemperature(25.0, 'C') |
| 125 | +gas.setPressure(50.0, 'bara') |
| 126 | + |
| 127 | +# Run a flash calculation |
| 128 | +from neqsim.thermo import TPflash |
| 129 | +TPflash(gas) |
| 130 | + |
| 131 | +print(f"Density: {gas.getDensity('kg/m3'):.2f} kg/m³") |
| 132 | +``` |
0 commit comments