-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
81 lines (65 loc) · 2.05 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
Setup script for building the module into a package for publishing to PyPI.
"""
from setuptools import setup, find_namespace_packages
import sys
import os
def get_version() -> str:
"""
Get the package version from the environment variables.
"""
major = os.environ.get('MAJOR', '1')
minor = os.environ.get('MINOR', '0')
patch = os.environ.get('PATCH', '0')
# Determine if this is a pre-release version
release_flag = os.environ.get('RELEASE', 'true').lower()
prerelease = not bool(release_flag)
if not prerelease:
return f'{major}.{minor}.{patch}'
else:
return f'{major}.{minor}.{patch}.dev'
def get_readme(filename: str = 'README.md') -> str:
"""
Returns the contents of the requested README file
"""
with open(filename, 'r') as file:
return file.read()
def get_requirements(filename: str = 'requirements.txt') -> list:
"""
Returns the contents of the requested requirements.txt
file
"""
with open(filename, 'r') as file:
return [line.strip() for line in file if line.strip() and not line.startswith('#')]
def get_package_url(main_module: str) -> str:
"""
Returns the URL for the package
"""
repository_name = main_module.replace('_', '-')
return f'https://github.com/thetestgame/{repository_name}'
def main() -> int:
"""
Main entry point for the setup script
"""
# Define some constants
module_name = 'panda3d_astron'
# Run the setup
setup(
name=module_name,
description='',
long_description=get_readme(),
long_description_content_type='text/markdown',
license='MIT',
version=get_version(),
author='Jordan Maxwell',
maintainer='Jordan Maxwell',
url=get_package_url(module_name),
packages=find_namespace_packages(),
install_requires=get_requirements(),
classifiers=[
'Programming Language :: Python :: 3',
])
return 0
# Run the main function
if __name__ == '__main__':
sys.exit(main())