Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 27 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# pylint: disable=missing-docstring, broad-except
import subprocess
import os
import platform
import subprocess
import sys
import sysconfig

import setuptools
Expand All @@ -12,11 +13,11 @@

uplinkc_version = "v1.2.2"

class Install(install):

class Install(install):
@staticmethod
def find_module_path():
new_path = os.path.join(sysconfig.get_paths()['purelib'], "uplink_python")
new_path = os.path.join(sysconfig.get_paths()["purelib"], "uplink_python")
try:
os.makedirs(new_path, exist_ok=True)
os.system("echo Directory uplink_python created successfully.")
Expand All @@ -25,35 +26,29 @@ def find_module_path():
return new_path

def run(self):

try:
install_path = self.find_module_path()
os.system("echo Package installation path: " + install_path)
if platform.system() == "Windows":
os.system("icacls " + install_path + " /grant Everyone:F /t")
else:
os.system("sudo chmod -R 777 " + install_path)
os.system("echo Building libuplinkc.so")
print("Package installation path: " + install_path)
print("Building libuplinkc.so")
copy_command = "copy" if platform.system() == "Windows" else "cp"
command = "git clone -b "+uplinkc_version+ "https://github.com/storj/uplink-c && cd uplink-c" \
"&& go build -o libuplinkc.so -buildmode=c-shared" \
"&& " + copy_command + " *.so " + install_path
build_so = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, shell=True)
command = (
f"git clone -c advice.detachedHead=false -b {uplinkc_version} https://github.com/storj/uplink-c"
f"&& cd uplink-c && go build -o libuplinkc.so -buildmode=c-shared"
f"&& {copy_command} *.so {install_path}"
)
build_so = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
output, errors = build_so.communicate()
build_so.wait()
if output is not None:
os.system("echo " + output.decode('utf-8'))
os.system("echo Building libuplinkc.so successful.")
if errors is not None:
os.system("echo " + errors.decode('utf-8'))
os.system("echo Building libuplinkc.so failed.")
if output:
print(output.decode("utf-8"))
print("Building libuplinkc.so successful.")
if errors:
print(errors.decode("utf-8"))
print("Building libuplinkc.so failed.")
if build_so.returncode != 0:
os.exit(1)
sys.exit(1)
except Exception as error:
os.system("echo " + str(error))
os.system("echo Building libuplinkc.so failed.")
print("Building libuplinkc.so failed: " + str(error))

install.run(self)

Expand All @@ -63,15 +58,13 @@ def run(self):
version="1.2.2.0",
author="Utropicmedia",
author_email="development@utropicmedia.com",
license='Apache Software License',
description="Python-native language binding for uplink to "
"communicate with the Storj network.",
license="Apache Software License",
description="Python-native language binding for uplink to " "communicate with the Storj network.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/storj-thirdparty/uplink-python",

packages=['uplink_python'],
install_requires=['wheel'],
packages=["uplink_python"],
install_requires=["wheel"],
include_package_data=True,
classifiers=[
"Intended Audience :: Developers",
Expand All @@ -80,8 +73,8 @@ def run(self):
"Operating System :: OS Independent",
"Topic :: Software Development :: Build Tools",
],
python_requires='>=3.4',
python_requires=">=3.4",
cmdclass={
'install': Install,
}
"install": Install,
},
)