Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/python packaging #310

Merged
merged 49 commits into from
Nov 6, 2018
Merged

Feature/python packaging #310

merged 49 commits into from
Nov 6, 2018

Conversation

migwellian
Copy link
Contributor

This PR makes it possible for us to deploy our python package to PyPi so that users can pip install keanu.

Currently you also need to put all your ND4J dependencies into a local directory and point to it with an environment variable KEANU_ND4J_CLASSPATH. This is only because of its size (around 250MB) - there is a 60MB limit on PyPi, although this will be extended if we request it.

Next step: see if we can strip ND4J down to just the bits we need, and measure its size.

keanu-python/setup.py Outdated Show resolved Hide resolved
keanu-python/keanu/base.py Outdated Show resolved Hide resolved
@migwellian
Copy link
Contributor Author

Here is a list of the largest jar files amongst ND4J's dependencies:

-rw-r--r--  1 michaellewin  staff   668K 29 Oct 16:26 openblas-0.3.0-1.4.2-ios-arm64.jar
-rw-r--r--  1 michaellewin  staff   777K 29 Oct 16:26 openblas-0.3.0-1.4.2-android-arm.jar
-rw-r--r--  1 michaellewin  staff   859K 29 Oct 16:26 openblas-0.3.0-1.4.2-android-arm64.jar
-rw-r--r--  1 michaellewin  staff   871K 29 Oct 16:26 openblas-0.3.0-1.4.2-ios-x86_64.jar
-rw-r--r--  1 michaellewin  staff   1.2M 29 Oct 16:26 openblas-0.3.0-1.4.2-android-x86.jar
-rw-r--r--  1 michaellewin  staff   1.2M 29 Oct 16:26 nd4j-native-1.0.0-beta2.jar
-rw-r--r--  1 michaellewin  staff   1.4M 29 Oct 16:26 protobuf-java-shaded-351-0.9.jar
-rw-r--r--  1 michaellewin  staff   1.4M 29 Oct 16:26 openblas-0.3.0-1.4.2-android-x86_64.jar
-rw-r--r--  1 michaellewin  staff   1.5M 29 Oct 16:26 mkl-2018.3-1.4.2-windows-x86.jar
-rw-r--r--  1 michaellewin  staff   1.8M 29 Oct 16:26 jackson-1.0.0-beta2.jar
-rw-r--r--  1 michaellewin  staff   1.9M 29 Oct 16:26 commons-math3-3.5.jar
-rw-r--r--  1 michaellewin  staff   2.3M 29 Oct 16:26 mkl-2018.3-1.4.2-windows-x86_64.jar
-rw-r--r--  1 michaellewin  staff   2.3M 29 Oct 16:26 guava-20.0.jar
-rw-r--r--  1 michaellewin  staff   2.5M 29 Oct 16:26 mkl-2018.3-1.4.2-macosx-x86_64.jar
-rw-r--r--  1 michaellewin  staff   2.9M 29 Oct 16:26 mkl-2018.3-1.4.2-linux-x86_64.jar
-rw-r--r--  1 michaellewin  staff   3.1M 29 Oct 16:26 mkl-2018.3-1.4.2-linux-x86.jar
-rw-r--r--  1 michaellewin  staff   5.1M 29 Oct 16:26 nd4j-api-1.0.0-beta2.jar
-rw-r--r--  1 michaellewin  staff   5.4M 29 Oct 16:26 nd4j-native-1.0.0-beta2-android-arm.jar
-rw-r--r--  1 michaellewin  staff   5.5M 29 Oct 16:26 nd4j-native-1.0.0-beta2-ios-arm64.jar
-rw-r--r--  1 michaellewin  staff   5.6M 29 Oct 16:26 openblas-0.3.0-1.4.2-linux-armhf.jar
-rw-r--r--  1 michaellewin  staff   5.7M 29 Oct 16:26 nd4j-native-1.0.0-beta2-android-arm64.jar
-rw-r--r--  1 michaellewin  staff   5.8M 29 Oct 16:26 nd4j-native-1.0.0-beta2-linux-ppc64le.jar
-rw-r--r--  1 michaellewin  staff   6.1M 29 Oct 16:26 nd4j-native-1.0.0-beta2-linux-x86_64.jar
-rw-r--r--  1 michaellewin  staff   6.2M 29 Oct 16:26 nd4j-native-1.0.0-beta2-android-x86_64.jar
-rw-r--r--  1 michaellewin  staff   6.4M 29 Oct 16:26 nd4j-native-1.0.0-beta2-ios-x86_64.jar
-rw-r--r--  1 michaellewin  staff   6.5M 29 Oct 16:26 nd4j-native-1.0.0-beta2-macosx-x86_64.jar
-rw-r--r--  1 michaellewin  staff   6.6M 29 Oct 16:26 nd4j-native-1.0.0-beta2-android-x86.jar
-rw-r--r--  1 michaellewin  staff   6.8M 29 Oct 16:26 nd4j-native-1.0.0-beta2-windows-x86_64.jar
-rw-r--r--  1 michaellewin  staff   6.9M 29 Oct 16:26 openblas-0.3.0-1.4.2-linux-ppc64le.jar
-rw-r--r--  1 michaellewin  staff   8.7M 29 Oct 16:26 openblas-0.3.0-1.4.2-linux-x86.jar
-rw-r--r--  1 michaellewin  staff   8.8M 29 Oct 16:26 openblas-0.3.0-1.4.2-windows-x86.jar
-rw-r--r--  1 michaellewin  staff    12M 29 Oct 16:26 openblas-0.3.0-1.4.2-linux-x86_64.jar
-rw-r--r--  1 michaellewin  staff    13M 29 Oct 16:26 openblas-0.3.0-1.4.2-windows-x86_64.jar
-rw-r--r--  1 michaellewin  staff    13M 29 Oct 16:26 openblas-0.3.0-1.4.2-macosx-x86_64.jar
-rw-r--r--  1 michaellewin  staff    31M 29 Oct 16:26 mkl-dnn-0.15-1.4.2-macosx-x86_64.jar
-rw-r--r--  1 michaellewin  staff    41M 29 Oct 16:26 mkl-dnn-0.15-1.4.2-linux-x86_64.jar
-rw-r--r--  1 michaellewin  staff    41M 29 Oct 16:26 mkl-dnn-0.15-1.4.2-windows-x86_64.jar

