Setuptools (python)
Introduction
Setuptools is a collection of enhancements to the Python distutils that allow developers to more easily build and distribute Python packages, especially ones that have dependencies on other packages.
https://setuptools.readthedocs.io/en/latest/setuptools.html
Install Python
Note: Tested Python 3.8 in Ubuntu 19.10
$ sudo apt install python3.8-minimal
$ python3.8 -V
Python 3.8.0
Install Setuptools
Note: for Python 3.x
$ sudo apt-get install python3-setuptools
setup.py file
#!/usr/bin/python3.8
from setuptools import setup, find_packages
setup(
name="myapp_calendar",
version="0.0.2",
packages=find_packages(),
scripts=["lambda_function.py"],
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=["docutils>=0.3"],
package_data={
# If any package contains *.txt or *.rst files, include them:
"": ["*.txt", "*.rst"],
# And include any *.msg files found in the "hello" package, too:
"hello": ["*.msg"],
},
# metadata to display on PyPI
author="Author name sample",
author_email="author@name.sample",
description="App AWS Lambda",
keywords="app calendar lambda aws",
url="https://app.cou.ude/app", # project home page, if any
project_urls={
"Bug Tracker": "https://bug.sample.url",
"Documentation": "https://doc.sample.url",
"Source Code": "https://git.cou.ude/app/",
},
classifiers=[
"License :: OSI Approved :: Python Software Foundation License"
]
# could also include long_description, download_url, etc.
)
setup.py How to read artifact version at runtime?
Using the same 'name' as declared in setup.py:
import pkg_resources # part of setuptools
...
tech_comp_version = pkg_resources.require("myapp_calendar")[0].version
logger.info("======== Artifact version: %s", tech_comp_version)
Package
Note: It generates a dist/ subdirectory with the application package
./setup.py sdist