Skip to content

Commit

Permalink
Merge branch 'ketozhang-ci-publish-to-pypi'
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed Jan 10, 2022
2 parents 4a9f22d + ec20dbd commit e715460
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 42 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Upload Python Package to PyPI

on:
release:
types: [published]

jobs:
publish:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py sdist

- name: Publish package to PyPI
# All files in dist/ are published
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[**Detailed documentation: https://rpoleski.github.io/MulensModel/**](https://rpoleski.github.io/MulensModel/)

[Latest release: 2.1.0](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code.
[Latest release: 2.2.0](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code.

MulensModel can generate a microlensing light curve for a given set of microlensing parameters, fit that light curve to some data, and return a chi2 value. That chi2 can then be input into an arbitrary likelihood function to find the best-fit parameters.

Expand Down Expand Up @@ -51,5 +51,5 @@ If you want to contribute to MulensModel, then please see [this file](CONTRIBUTI
---
[![astropy](http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org/)

file revised Dec 2021
file revised Jan 2022

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
69 changes: 32 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
import os
import sys
import glob
import warnings
from setuptools import setup, Extension
from pathlib import Path

from setuptools import Extension, find_packages, setup

file_required = "requirements.txt"
PROJECT_PATH = Path(__file__).resolve().parent
SOURCE_PATH = PROJECT_PATH / "source"
DATA_PATH = PROJECT_PATH / "data"

source_VBBL = os.path.join('source', 'VBBL')
source_AC = os.path.join('source', 'AdaptiveContouring')
source_MM = os.path.join('source', 'MulensModel')
source_MMmo = os.path.join(source_MM, 'mulensobjects')

# Read all files from data/ in format adequate for data_files option of setup.
files = glob.glob(os.path.join("data", "**", "*"), recursive=True)
files = [f for f in files if os.path.isfile(f)]
dir_files = dict()
for file_ in files:
dir_ = os.path.dirname(file_)
if dir_ in dir_files:
dir_files[dir_] += [file_]
else:
dir_files[dir_] = [file_]
data_files = []
for (key, value) in dir_files.items():
data_files += [(os.path.join('MulensModel', key), value)]
file_required = PROJECT_PATH / "requirements.txt"
with file_required.open() as file_:
install_requires = file_.read().splitlines()

version = "unknown"
with open(os.path.join('source', 'MulensModel', 'version.py')) as in_put:
with Path(SOURCE_PATH / "MulensModel" / "version.py").open() as in_put:
for line_ in in_put.readlines():
if line_.startswith('__version__'):
version = line_.split()[2][1:-1]

source_VBBL = SOURCE_PATH / "VBBL"
source_AC = SOURCE_PATH / "AdaptiveContouring"
source_MM = SOURCE_PATH / "MulensModel"
source_MMmo = source_MM / "mulensobjects"

# Read all files from data/ in format adequate for data_files option of setup.
files = [
f.relative_to(PROJECT_PATH) for f in DATA_PATH.rglob("*") if f.is_file()]
data_files = {str(f): str(f) for f in files}

# C/C++ Extensions
ext_AC = Extension('MulensModel.AdaptiveContouring',
sources=glob.glob(os.path.join(source_AC, "*.c")))
sources=[str(f) for f in source_AC.glob("*.c")],
libraries=["m"])
ext_VBBL = Extension('MulensModel.VBBL',
sources=glob.glob(os.path.join(source_VBBL, "*.cpp")))

with open(file_required) as file_:
required = file_.read().splitlines()
sources=[str(f) for f in source_AC.glob("*.cpp")],
libraries=["m"])

setup(
name='MulensModel',
version=version,
url='[email protected]:rpoleski/MulensModel.git',
url='https://github.com/rpoleski/MulensModel',
project_urls={
'documentation': 'https://github.com/rpoleski/MulensModel'},
ext_modules=[ext_AC, ext_VBBL],
author='Radek Poleski',
author='Radek Poleski & Jennifer Yee',
author_email='[email protected]',
description='package for modeling gravitational microlensing events',
packages=['MulensModel', 'MulensModel.mulensobjects'],
package_dir={
'MulensModel': source_MM,
'MulensModel.mulensobjects': source_MMmo},
packages=find_packages(where="source"),
package_dir={"": "source"},
data_files=data_files,
install_requires=required
python_requires=">=3.6",
install_requires=install_requires,
)
4 changes: 2 additions & 2 deletions source/MulensModel/tests/test_Event.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_event_get_chi2_1():

ev.fix_blend_flux = fix_blend_flux
np.testing.assert_almost_equal(ev.get_chi2(), 459.09826, decimal=4)
assert(ev.blend_fluxes() == [0.])
assert(ev.blend_fluxes == [0.])


def test_event_get_chi2_2():
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_event_get_chi2_2():
np.testing.assert_almost_equal(
float(chi2_no_blend), 2.*459.09826, decimal=4,
err_msg='problem in resulting chi2 for fixed no blending')
assert (ev.blend_fluxes() == [0., 0.])
assert (ev.blend_fluxes == [0., 0.])


def test_event_get_chi2_3():
Expand Down
2 changes: 1 addition & 1 deletion source/MulensModel/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.1.18"
__version__ = "2.2.0"

0 comments on commit e715460

Please sign in to comment.