@migwellian
Copy link
Contributor Author

I guess we can exclude mkl-dnn altogether...?

@migwellian
Copy link
Contributor Author

I've got ND4J's dependencies down to 75MB but I don't think I can go any further. We could split our python package up into 3 different versions (for 3 platforms) but that feels like introducing unnecessary complexity.

2.1K 30 Oct 14:04 mkl-platform-2018.3-1.4.2.jar
2.1K 30 Oct 14:04 mkl-dnn-platform-0.15-1.4.2.jar
2.9K 30 Oct 14:04 nd4j-native-platform-1.0.0-beta2.jar
8.6K 30 Oct 14:04 nd4j-context-1.0.0-beta2.jar
9.9K 30 Oct 14:04 flatbuffers-1.2.0-3f79e055.jar
 26K 30 Oct 14:04 cloning-1.9.3.jar
 40K 30 Oct 14:04 slf4j-api-1.7.21.jar
 47K 30 Oct 14:04 nd4j-native-api-1.0.0-beta2.jar
 52K 30 Oct 14:04 neoitertools-1.0.0.jar
 54K 30 Oct 14:04 objenesis-2.6.jar
 64K 30 Oct 14:04 nd4j-buffer-1.0.0-beta2.jar
 68K 30 Oct 14:04 protobuf-java-util-shaded-351-0.9.jar
