Skip to content

Commit

Permalink
Merge pull request #32 from Herculens/pr-versioning
Browse files Browse the repository at this point in the history
Add proper versioning
  • Loading branch information
aymgal authored Jul 30, 2024
2 parents e214110 + 3125fbf commit d16cc9d
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 54 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish to PyPi

on: workflow_dispatch

jobs:
build-and-publish:
name: Build python package and publish to PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build
run: python setup.py sdist bdist_wheel
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/publish-to-testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish to Test PyPi

on: workflow_dispatch

jobs:
build-and-publish:
name: Build python package and publish to Test PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build
run: python setup.py sdist bdist_wheel
- name: Publish to Test PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<img src="images/horizontal.png" width="600" alt="Herculens logo" />
<img src="https://raw.githubusercontent.com/Herculens/herculens/main/images/horizontal.png#gh-light-mode-only" width="600" alt="Herculens logo" />
<img src="https://raw.githubusercontent.com/Herculens/herculens/main/images/horizontal_dark_bg.png#gh-dark-mode-only" width="600" alt="Herculens logo" />

# Herculens: differentiable gravitational lensing

Expand Down
21 changes: 18 additions & 3 deletions herculens/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
__author__ = 'Austin Peel, Aymeric Galan, Giorgos Vernardos and contributors'
"""
This file initializes the coolest module
and provides some basic information about the package.
"""

# Set the package release version
version_info = (0, 0, 1)
__version__ = '.'.join(str(c) for c in version_info)

# Set the package details
__author__ = 'Aymeric Galan, Austin Peel, Giorgos Vernardos & Herculens contributors'
__email__ = '[email protected]'
__version__ = '0.0.1'
__credits__ = 'EPFL'
__year__ = '2021-2024'
__credits__ = 'Herculens contributors, EPFL (see AUTHORS.md)'
__url__ = 'https://github.com/austinpeel/herculens'
__description__ = 'Auto-differentiable strong lens modelling'
__license__ = 'MIT'
35 changes: 0 additions & 35 deletions herculens/info.py

This file was deleted.

Binary file added images/horizontal_dark_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ numpy>=1.20.3
scipy>=1.6.3
jax>=0.3.14
jaxlib>=0.3.14
optax>=0.1.0
jaxopt>=0.5.5
chex>=0.1.4
objax>=1.7.0
matplotlib>=3.0.0
findiff==0.8.9
scikit-image>=0.20.0
git+https://github.com/aymgal/utax.git@main#egg=utax # JAX utilities (convolution, interpolation, etc.)

# the following packages are optional (pay attention to the versions)
#optax>=0.1.0 # for optimizers
#jaxopt>=0.5.5 # for optimizers
#matplotlib>=3.7.0 # for plotting
#findiff==0.8.9 # for building matrix with finite difference coefficients
#tqdm>=4.61.0 # for progress bars with certain optimizers and samplers
#numpyro==0.10.1 # for SVI and HMC sampling
#blackjax==0.9.6 # for JAX-based HMC sampling
Expand Down
56 changes: 46 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,67 @@
import setuptools
import os

__name__ = 'herculens'
name = 'herculens'

release_info = {}
infopath = os.path.abspath(os.path.join(os.path.dirname(__file__),
__name__, 'info.py'))
name, '__init__.py'))
with open(infopath) as open_file:
exec(open_file.read(), release_info)

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
readme = f.read()

# Use the README as long description but remove the second version
# of the logo (readable only by GitHub's dark mode interface)
long_description = readme.replace('<img src="https://raw.githubusercontent.com/Herculens/herculens/main/images/horizontal_dark_bg.png#gh-dark-mode-only" width="600" alt="Herculens logo" />', '')

# Python version
python_requires = '>=3.8'

# Minimal required packages (see requirements.txt for versions)
install_requires = [
'numpy',
'scipy',
'jax',
'jaxlib',
'objax',
'scikit-image',
# 'https://github.com/aymgal/utax.git', # use requirements.txt
]

# Minimal optional packages (see requirements.txt for versions and complete list)
install_optional = [
'matplotlib', # for plotting
'optax', # for optimizers
'jaxopt', # for optimizers
'findiff', # for building matrix with finite difference coefficients
'numpyro', # for SVI and HMC sampling
'blackjax', # for JAX-based HMC sampling
]

version = release_info['__version__']

setuptools.setup(
name=__name__,
name=name,
author=release_info['__author__'],
author_email=release_info['__email__'],
version=release_info['__version__'],
version=version,
url=release_info['__url__'],
download_url=f"https://github.com/Herculens/herculens/archive/refs/tags/v{version}.tar.gz",
packages=setuptools.find_packages(),
python_requires=release_info['__python__'],
install_requires=release_info['__requires__'],
license=release_info['__license__'],
description=release_info['__about__'],
description=release_info['__description__'],
long_description=long_description,
long_description_content_type='text/markdown',
setup_requires=release_info['__setup_requires__'],
tests_require=release_info['__tests_require__']
keywords=["herculens", "lensing", "gravitation", "astrophysics"],

python_requires=python_requires,
install_requires=install_requires,
extras_require={
"opt": install_optional, # installable via `pip install herculens[opt]`
},
setup_requires=['pytest-runner',],
tests_require=['pytest', 'pytest-cov', 'pytest-pep8'],
)
3 changes: 3 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
tqdm>=4.61.0 # for progress bars with certain optimizers and samplers
numpyro>=0.10.1 # for SVI and HMC sampling
optax>=0.1.0 # for optimizers
jaxopt>=0.5.5 # for optimizers
matplotlib>=3.7.0 # for plotting
git+https://github.com/adam-coogan/jaxinterp2d@9881075#egg=jaxinterp2d # for fast bilinear interpolation (e.g. for pixelated profiles)
git+https://github.com/Herculens/helens.git@main#egg=helens # lens equation solver

0 comments on commit d16cc9d

Please sign in to comment.