Skip to content

Commit

Permalink
Merge pull request skycoin#69 from skycoin/stdevOzkar_t067_pyskycoin_…
Browse files Browse the repository at this point in the history
…version

fixes skycoin#67 - defined module version on __init__.py of skycoin, according to PEP 396
  • Loading branch information
olemis authored Dec 25, 2018
2 parents d105be1 + 9c6e034 commit 7198285
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 64 deletions.
125 changes: 63 additions & 62 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
from distutils.errors import DistutilsSetupError
from distutils import log as distutils_logger

# To use a consistent encoding
from codecs import open
from os import path
import os, subprocess
import os
import subprocess
import platform
import sys
from skycoin import __version__

script_dirname = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(script_dirname, 'README.md'), encoding='utf-8') as f:
with open(path.join(script_dirname, "README.md"), encoding="utf-8") as f:
long_description = f.read()

class skycoin_build_ext(build_ext, object):

class skycoin_build_ext(build_ext, object):
def build_extension(self, ext):

if ext.name != "_skycoin":
Expand All @@ -33,95 +35,94 @@ def build_extension(self, ext):
sources = ext.sources
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError(
"in 'ext_modules' option (extension '%s'), "
"'sources' must be present and must be "
"a list of source filenames" % ext.name)
"in 'ext_modules' option (extension '%s'), "
"'sources' must be present and must be "
"a list of source filenames" % ext.name
)
sources = list(sources)

if len(sources)>1:
if len(sources) > 1:
sources_path = os.path.commonprefix(sources)
else:
sources_path = os.path.dirname(sources[0])
sources_path = os.path.realpath(sources_path)
if not sources_path.endswith(os.path.sep):
sources_path+= os.path.sep
sources_path += os.path.sep

if not os.path.exists(sources_path) or not os.path.isdir(sources_path):
raise DistutilsSetupError(
"in 'extensions' option (extension '%s'), "
"the supplied 'sources' base dir "
"must exist" % ext.name)

make_path = os.path.realpath(os.path.join(sources_path,'..'))

make_process = subprocess.Popen('make build-libc-swig',
cwd=make_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
"in 'extensions' option (extension '%s'), "
"the supplied 'sources' base dir "
"must exist" % ext.name
)

make_path = os.path.realpath(os.path.join(sources_path, ".."))

make_process = subprocess.Popen(
"make build-libc-swig",
cwd=make_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
)
stdout, stderr = make_process.communicate()
print("stdout:")
sys.stderr.write(str(stdout))
if len(stderr) > 0:
print("stderr:")
sys.stderr.write(str(stderr))
# After making the library build the c library's
# python interface with the parent build_extension method
super(skycoin_build_ext, self).build_extension(ext)



skypath = path.join(*("gopath/src/github.com/skycoin/skycoin".split('/')))
lib_path = path.join(skypath, 'build', 'libskycoin')
library_file = path.join(lib_path, 'libskycoin.a')
skypath = path.join(*("gopath/src/github.com/skycoin/skycoin".split("/")))
lib_path = path.join(skypath, "build", "libskycoin")
library_file = path.join(lib_path, "libskycoin.a")
extra_link_args = []
if platform.system() == "Darwin":
extra_link_args += ["-framework", "Foundation", "-framework", "Security"]
extra_link_args.append(library_file)

setup(
name='Pyskycoin', # Required
version='0.25.0', # Required
description='Skycoin Python Library',
name='pyskycoin', # Required
version=__version__, # Required
description="Skycoin Python Library",
long_description=long_description,
url='https://github.com/simelo/pyskycoin',
author='stdevEclipse', # Optional
author_email='dev0003@simelo.tech',
url="https://github.com/simelo/pyskycoin",
author="Ratmil Torres", # Optional
author_email="skycoin@simelo.tech",
setup_requires=["pytest-runner"],
tests_require=["pytest"],
classifiers=[
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
],
keywords='skycoin crypto coin currency blockchain', # Optional
py_modules=['skycoin'],
packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required
keywords="skycoin crypto coin currency blockchain", # Optional
py_modules=["skycoin"],
packages=find_packages(exclude=["contrib", "docs", "tests"]), # Required
install_requires=[],
extras_require={ # Optional
'dev': ['check-manifest'],
'test': ['coverage'],
},
package_data={
},
entry_points={
'console_scripts': [
],
},
cmdclass = {'build_ext': skycoin_build_ext},
ext_modules = [Extension("_skycoin", ["swig/pyskycoin_wrap.c"],
include_dirs=[
"swig/include",
path.join(skypath, "include")
],
extra_link_args=extra_link_args,
depends=[],
)],

extras_require={"dev": ["check-manifest"], "test": ["coverage"]}, # Optional
package_data={},
entry_points={"console_scripts": []},
cmdclass={"build_ext": skycoin_build_ext},
ext_modules=[
Extension(
"_skycoin",
["swig/pyskycoin_wrap.c"],
include_dirs=["swig/include", path.join(skypath, "include")],
extra_link_args=extra_link_args,
depends=[],
)
],
)
20 changes: 18 additions & 2 deletions skycoin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
from .skycoin import *
from .skyerror import *

__version__ = "0.25.0"
init_error = None

def _print2stderr(msg):
sys.stderr.write(msg + '\n')

try:
from .skycoin import *
from .skyerror import *
except (AttributeError, ImportError) as _err :
init_error = _err

import sys, traceback
_print2stderr("Error initializing skycoin package. Details:")
traceback.print_exception(*sys.exc_info())
_print2stderr("\n\nInport succeeded but package load failed")

0 comments on commit 7198285

Please sign in to comment.