简体   繁体   English

用python包装科学项目

[英]packaging scientific project in python

I am trying to build a package for an apps in python. 我正在尝试为python中的应用程序构建软件包。 It uses sklearn , pandas , numpy , boto and some other scientific module from anaconda . 它使用sklearnpandasnumpybotoanaconda其他一些科学模块。 Being very unexperienced with python packaging, I have various questions: 由于对python打包非常缺乏经验,我有很多问题:

1- I have some confidential files .py in my project which I don't want anyone to be able to see. 1-我的项目中有一些机密文件.py ,我不想让任何人看到。 In java I would have defined private files and classes but I am completely lost in python. 在Java中,我会定义私有文件和类,但在python中我完全迷路了。 What is the "good practice" to deal with these private modules? 处理这些私有模块的“最佳做法”是什么? Can anyone link me some tutorial? 谁能给我链接一些教程?

2- What is the best way to package my apps? 2-打包我的应用程序的最佳方法是什么? I don't want to publish anything on Pypi , I only need it to execute on Google App engine for instance. 我不想在Pypi上发布任何内容, Pypi ,我只需要在Google App引擎上执行它即可。 I tried a standalone package with PyInstaller but I could not finish it because of numpy and other scipy packages which makes it hard. 我用PyInstaller尝试了一个独立的程序包,但是由于numpy和其他scipy程序包而使它变得困难,因此无法完成它。 Is there a simple way to package in a private way python projects made with anaconda ? 有没有一种简单的方法可以用私有方式打包用anaconda制作的python项目?

3- Since I want to build more apps in a close future, shall I try to make sub-packages in order to use them for other apps? 3-由于我想在不久的将来构建更多应用程序,我是否应该尝试制作子软件包以便将其用于其他应用程序?

  1. The convention is to lead with a single underscore _ if something is internal. 如果内部有某些约定,则约定以下划线_开头。 Note that this is a convention. 请注意,这是一个约定。 If someone really wants to use it, they still can. 如果有人真的想使用它,他们仍然可以。 Your code is not strictly confidential. 您的代码不是严格保密。

  2. Take a look at http://python-packaging-user-guide.readthedocs.org/en/latest/ . 看看http://python-packaging-user-guide.readthedocs.org/en/latest/ You don't need to publish to pypi to create a Python package that uses tools such as pip . 您无需发布到pypi即可创建使用诸如pip工具的Python包。 You can create a project with a setup.py file and a requirements.txt file and then use pip to install your package from wherever you have it (eg, a local directory or a repository on github). 您可以使用setup.py文件和requirements.txt文件创建一个项目,然后使用pip从任何地方安装软件包(例如,本地目录或github上的存储库)。 If you take this approach then pip will install all the dependencies you list. 如果您采用这种方法,则pip将安装您列出的所有依赖项。

  3. If you want to reuse your package, just include it in requirements.txt and the install_requires parameter in setup.py (see http://python-packaging-user-guide.readthedocs.org/en/latest/requirements/ ). 如果您想重用您的软件包,只需将其包含在requirements.txt ,并将install_requires参数包含在setup.py (请参阅http://python-packaging-user-guide.readthedocs.org/en/latest/requirements/ )。 For example, if you install your package with pip install https://github/myname/mypackage.git then you could include https://github/myname/mypackage.git in your requirements.txt file in future projects. 例如,如果使用pip install https://github/myname/mypackage.git安装软件包,则可以在以后的项目中将https://github/myname/mypackage.git包含在您的requirements.txt文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM