- Introduction to Python
- Getting started with Python and the IPython notebook
- Functions are first class objects
- Data science is OSEMN
- Working with text
- Preprocessing text data
- Working with structured data
- Using SQLite3
- Using HDF5
- Using numpy
- Using Pandas
- Computational problems in statistics
- Computer numbers and mathematics
- Algorithmic complexity
- Linear Algebra and Linear Systems
- Linear Algebra and Matrix Decompositions
- Change of Basis
- Optimization and Non-linear Methods
- Practical Optimizatio Routines
- Finding roots
- Optimization Primer
- Using scipy.optimize
- Gradient deescent
- Newton’s method and variants
- Constrained optimization
- Curve fitting
- Finding paraemeters for ODE models
- Optimization of graph node placement
- Optimization of standard statistical models
- Fitting ODEs with the Levenberg–Marquardt algorithm
- 1D example
- 2D example
- Algorithms for Optimization and Root Finding for Multivariate Problems
- Expectation Maximizatio (EM) Algorithm
- Monte Carlo Methods
- Resampling methods
- Resampling
- Simulations
- Setting the random seed
- Sampling with and without replacement
- Calculation of Cook’s distance
- Permutation resampling
- Design of simulation experiments
- Example: Simulations to estimate power
- Check with R
- Estimating the CDF
- Estimating the PDF
- Kernel density estimation
- Multivariate kerndel density estimation
- Markov Chain Monte Carlo (MCMC)
- Using PyMC2
- Using PyMC3
- Using PyStan
- C Crash Course
- Code Optimization
- Using C code in Python
- Using functions from various compiled languages in Python
- Julia and Python
- Converting Python Code to C for speed
- Optimization bake-off
- Writing Parallel Code
- Massively parallel programming with GPUs
- Writing CUDA in C
- Distributed computing for Big Data
- Hadoop MapReduce on AWS EMR with mrjob
- Spark on a local mahcine using 4 nodes
- Modules and Packaging
- Tour of the Jupyter (IPython3) notebook
- Polyglot programming
- What you should know and learn more about
- Wrapping R libraries with Rpy
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
Distributing your package
Suppose we want to distribute our code as a library (for example, on PyPI so that it cnn be installed with pip
). Let’s create an sta663
library containing the pkg
package and some other files:
README.md
: some information about the librarysta663.py
: a standalone modulerun_sta663.py
: a script (intended for use aspython run_sta.py
)
! ls -R sta663
README.txt run_sta663.py sta663.py �[34mpkg// setup.py �[34mtests// sta663/pkg: __init__.py foo.py �[34msub1// �[34msub2// sta663/pkg/sub1: __init__.py more_sub1_stuff.py sub1_stuff.py sta663/pkg/sub2: __init__.py sub2_stuff.py sta663/tests:
! cat sta663/run_sta663.py
import pkg.foo as foo from pkg.sub1.more_sub1_stuff import g3 from pkg.sub2.sub2_stuff import h2 print foo.f1() print g3() print h2()
Using distutils
All we need to do is to write a setup.py
file.
! cat sta663/setup.py
from distutils.core import setup setup(name = "sta663", version = "1.0", author='Cliburn Chan', author_email='cliburn.chan@duke.edu', url='http://people.duke.edu/~ccc14/sta-663/', py_modules = ['sta663'], packages = ['pkg', 'pkg/sub1', 'pkg/sub2'], scripts = ['run_sta663.py'] )
Build a source archive for distribution
%%bash cd sta663 python setup.py sdist cd -
running sdist running check writing manifest file 'MANIFEST' creating sta663-1.0 creating sta663-1.0/pkg creating sta663-1.0/pkg/sub1 creating sta663-1.0/pkg/sub2 making hard links in sta663-1.0... hard linking README.txt -> sta663-1.0 hard linking run_sta663.py -> sta663-1.0 hard linking setup.py -> sta663-1.0 hard linking sta663.py -> sta663-1.0 hard linking pkg/__init__.py -> sta663-1.0/pkg hard linking pkg/foo.py -> sta663-1.0/pkg hard linking pkg/sub1/__init__.py -> sta663-1.0/pkg/sub1 hard linking pkg/sub1/more_sub1_stuff.py -> sta663-1.0/pkg/sub1 hard linking pkg/sub1/sub1_stuff.py -> sta663-1.0/pkg/sub1 hard linking pkg/sub2/__init__.py -> sta663-1.0/pkg/sub2 hard linking pkg/sub2/sub2_stuff.py -> sta663-1.0/pkg/sub2 creating dist Creating tar archive removing 'sta663-1.0' (and everything under it) /Users/cliburn/git/STA663-2015/Lectures/Topic23_Packaging
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)
! ls -R sta663
MANIFEST �[34mdist// run_sta663.py sta663.py README.txt �[34mpkg// setup.py �[34mtests// sta663/dist: sta663-1.0.tar.gz sta663/pkg: __init__.py foo.py �[34msub1// �[34msub2// sta663/pkg/sub1: __init__.py more_sub1_stuff.py sub1_stuff.py sta663/pkg/sub2: __init__.py sub2_stuff.py sta663/tests:
Distribution
You can now distribute sta663-1.0.tar.gz
to somebody else for installation in the usual way.
%%bash cp sta663/dist/sta663-1.0.tar.gz /tmp cd /tmp tar xzf sta663-1.0.tar.gz cd sta663-1.0 python setup.py install
running install running build running build_py running build_scripts running install_lib running install_scripts changing mode of /Users/cliburn/anaconda/bin/run_sta663.py to 755 running install_egg_info Writing /Users/cliburn/anaconda/lib/python2.7/site-packages/sta663-1.0-py2.7.egg-info
Distributing to PyPI
Just enter python setup.py register
and respond to the prompts to register as a new user.
References
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论