Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e2d1fff
fix import error
Fadila82 Jul 4, 2022
cbf3877
free errors
Fadila82 Jul 6, 2022
fac90ec
access: deallocate unused c struct
Fadila82 Jul 6, 2022
09d173d
free unused structs
Fadila82 Jul 7, 2022
c0e0c9c
fix codacy issues
Fadila82 Jul 7, 2022
a8da7bb
linting
Fadila82 Jul 8, 2022
7f74da2
remove duplicate code
Fadila82 Aug 8, 2022
80ccdc5
correct according to codacy checks
Fadila82 Aug 8, 2022
a19bcaa
update satellite address
Fadila82 Sep 6, 2022
dbbed15
argstypes replaced by argtypes
Fadila82 Oct 29, 2022
2fd62c8
do not free upload result
Fadila82 Oct 30, 2022
b015729
test
Fadila82 Oct 31, 2022
e3e6934
test
Fadila82 Oct 31, 2022
0711d1e
test
Fadila82 Oct 31, 2022
6547aa2
use unwrap_libuplink_result
Fadila82 Nov 3, 2022
ea0d41b
code clean-up
Fadila82 Nov 3, 2022
02721a7
code clean-up
Fadila82 Nov 3, 2022
493d6d6
code clean-up
Fadila82 Nov 3, 2022
d3c4f48
code clean-up
Fadila82 Nov 3, 2022
139c51a
code cleanup
Fadila82 Nov 4, 2022
2162e46
code cleanup
Fadila82 Nov 4, 2022
83607ab
code cleanup
Fadila82 Nov 4, 2022
12851fc
code cleanup
Fadila82 Nov 4, 2022
d083724
code cleanup
Fadila82 Nov 4, 2022
86e51ab
code cleanup
Fadila82 Nov 4, 2022
4f6c64f
add __del__ to free c memory
Fadila82 Nov 10, 2022
b8f98a2
add __del__ to free c memory
Fadila82 Nov 10, 2022
c30c650
typo
Fadila82 Nov 11, 2022
0a9e4a4
test ci
Fadila82 Nov 13, 2022
72b6198
test cloudbuild
Fadila82 Nov 15, 2022
be5448f
test cloudbuild
Fadila82 Nov 15, 2022
619c31f
test cloudbuild
Fadila82 Nov 15, 2022
ad3e904
test cloudbuild
Fadila82 Nov 15, 2022
868bcb8
try docker in docker for cibuildwheel
Fadila82 Nov 16, 2022
a0afcb3
add cibuildwheel config file
Fadila82 Nov 16, 2022
e00adcf
add install golang python scripts for cibuildwheel
Fadila82 Nov 16, 2022
b04834f
skip musllinux builds for now
Fadila82 Nov 16, 2022
7a18014
add setup.cfg
Fadila82 Nov 19, 2022
0e8fa3b
try sotrj-up
Fadila82 Nov 20, 2022
dddb102
try sotrj-up
Fadila82 Nov 20, 2022
11c8131
try storj-up
Fadila82 Nov 20, 2022
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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ RUN mv go /usr/local
ENV PATH=$PATH:/usr/local/go/bin

RUN pip --no-cache-dir install pylint
RUN apt-get update && \
apt-get -qy full-upgrade && \
apt-get install -qy curl && \
apt-get install -qy curl && \
curl -sSL https://get.docker.com/ | sh
41 changes: 28 additions & 13 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
steps:
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/python3', '.']
# - name: 'gcr.io/${PROJECT_ID}/python3'
# entrypoint: 'python3'
# args: ["-m", "pylint", 'uplink_python/uplink.py']
# - name: gcr.io/cloud-builders/gcloud
# entrypoint: 'bash'
# args: ["-c","gcloud secrets versions access latest --secret=StorjAPIKey >>secret.txt" ]
# - name: 'gcr.io/${PROJECT_ID}/python3'
# entrypoint: 'bash'
# args: ["-c", "git clone -b v1.2.2 https://github.com/storj/uplink-c"]
# - name: 'gcr.io/${PROJECT_ID}/python3'
# entrypoint: 'bash'
# args: ["-c", "cd uplink-c && go build -o libuplinkc.so -buildmode=c-shared && cp *.so ../uplink_python/"]
# - name: 'gcr.io/${PROJECT_ID}/python3'
# entrypoint: 'python3'
# args: ['-m', 'unittest', 'test/test_cases.py', '-v']
- name: 'gcr.io/${PROJECT_ID}/python3'
entrypoint: 'python3'
args: ["-m", "pylint", 'uplink_python/uplink.py']
- name: gcr.io/cloud-builders/gcloud
entrypoint: 'bash'
args: ["-c","gcloud secrets versions access latest --secret=StorjAPIKey >>secret.txt" ]
script: |
set -o errexit
GO111MODULE=on go install storj.io/storj-up
storj-up init
docker compose up -d
docker compose ps
storj-up credentials
- name: 'gcr.io/${PROJECT_ID}/python3'
entrypoint: 'bash'
args: ["-c", "git clone -b v1.2.2 https://github.com/storj/uplink-c"]
- name: 'gcr.io/${PROJECT_ID}/python3'
entrypoint: 'bash'
args: ["-c", "cd uplink-c && go build -o libuplinkc.so -buildmode=c-shared && cp *.so ../uplink_python/"]
- name: 'gcr.io/${PROJECT_ID}/python3'
entrypoint: 'python3'
args: ['-m', 'unittest', 'test/test_cases.py', '-v']
script: |
set -o errexit
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==2.11.2
cibuildwheel --platform linux --output-dir wheelhouse .
ls wheelhouse/
tags: ['cloud-builders-community']
images: ['gcr.io/$PROJECT_ID/python3']
tags: ['cloud-builders-community']
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"Cython",
]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
skip = ["cp-36*", "*musllinux*"]

