Skip to content

Commit

Permalink
update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TsumiNa committed Jan 18, 2018
1 parent 9301914 commit 89af583
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 44 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
matplotlib~=2.1.1
numpy~=1.13.3
numpy~=1.14.0
pandas~=0.22.0
pymatgen
PyMonad
Expand Down
221 changes: 190 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,202 @@

# -*- coding: utf-8 -*-

import ast
# uncomment this for compatibility with py27
# from __future__ import print_function

import os
from datetime import date
from setuptools import setup, find_packages

package_name = 'XenonPy'
# --- import your package ---
import xenonpy as package

def get_version(verFile):
with open(verFile) as f:
src = f.read()
module = ast.parse(src)
for e in module.body:
if isinstance(e, ast.Assign) and \
len(e.targets) == 1 and \
e.targets[0].id == '__version__' and \
isinstance(e.value, ast.Str):
return e.value.s
raise RuntimeError('__version__ not found')
if __name__ == "__main__":
# --- Automatically generate setup parameters ---
# Your package name
PKG_NAME = package.__name__

# Your GitHub user name
try:
GITHUB_USERNAME = package.__github_username__
except:
GITHUB_USERNAME = "Unknown-Github-Username"

def setup_package():
with open('README.md') as f:
readme = f.read()
# Short description will be the description on PyPI
try:
SHORT_DESCRIPTION = package.__short_description__ # GitHub Short Description
except:
print(
"'__short_description__' not found in '%s.__init__.py'!" % PKG_NAME)
SHORT_DESCRIPTION = "No short description!"

with open('LICENSE') as f:
this_license = f.read()
# Long description will be the body of content on PyPI page
try:
LONG_DESCRIPTION = open("README.rst", "rb").read().decode("utf-8")
except:
LONG_DESCRIPTION = "No long description!"

# Version number, VERY IMPORTANT!
VERSION = package.__version__

# Author and Maintainer
try:
AUTHOR = package.__author__
except:
AUTHOR = "Unknown"

try:
AUTHOR_EMAIL = package.__author_email__
except:
AUTHOR_EMAIL = None

try:
MAINTAINER = package.__maintainer__
except:
MAINTAINER = "Unknown"

try:
MAINTAINER_EMAIL = package.__maintainer_email__
except:
MAINTAINER_EMAIL = None

PACKAGES, INCLUDE_PACKAGE_DATA, PACKAGE_DATA, PY_MODULES = (
None, None, None, None,
)

# It's a directory style package
if os.path.exists(__file__[:-8] + PKG_NAME):
# Include all sub packages in package directory
PACKAGES = [PKG_NAME] + ["%s.%s" % (PKG_NAME, i)
for i in find_packages(PKG_NAME)]

# Include everything in package directory
INCLUDE_PACKAGE_DATA = True
PACKAGE_DATA = {
"": ["*.*"],
}

# It's a single script style package
elif os.path.exists(__file__[:-8] + PKG_NAME + ".py"):
PY_MODULES = [PKG_NAME, ]

# The project directory name is the GitHub repository name
repository_name = os.path.basename(os.path.dirname(__file__))

# Project Url
URL = "https://github.com/{0}/{1}".format(GITHUB_USERNAME, repository_name)
# Use todays date as GitHub release tag
github_release_tag = str(date.today())
# Source code download url
DOWNLOAD_URL = "https://github.com/{0}/{1}/tarball/{2}".format(
GITHUB_USERNAME, repository_name, github_release_tag)

try:
LICENSE = package.__license__
except:
print("'__license__' not found in '%s.__init__.py'!" % PKG_NAME)
LICENSE = ""

PLATFORMS = [
"Windows",
"MacOS",
"Unix",
]

CLASSIFIERS = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: Unix",
"Programming Language :: Python",
# "Programming Language :: Python :: 2.7",
# "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
]

# Read requirements.txt, ignore comments
try:
REQUIRES = list()
f = open("requirements.txt", "rb")
for line in f.read().decode("utf-8").split("\n"):
line = line.strip()
if "#" in line:
line = line[:line.find("#")].strip()
if line:
REQUIRES.append(line)
except:
print("'requirements.txt' not found!")
REQUIRES = list()

