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:
parent
1a0d48eb0f
commit
900e315d36
|
@ -1,29 +1,7 @@
|
|||
import codecs
|
||||
|
||||
import pkg_resources
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
|
||||
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",
|
||||
}
|
||||
from setup import pypi_config
|
||||
|
||||
|
||||
def createTag():
|
||||
|
|
26
setup.py
26
setup.py
|
@ -11,16 +11,38 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from pypi_packaging import pypi_config
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
import os
|
||||
import codecs
|
||||
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()
|
||||
long_description = (here / "README.md").read_text(encoding="utf-8")
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup(
|
||||
name=pypi_config["package_name"],
|
||||
summary="CloudEvents SDK Python",
|
||||
|
|
Loading…
Reference in New Issue