#test-requires = ["unittest"]
test-command = "python3 -m unittest -s test -v"
before-all = "pip install wget && python3 scripts/install-golang.py"
38 changes: 38 additions & 0 deletions scripts/install-golang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# usage: python3 install-golang.py platform machine
import os
import sys
import platform
import tarfile
import wget

from subprocess import call

cibuildwheel_to_go_platform = {
'x86_64' : 'amd64',
'686' : '386'
}




_platform = sys.platform



print("Installing go for ", _platform, "/", platform.machine())

''' Download golang archive and extract it '''
GOLANG_URL = 'https://storage.googleapis.com/golang/go1.19.2.linux-amd64.tar.gz'
if platform.machine() == "i686":
GOLANG_URL = 'https://storage.googleapis.com/golang/go1.19.2.linux-386.tar.gz'


filename = wget.download(GOLANG_URL, 'go.tar.gz')
print("Golang archive filename = ", filename)
file = tarfile.open(filename)
file.extractall("/usr/bin/")
file.close()
cmd = ['chmod','a+x', '/usr/bin/go/bin/go']
out = call(cmd)
if out != 0:
raise CompileError('Go build failed')
22 changes: 22 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[metadata]
name = uplink-python
version = 1.2.2.0
author = Utropicmedia
author_email = development@utropicmedia.com
license= Apache Software License
description = Bindings for Storj network uplink
long_description= file: README.md,
long_description_content_type = text/markdown
classifiers=
Intended Audience :: Developers
Programming Language :: Python :: 3
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Topic :: Software Development :: Build Tools
url = https://github.com/storj-thirdparty/uplink-python

[options]
packages = uplink_python
install_requires= wheel
include_package_data=True
python_requires = >=3.7
105 changes: 38 additions & 67 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,56 @@
import os
import platform
import sysconfig
import sys

from distutils.errors import CompileError
from subprocess import call

import setuptools
from setuptools.command.install import install
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext

with open("README.md", "r") as fh:
long_description = fh.read()

uplinkc_version = "v1.2.2"

class Install(install):

@staticmethod
def find_module_path():
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.")
except OSError as error:
os.system("echo Error in creating uplink_python directory. Error: " + str(error))
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")
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)
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 build_so.returncode != 0:
os.exit(1)
except Exception as error:
os.system("echo " + str(error))
os.system("echo Building libuplinkc.so failed.")

install.run(self)
class build_go_ext(build_ext):
"""Custom command to build extension from Go source files"""
def build_extension(self, ext):

print("os.name ", os.name)
print("sys.platform ", sys.platform)
print("platform.system() ", platform.system())
print("sysconfig.get_platform() ", sysconfig.get_platform())
print("platform.machine() ", platform.machine())
print("platform.architecture() ", platform.architecture())
print("platform.python ", platform.python_version())
print("BUILDING EXT FOR ", platform.release(), " ---- ",platform.machine())

ext_path = self.get_ext_fullpath(ext.name)
print("ext path = ", ext_path)
cmd = ['rm', '-rf', './uplink-c']
out = call(cmd)
if out != 0:
raise CompileError('Go build failed')
cmd = ['git', 'clone', 'https://github.com/storj/uplink-c']
out = call(cmd)
if out != 0:
raise CompileError('Go build failed')
os.chdir('./uplink-c')
cmd = ['/usr/bin/go/bin/go', 'build', '-buildmode=c-shared', '-o', '../'+ext_path]#, "."]
out = call(cmd)
os.chdir('..')
if out != 0:
raise CompileError('Go build failed')


setuptools.setup(
name="uplink-python",
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.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/storj-thirdparty/uplink-python",

packages=['uplink_python'],
install_requires=['wheel'],
include_package_data=True,
classifiers=[
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Build Tools",
ext_modules=[
Extension('libuplinkc', [])
],
python_requires='>=3.4',
cmdclass={
'install': Install,
'build_ext': build_go_ext,
}
)
2 changes: 1 addition & 1 deletion test/test_data/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
self.api_key = file_handle.read()
file_handle.close()

self.satellite = "12EayRS2V1kEsWESU9QMRseFhdxYxKicsiFmxrsLZHeLUtdps3S@us-central-1.tardigrade.io:7777"
self.satellite = "12EayRS2V1kEsWESU9QMRseFhdxYxKicsiFmxrsLZHeLUtdps3S@us1.storj.io:7777"
self.encryption_phrase = "test"

self.uplink = Uplink()
Expand Down
1 change: 0 additions & 1 deletion test/test_data/object_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import string
import unittest

from uplink_python.errors import StorjException, ERROR_OBJECT_NOT_FOUND
from .helper import TestPy


Expand Down
Loading