-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ketozhang-ci-publish-to-pypi'
- Loading branch information
Showing
6 changed files
with
76 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.18" | ||
__version__ = "2.2.0" |