-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this monorepo is organized as a PEP 420 compliant namespace (https://www.python.org/dev/peps/pep-0420/). The sdk package has been restructured to conform to the PEP 420 namespace package specification and it's under the "snet" namespace. The cli package is both a regular package and a namespace package. setup.py for the monorepo itself installs the dependencies for all packages in the repository. Each package and the overarching monorepo also have "requirements.txt" files for local installations and CI enviroments: by installing via "requirements.txt", the dependencies listed in "setup.py" are only pulled and installed from PyPI if a local version is not already available. This allows to get dependencies within the monorepo to be installed from the local filesystem. The whole package is called "snet" and gives the name to the namespace. The subpackages are "snet.sdk", "snet.snet_cli" and snet_cli (since the CLI package is both within the namespace and a regular package). Going forward, all of the code in the "snet_cli" package can be migrated to the namespace package: both were kept momentarily for compatibility. In this scenario, everything inside the "snet.sdk" package has visibility on the contents of the "snet.snet_cli" package and vice-versa. Everything inside the "snet_cli" regular package has visibility on the contents of the "snet.snet_cli" package due to the regular Python import mechanics, but it has no visibility on the contents of the "snet.sdk" package (and vice-versa). So, the shared code between the SDK and the CLI goes under the "snet.snet_cli" package which is at "packages/snet_cli/snet/snet_cli". Code and assets deduplication: thanks to the new structure, everything under "resources" has been moved to the "snet.snet_cli" package and is now shared between the SDK and CLI. Specifically, this includes the json artifacts from the compilation and deployment of the smart contracts, the raw ".proto" files to interact with the daemon and the compiled python client libraries. Changes: since the CLI is both a namespace package and a regular package, changes to the code have been kept to a minimum. The only change of note is that state service does not compile its own ".proto" files at runtime inside the user's home directory anymore but they are imported from the "resources" directory under the "snet.snet_cli" namespace package, where they are compiled during setup.
- Loading branch information
1 parent
052d9b3
commit 63e2a0a
Showing
129 changed files
with
298 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
venv/ | ||
.idea/ | ||
__pycache__ | ||
blockchain/node_modules | ||
snet.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
venv/ | ||
snet.sdk.egg-info/ | ||
build/ | ||
dist/ |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--index-url https://pypi.python.org/simple | ||
../snet_cli/ | ||
-e . |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pkg_resources | ||
from setuptools import setup, find_namespace_packages | ||
|
||
|
||
PACKAGE_NAME = 'snet.sdk' | ||
|
||
|
||
def is_package_installed(package_name): | ||
installed_modules = [p.project_name for p in pkg_resources.working_set] | ||
return package_name in installed_modules | ||
|
||
|
||
dependencies = [] | ||
|
||
|
||
if is_package_installed('snet-cli'): | ||
# The default setup.py in the snet_cli package for local development installs the whole snet_cli package, | ||
# not the standalone snet.snet_cli namespace package; if a strict dependency on snet.snet_cli was enforced, | ||
# this setup.py would fetch it from PyPI. So, if snet_cli is installed and in your Python path, the | ||
# dependency on snet.snet_cli will be skipped. | ||
# If snet_cli is not available, snet.snet_cli will be fetched from PyPI. | ||
print("Package 'snet_cli' is installed and in your PYTHONPATH: skipping snet.snet_cli dependency") | ||
else: | ||
dependencies.append('snet.snet_cli') | ||
|
||
|
||
version_dict = {} | ||
with open("./snet/sdk/version.py") as fp: | ||
exec(fp.read(), version_dict) | ||
|
||
setup( | ||
name=PACKAGE_NAME, | ||
version=version_dict['__version__'], | ||
packages=find_namespace_packages(include=['snet.*']), | ||
namespace_packages=['snet'], | ||
url='https://github.com/singnet/snet-cli/tree/master/snet_sdk', | ||
license='MIT', | ||
author='SingularityNET Foundation', | ||
author_email='[email protected]', | ||
description='SingularityNET Python SDK', | ||
python_requires='>=3.6', | ||
install_requires=dependencies | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
snet_sdk/snet_sdk/account.py → packages/sdk/snet/sdk/account.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 4 additions & 2 deletions
6
snet_sdk/snet_sdk/mpe_contract.py → packages/sdk/snet/sdk/mpe_contract.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.1.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
venv/ | ||
snet_cli.egg-info/ | ||
snet/snet_cli/resources/contracts/abi | ||
snet/snet_cli/resources/contracts/networks | ||
snet/snet_cli/resources/node_modules | ||
snet/snet_cli/resources/proto/*.py | ||
build/ | ||
dist/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include snet/snet_cli/resources/proto/* | ||
include snet/snet_cli/resources/contracts/abi/* | ||
include snet/snet_cli/resources/contracts/networks/* | ||
include snet/snet_cli/resources/package.json | ||
|
||
recursive-include snet_cli/_vendor * | ||
|
||
recursive-exclude * .git | ||
recursive-exclude * node_modules | ||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--index-url https://pypi.python.org/simple | ||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
from snet_cli.config import Config | ||
import argcomplete | ||
|
||
|
||
def main(): | ||
try: | ||
argv = sys.argv[1:] | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.