diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c10de134..f6a664a83 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,8 +11,9 @@ This is a brief guide to contributing to CLMM, including information about ident 4. [Reviewing an open pull request](#reviewing_an_open_pull_request) 5. [Steps to merging a pull request](#steps_to_merging_a_pull_request) 6. [Updating Public Documentation on lsstdesc.org](#updating_public_docs) -7. [Additional resources](#additional_resources) -8. [Contact](#contact) +7. [Creating installation via pip and conda](#creating_pip_conda) +8. [Additional resources](#additional_resources) +9. [Contact](#contact) ## Identifying Issues @@ -113,6 +114,48 @@ All these steps should be done on the `publish-docs` branch (just `git checkout 2. If you have figures in notebooks that you would like rendered on the website, you will want to execute all cells of demo notebooks. 3. From the `main` CLMM directory (the one that contains `setup.py`) run `./publish_docs` (note, this is different from `./update_docs` that you did in your development branch) and it does all of the work for you (including automatically pushing changes to Github)! +## Creating installation via pip and conda +After new changes to the main code have been made, you will want to update the existing clmm package at the Pypi repository to create an installation via `pip`. To do so, the following steps must be followed: +1. First, install the `hatch` package with pip with the following command: + ```bash + pip install hatch + ``` +You can check [Publish your Python package with Hatch](https://www.pyopensci.org/python-package-guide/tutorials/publish-pypi.html) for more information. + +2. In the `CLMM` repository, create the virtual environment with the command: + ```bash + cd CLMM + hatch env create + ``` +3. If new packages are required as dependencies, add the packages to the `pyproject.toml` file in the repository in the dependencies section. The installation files will be generated from this file, so if any changes are required, look carefully inside the `pyproject.toml` file for the sections related to the changes. +4. Next, build the needed files for publication with the command: + ```bash + hatch build + ``` +This will create a `clmm-1.14.4.tar.gz` and `clmm-1.14.4-py3-none-any.whl` files in the `dist` folder inside the repository. Note that the name of the files will change for the given version to be publicated. + +5. To publish the package to pip, we will use `twine`, which should be installed with the following: + ```bash + pip install twine + ``` +6. To make sure that the package is working properly, we can first publish `clmm` to `PypiTest` running the command: + ```bash + twine upload --repository testpypi dist/* --verbose + ``` +Once the package is published, one can install it by running: + ```bash + pip install -i https://test.pypi.org/simple/ clmm==1.14.4 --extra-index-url https://pypi.org/simple clmm==1.14.4 + ``` +with the proper version number. This step will require an account at [PypiTest](https://test.pypi.org/) and you will need to generate a token that is required to publish packages. Note that some of the required dependencies may note be published to `PypiTest` and thus we need the extra index url to import the packages from `Pypi`. If the package was properly installed, we are now ready to publish it to `Pypi`. + +7. To publish to `Pypi`, run the command: +```bash +twine upload dist/* +``` +This last step must be done with the token used to publish `CLMM` from the right account at `Pypi`. Once this is done, you will find the latest version of `CLMM` at the `Pypi` repository. To test it, try running +```bash +pip install clmm +``` ## Additional resources Here's a list of additional resources which you may find helpful in navigating git for the first time. diff --git a/INSTALL.md b/INSTALL.md index 1213a338e..aa0906509 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,20 +1,48 @@ - # Installation instructions -* [Main readme](README.md) +We strongly recommend you make a new conda environment for the installation of CLMM so you can avoid conflicts with versions of +libraries used for other programs. +Here we present several ways to do it. ## Table of contents 1. [Basic installation](#basic_install) -2. [Access to the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori) +2. [Manual installation](#manual_install) + * [Setting up the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori) 3. [An alternative installation at NERSC or at CC-IN2P3 for DESC members](#from_desc_conda_env) 4. [Making a local copy of CLMM](#making_a_local_copy_of_clmm) ## Basic procedure -Here we provide a quick guide for a basic instalation, this will install all the packages in your current environment. -To create a specific conda environment for CLMM, we recommend you to check the begining of section -[Access to the proper environment on cori.nersc.gov](#access_to_the_proper_environment_on_cori). +These commands will create a new local environment ready for CLMM installation: + +```bash + conda env create -f environment.yml + conda activate clmm +``` + +You can now install CLMM in a local and stable environment with the usual procedure. + +## Manual procedure + +Here we provide a quick guide for a maual instalation, this will install all the packages in your current environment. + +To create your conda environment, run: + +```bash + module load python # Also loads anaconda + conda create --name clmmenv # Create an anaconda environment for clmm + source activate clmmenv # switch to your newly created environment +``` + + +Install some basic packages you will need: + +```bash + conda install pip # need pip to install everything else necessary for clmm + conda install ipython # need to have the ipython tied to this environment + conda install -c conda-forge firefox # Need a browser to view jupyter notebooks +``` ### Theory backend installation First, choose and install a theory backend for CLMM. @@ -65,18 +93,7 @@ Now, you can install CLMM and its dependencies as python setup.py install # build from source ``` -### Local environment for CLMM - -Alternatively, you can create a new local environment by running - -```bash - conda env create -f environment.yml - conda activate clmm -``` - -You can now install CLMM in a local and stable environment with the usual procedure. - -## Access to the proper environment on cori.nersc.gov +### Setting up the proper environment on cori.nersc.gov If you have access to NERSC, this will likely be the easiest to make sure you have the appropriate environment. After logging into cori.nersc.gov, you will need to execute the following. We recommend executing line-by-line to avoid errors: @@ -154,5 +171,3 @@ If you do have edit privileges to CLMM, it may be easier to simply clone the bas ``` bash git clone git@github.com:LSSTDESC/CLMM.git ``` - - diff --git a/README.md b/README.md index c9a97fd36..cfaea5a7e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # CLMM [![Build and Check](https://github.com/LSSTDESC/CLMM/workflows/Build%20and%20Check/badge.svg)](https://github.com/LSSTDESC/CLMM/actions?query=workflow%3A%22Build+and+Check%22) [![Coverage Status](https://coveralls.io/repos/github/LSSTDESC/CLMM/badge.svg?branch=main)](https://coveralls.io/github/LSSTDESC/CLMM?branch=main) +[![Documentation](https://readthedocs.org/projects/clmm/badge/?version=latest)](http://lsstdesc.org/CLMM/) +[![DOI](https://img.shields.io/badge/DOI-10.3847%2F1538--4365%2Fab1658-B31B1B.svg)](https://doi.org/10.1093/mnras/stab2764) The LSST-DESC Cluster Lensing Mass Modeling (CLMM) code is a DESC tool consisting of a Python library for performing galaxy cluster mass reconstruction from weak lensing observables. CLMM is associated with Key Tasks _DC1 SW+RQ_ and _DC2 SW_ of the LSST-DESC [Science Roadmap](https://lsstdesc.org/sites/default/files/DESC_SRM_V1_4.pdf) pertaining to absolute and relative mass calibration. @@ -17,9 +19,33 @@ link to this repository: https://github.com/LSSTDESC/CLMM. Please follow the gui # Installing CLMM +CLMM can be installed with `pip` or `conda`. +There commands will install most of the dependencies for CLMM, +with the exception of the backend to be used on theoretical predictions, +check [this](#backends) section for details. + +For a `pip` installation, run: + +```bash + pip install clmm +``` + +For a `conda` installation, run: + +```bash + conda install -c conda-forge clmm +``` + +We highly recommend you make a new conda environment for the installation of CLMM, +see [INSTALL documentation](INSTALL.md) for instructions on how to do it. + ## Requirements -CLMM requires Python version 3.8 or later. CLMM has the following dependencies: +CLMM requires Python version 3.8 or later. + +### Dependencies + +CLMM has the following dependencies: - [NumPy](https://www.numpy.org/) (v1.17 or later) - [SciPy](https://scipy.org/) (v1.6 or later) @@ -31,6 +57,8 @@ CLMM requires Python version 3.8 or later. CLMM has the following dependencies: pip install numpy scipy astropy matplotlib ``` +### Back-ends + For the theoretical predictions of the signal, CLMM relies on existing libraries and **at least one of the following must be installed as well**: - [cluster-toolkit](https://cluster-toolkit.readthedocs.io/en/latest/) @@ -40,6 +68,8 @@ For the theoretical predictions of the signal, CLMM relies on existing libraries (See the [INSTALL documentation](INSTALL.md) for more detailed installation instructions.) +### Developers + For developers, you will also need to install: - [pytest](https://docs.pytest.org/en/latest/) (3.x or later for testing) @@ -51,9 +81,9 @@ These are also pip installable: ``` Note, the last item, `sphinx_rtd_theme` is to make the docs. -## Installation +## Manual installation -To install CLMM you currently need to build it from source: +To install CLMM manually, you need to build it from source: ``` git clone https://github.com/LSSTDESC/CLMM.git diff --git a/dist/clmm-1.14.4-py3-none-any.whl b/dist/clmm-1.14.4-py3-none-any.whl new file mode 100644 index 000000000..e68ed02ce Binary files /dev/null and b/dist/clmm-1.14.4-py3-none-any.whl differ diff --git a/dist/clmm-1.14.4.tar.gz b/dist/clmm-1.14.4.tar.gz new file mode 100644 index 000000000..7644a59b4 Binary files /dev/null and b/dist/clmm-1.14.4.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index efc4a2346..1ce71fc40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,50 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.metadata] +allow-direct-references = true + +[project] +name = "clmm" +dynamic = ["version"] +description = "A comprehensive package for galaxy cluster weak lensing" +readme = "README.md" +license = "bsd-3-clause" +requires-python = ">=3.8" +authors = [ + { name = "The LSST DESC CLMM Contributors" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", +] +dependencies = [ + "astropy>=4, !=5.0", + "matplotlib", + "numpy>=1.17", + "scipy>=1.3", + "healpy", + "qp-prob" +] + + + +[project.urls] +Repository = "https://github.com/LSSTDESC/CLMM" + +[tool.hatch.version] +path = "clmm/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/clmm", +] + [tool.black] line-length = 100