Improve redistribute-ability (#151)

* Move functions needed to build project into setup.py

Signed-off-by: Dustin Ingram <di@users.noreply.github.com>

* Only execute setup() in __main__

Signed-off-by: Dustin Ingram <di@users.noreply.github.com>

Co-authored-by: Yurii Serhiichuk <xSAVIKx@users.noreply.github.com>
This commit is contained in:
Dustin Ingram 2022-07-09 05:25:50 -04:00 committed by GitHub
parent 1a0d48eb0f
commit 900e315d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 50 deletions

View File

@ -1,29 +1,7 @@
import codecs
import pkg_resources
import os import os
import pkg_resources
from setup import pypi_config
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()
def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")
# FORMAT: 1.x.x
pypi_config = {
"version_target": get_version("cloudevents/__init__.py"),
"package_name": "cloudevents",
}
def createTag(): def createTag():

View File

@ -11,37 +11,59 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from pypi_packaging import pypi_config
from setuptools import setup, find_packages from setuptools import setup, find_packages
import os
import codecs
import pathlib import pathlib
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()
def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")
# FORMAT: 1.x.x
pypi_config = {
"version_target": get_version("cloudevents/__init__.py"),
"package_name": "cloudevents",
}
here = pathlib.Path(__file__).parent.resolve() here = pathlib.Path(__file__).parent.resolve()
long_description = (here / "README.md").read_text(encoding="utf-8") long_description = (here / "README.md").read_text(encoding="utf-8")
setup( if __name__ == "__main__":
name=pypi_config["package_name"], setup(
summary="CloudEvents SDK Python", name=pypi_config["package_name"],
long_description_content_type="text/markdown", summary="CloudEvents SDK Python",
long_description=long_description, long_description_content_type="text/markdown",
author="The Cloud Events Contributors", long_description=long_description,
author_email="cncfcloudevents@gmail.com", author="The Cloud Events Contributors",
home_page="https://cloudevents.io", author_email="cncfcloudevents@gmail.com",
classifiers=[ home_page="https://cloudevents.io",
"Intended Audience :: Information Technology", classifiers=[
"Intended Audience :: System Administrators", "Intended Audience :: Information Technology",
"License :: OSI Approved :: Apache Software License", "Intended Audience :: System Administrators",
"Operating System :: POSIX :: Linux", "License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3", "Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.9",
], "Programming Language :: Python :: 3.10",
packages=find_packages(exclude=["cloudevents.tests"]), ],
version=pypi_config["version_target"], packages=find_packages(exclude=["cloudevents.tests"]),
install_requires=["deprecation>=2.0,<3.0"], version=pypi_config["version_target"],
) install_requires=["deprecation>=2.0,<3.0"],
)