setup(
name=package_name,
version=get_version(package_name + '/__version__.py'),
description='A library to generate descriptors of elements',
long_description=readme,
author='TsumiNa(Chang Liu)',
author_email='liu.chang.1865@gmail.com',
url='https://github.com/yoshida-lab/XenonPy',
license=this_license,
packages=find_packages(exclude=('tests', 'docs'), install_requires=['numpy']))


if __name__ == '__main__':
setup_package()
name=PKG_NAME,
description=SHORT_DESCRIPTION,
long_description=LONG_DESCRIPTION,
version=VERSION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
packages=PACKAGES,
include_package_data=INCLUDE_PACKAGE_DATA,
package_data=PACKAGE_DATA,
py_modules=PY_MODULES,
url=URL,
download_url=DOWNLOAD_URL,
classifiers=CLASSIFIERS,
platforms=PLATFORMS,
license=LICENSE,
install_requires=REQUIRES,
)

"""
Appendix
--------
::
Frequent used classifiers List = [
"Development Status :: 1 - Planning",
"Development Status :: 2 - Pre-Alpha",
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Development Status :: 6 - Mature",
"Development Status :: 7 - Inactive",
"Intended Audience :: Customer Service",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Financial and Insurance Industry",
"Intended Audience :: Healthcare Industry",
"Intended Audience :: Information Technology",
"Intended Audience :: Legal Industry",
"Intended Audience :: Manufacturing",
"Intended Audience :: Other Audience",
"Intended Audience :: Religion",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Intended Audience :: Telecommunications Industry",
"License :: OSI Approved :: BSD License",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: GNU General Public License (GPL)",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Natural Language :: English",
"Natural Language :: Chinese (Simplified)",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 2 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3 :: Only",
]
"""
12 changes: 10 additions & 2 deletions xenonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
except (ImportError, AttributeError):
from pathlib2 import Path

from .__version__ import __version__ as version
from .decorator import *
from .descriptor import *
from .model import *
Expand All @@ -19,6 +18,15 @@
PACKAGE_CONF_DIR = '.XenonPy'
PACKAGE = 'XenonPy'

__version__ = '0.1.0'
__short_description__ = "material descriptor library"
__license__ = "BSD3"
__author__ = "TsumiNa"
__author_email__ = "liu.chang.1865@gmail.com"
__maintainer__ = "TsumiNa"
__maintainer_email__ = "liu.chang.1865@gmail.com"
__github_username__ = "TsumiNa"


def get_version():
"""
Expand All @@ -29,7 +37,7 @@ def get_version():
str
package version.
"""
return version
return __version__


def get_conf(key: str = None):
Expand Down
5 changes: 0 additions & 5 deletions xenonpy/__version__.py

This file was deleted.

2 changes: 1 addition & 1 deletion xenonpy/descriptor/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self,
*methods: str,
elements=None,
comps_col: str = 'composition',
verbose: bool = True,
verbose: bool = True
):
"""
:param str methods: calculation method(s) which to be used must in the :attr:`methods` list.
Expand Down
2 changes: 1 addition & 1 deletion xenonpy/descriptor/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self,
cell_range: int = 1,
sigma: float = 0.1,
structure_col: str = 'structure',
verbose: bool = True,
verbose: bool = True
):
"""
Expand Down
4 changes: 2 additions & 2 deletions xenonpy/model/nn/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, n_features: int, n_predict: int, *,
layer_func: [] = (nn.Linear,),
act_func: [] = (nn.ReLU(),),
batch_normalize: [bool] = (False,),
momentum: [float] = (0.1,),
momentum: [float] = (0.1,)
):
self.n_in, self.n_out = n_features, n_predict

Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, model: nn.Module, *,
ctx: str = 'cpu',
checkstep: int = 100,
check: tuple = ('epochs', 'loss'),
save_to: str = '',
save_to: str = ''
):
parent = Path(save_to)
if not parent.exists():
Expand Down
3 changes: 2 additions & 1 deletion xenonpy/model/nn/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def __init__(self, *,
layer_func=nn.Linear,
act_func=nn.ReLU(),
batch_normalize=False,
momentum=0.1, ):
momentum=0.1
):
super().__init__()
self.neuron = layer_func(n_in, n_out)
self.batch_nor = None if not batch_normalize else nn.BatchNorm1d(n_out, momentum)
Expand Down

0 comments on commit 89af583

Please sign in to comment.