125K 30 Oct 14:04 openblas-0.3.0-1.4.2.jar
147K 30 Oct 14:04 mkl-dnn-0.15-1.4.2.jar
195K 30 Oct 14:04 mkl-2018.3-1.4.2.jar
204K 30 Oct 14:04 commons-io-2.5.jar
213K 30 Oct 14:04 nd4j-common-1.0.0-beta2.jar
227K 30 Oct 14:04 gson-2.7.jar
264K 30 Oct 14:04 snakeyaml-1.12.jar
278K 30 Oct 14:04 commons-codec-1.10.jar
352K 30 Oct 14:04 javacpp-1.4.2.jar
483K 30 Oct 14:04 commons-lang3-3.6.jar
546K 30 Oct 14:04 commons-compress-1.16.1.jar
560K 30 Oct 14:04 joda-time-2.2.jar
1.2M 30 Oct 14:04 nd4j-native-1.0.0-beta2.jar
1.4M 30 Oct 14:04 protobuf-java-shaded-351-0.9.jar
1.8M 30 Oct 14:04 jackson-1.0.0-beta2.jar
1.9M 30 Oct 14:04 commons-math3-3.5.jar
2.3M 30 Oct 14:04 guava-20.0.jar
5.1M 30 Oct 14:04 nd4j-api-1.0.0-beta2.jar
6.1M 30 Oct 14:04 nd4j-native-1.0.0-beta2-linux-x86_64.jar
6.5M 30 Oct 14:04 nd4j-native-1.0.0-beta2-macosx-x86_64.jar
6.8M 30 Oct 14:04 nd4j-native-1.0.0-beta2-windows-x86_64.jar
 12M 30 Oct 14:04 openblas-0.3.0-1.4.2-linux-x86_64.jar
 13M 30 Oct 14:04 openblas-0.3.0-1.4.2-windows-x86_64.jar
 13M 30 Oct 14:04 openblas-0.3.0-1.4.2-macosx-x86_64.jar

@icantsayrural
Copy link
Contributor

Is it possible for KeanuContext to download Java Keanu from Github and create a jar file?

@migwellian
Copy link
Contributor Author

Request to increase PiPI file size limit: pypi/warehouse#4979

@migwellian
Copy link
Contributor Author

Is it possible for KeanuContext to download Java Keanu from Github and create a jar file?

We could do something like that, but I don't want to be dependent on internet connectivity at runtime. I think any pulling down of dependencies ought to happen at installation time.

@migwellian
Copy link
Contributor Author

We've been given an increased limit of 100MB now

migwellian and others added 23 commits November 2, 2018 18:08
…he environment variable APPVEYOR_BUILD_FOLDER

def readme():
with open('README.rst', "r") as f:
return f.read()

version_string = '0.0.14.dev8'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be 0.0.15.dev0 if we want to follow java Keanu.

Copy link
Contributor

@icantsayrural icantsayrural left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just some nits.

.gitignore Show resolved Hide resolved
if nd4j_path is None:
return keanu_path
else:
return os.pathsep.join([keanu_path, os.path.join(nd4j_path, "*")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for appveyor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's for Windows.

For now, Windows users have to download a 40MB jar (mkl-dnn) and set an environment variable to point to it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

@@ -0,0 +1,10 @@
# Root logger option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is this related to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's related to me trying to debug why it was freezing on Windows!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it will be useful to have this in our main branch

Copy link
Contributor

@icantsayrural icantsayrural left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments

author='Improbable Worlds',
author_email='keanu-engineering@improbable.io',
url='https://github.com/improbable-research/keanu',
license='MIT',
packages=['keanu'],
packages=find_packages(exclude=["examples"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also exclude tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems to happen automatically

version_string = '0.0.15.dev0'

# If you don't remove the old directories, it tends to put the excluded module "examples" into the bdist
for dir_name in ("keanu-%s.dist-info" % version_string, "keanu.egg-info", "build", "dist"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we can get around this bug my adding some more stuff to our MANIFEST.in

Source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - see e.g. pypa/setuptools#511

@migwellian migwellian merged commit d464e8d into develop Nov 6, 2018
@migwellian migwellian deleted the feature/python-packaging branch November 6, 2018 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants