Skip to content

Commit

Permalink
ci: enhanced setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
grimen committed Mar 10, 2019
1 parent 551d929 commit 1537930
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 47 deletions.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "*/tests/*"
179 changes: 132 additions & 47 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,117 @@


# =========================================
# IMPORTS
# --------------------------------------

import os
import glob
import setuptools

# DISABLED/BUG: this line fails when `pip install palmtree` but works `pip install .`
# from palmtree import __version__


# =========================================
# FUNCTIONS
# --------------------------------------

def find_data_files(data_file_patterns = [], root_path = None):
root_path = root_path or os.path.abspath(os.path.dirname(__file__))
data_file_dirs = []

for root, dirs, files in os.walk(root_path):
data_file_dirs.append(root)

data_files = []

for data_file_dir in data_file_dirs:
files = []

for data_file_pattern in data_file_patterns:
files += glob.glob(os.path.join(data_file_dir, data_file_pattern))

if not files:
continue

target = os.path.join(root_path, data_file_dir)

data_files.append((target, files))

return data_files

def get_readme():
root_path = os.path.abspath(os.path.dirname(__file__))
readme_file_path = os.path.join(root_path, 'README.md')

with open(readme_file_path) as file:
readme = file.read()

return readme

def get_requirements():
root_path = os.path.abspath(os.path.dirname(__file__))
requirements_file_path = os.path.join(root_path, 'requirements.txt')

with open(requirements_file_path) as file:
requirements = [requirement.strip() for requirement in file.readlines()]
requirements = filter(lambda requirement: len(requirement), requirements)
requirements = list(requirements)

return requirements

# import setuptools

# DISABLED/BUG: this line fails when `pip install rootpath` but works `pip install .`
# from rootpath import __version__

setuptools.setup(
name = 'rootpath',
version = '0.1.0',
description = (
'Python project/package root path detection.'
),
long_description = open('README.md').read(),
long_description_content_type = 'text/markdown',
keywords = [
'python',
'utlity',
'common',
'root',
'rootpath',
'root-path',
'detect',
'autodetect',
'auto-detect',
'project-root',
'project-root-path',
'package-root',
'package-root-path',
],
author = 'Jonas Grimfelt',
author_email = 'grimen@gmail.com',
url = 'https://github.com/grimen/python-rootpath',
download_url = 'https://github.com/grimen/python-rootpath',
project_urls = {
'repository': 'https://github.com/grimen/python-rootpath',
'bugs': 'https://github.com/grimen/python-rootpath/issues',
},
packages = setuptools.find_packages(),
package_dir = {
'rootpath': 'rootpath'
},
package_data = {
'': [
'MIT-LICENSE',
'README.md',
],
'rootpath': [
'*.*',
]
# =========================================
# MAIN
# --------------------------------------

name = 'rootpath'
version = '0.1.0'
description = 'Python project/package root path detection.'
keywords = [
'python',
'utlity',
'common',
'root',
'rootpath',
'root-path',
'detect',
'autodetect',
'auto-detect',
'project-root',
'project-root-path',
'package-root',
'package-root-path',
]

readme = get_readme()
requirements = get_requirements()
packages = setuptools.find_packages()
data_files = find_data_files(['*.*'], os.path.join(name, 'tests', '__fixtures__'))

config = {
'name': name,
'version': version,
'description': (description),
'keywords': keywords,
'author': 'Jonas Grimfelt',
'author_email': 'grimen@gmail.com',
'url': 'https://github.com/grimen/python-{name}'.format(name = name),
'download_url': 'https://github.com/grimen/python-{name}'.format(name = name),
'project_urls': {
'repository': 'https://github.com/grimen/python-{name}'.format(name = name),
'bugs': 'https://github.com/grimen/python-{name}/issues'.format(name = name),
},
license = 'MIT',
classifiers = [
'license': 'MIT',

'long_description': readme,
'long_description_content_type': 'text/markdown',

'classifiers': [
'Topic :: Software Development :: Libraries',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand All @@ -61,5 +123,28 @@
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
zip_safe = True,
)

'packages': packages,
'package_dir': {
name: name,
},
'package_data': {
'': [
'MIT-LICENSE',
'README.md',
],
name: [
'*.*',
],
},
'data_files': data_files,
'include_package_data': True,
'zip_safe': True,

'install_requires': requirements,
'setup_requires': [
'setuptools_git >= 1.2',
],
}

setuptools.setup(**config)

0 comments on commit 1537930

Please sign in to comment.