python模块打包方法
http://www.jb51.net/article/92789.htm
一 首先将模块的目录结构整理如下:
VASPy/
├── LICENSE
├── MANIFEST
├── MANIFEST.in
├── README.rst
├── requirements.txt
├── scripts
│ ├── change_incar_parameters.py
│ ├── create_inputs.py
│ └── ...
├── setup.cfg
├── setup.py
├── tests
│ ├── incar_test.py
│ ├── __init__.py
│ ├── oszicar_test.py
│ ├── outcar_test.py
│ ├── testdata
│ │ ├── CONTCAR
│ │ ├── DOS_SUM
│ │ ├── ELFCAR
│ │ └── ...
│ └── ...
└── vaspy
├── __init__.py
├── iter.py
├── matstudio.py
└── ...
注意上面的MANIFEST.in,requirements.txt, setup.py vaspy以及里面的__init__.py这些是必须
注意vaspy和里面的vaspy的一致。
tests是子包,scripys也是 子包,matstudio.py可以是模块入口文件
MANIFEST.in
此文件在打包的时候告诉setuptools还需要额外打包那些文件,例如我VASPy中的单元测试的测试数据文件我就使用这个文件将其包含进来。当然README,LICENSE这些也可以通过它来一起打包进来。
下面是我自己的MANIFEST.in的内容:
include README.rst
include requirements.txt
include LICENSE
recursive-include scripts *
recursive-include tests *
也就是把一些 必须 的文件还有子包引入进去
vaspy/
此文件夹就是vaspy源代码所在的包。个人理解是一个和模块名同名的文件夹
setup()的参数
name
versions = "vaspy"
是整个项目的名字,打包后会使用此名字和版本号。
description
是一个简短的对项目的描述,一般一句话就好,会显示在pypi上名字下端。
long_description
是一个长的描述,相当于对项目的一个简洁,如果此字符串是rst格式的,PyPI会自动渲染成HTML显示。这里可以直接读取README.rst中的内容。
url
包的连接,通常为GitHub上的链接或者readthedocs的链接。
packages
需要包含的子包列表,setuptools提供了find_packages()帮助我们在根路径下寻找包,这个函数distutil是没有的。
setup_requires
这个参数定义了VASPy安装和顺利运行所需要的其他依赖项(最基本的),使用pip安装的时候会对这些依赖项进行安装。
关于这个参数与requirements.txt的区别可以参考:install_requires vs Requirements files
classifier
这个参数提供了一系列的分类,在PyPI上会将其放入不同的目录中讲项目进行归类。
#!/usr/bin/env python from setuptools import setup, find_packages maintainer = 'Shao-Zheng-Jiang'
maintainer_email = 'shaozhengjiang@gmail.com'
author = maintainer
author_email = maintainer_email
description = "A pure Python library designed to make it easy and quick to manipulate VASP files" long_description = """
=====
test1
=====
.. image:: https://travis-ci.org/PytLab/test1.svg?branch=master
:target: https://travis-ci.org/PytLab/test1
:alt: Build Status
.. image:: https://landscape.io/github/PytLab/test1/master/landscape.svg?style=flat
:target: https://landscape.io/github/PytLab/test1/master
:alt: Code Health
.. image:: https://codecov.io/gh/PytLab/test1/branch/master/graph/badge.svg
:target: https://codecov.io/gh/PytLab/test1
.. image:: https://img.shields.io/badge/python-3.5, 2.7-green.svg
:target: https://www.python.org/downloads/release/python-351/
:alt: platform
.. image:: https://img.shields.io/badge/pypi-v0.8.8-blue.svg
:target: https://pypi.python.org/pypi/test1/
:alt: versions
Introduction
------------
test1 is a pure Python library designed to make it easy and quick to manipulate VASP files.
You can use test1 to manipulate VASP files in command lins or write your own python scripts to process VASP files and visualize VASP data.
In `/scripts <https://github.com/PytLab/test1/tree/master/scripts>`_ , there are some scripts written by me for daily use.
Installation
------------
. Via pip(recommend)::
pip install test1
. Via easy_install::
easy_install test1
. From source::
python setup.py install
If you want to use **mayavi** to visualize VASP data, it is recommened to install `Canopy environment <https://store.enthought.com/downloads/#default>`_ on your device instead of installing it manually.
After installing canopy, you can set corresponding aliases, for example:
.. code-block:: shell
alias canopy='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/python'
alias canopy-pip='/Users/zjshao/Library/Enthought/Canopy/edm/envs/User/bin/pip'
alias canopy-ipython='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/ipython'
alias canopy-jupyter='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/jupyter'
Then you can install test1 to canopy::
canopy-pip install test1
""" install_requires = [
'configparser',
'selenium',
] # Get long description.
#with open("README.rst") as f:
# lines = f.readlines()
#
#long_description = ""
#for line in lines:
# if "Installation" in line:
# break
# else:
# long_description += line name = 'test1'
packages = [
'test1',
]
platforms = ['linux'] # classifiers = [
# 'Development Status :: 3 - Alpha',
# 'Topic :: Text Processing',
# 'License :: OSI Approved :: MIT License',
# 'Programming Language :: Python :: 2',
# 'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3',
# 'Programming Language :: Python :: 3.5',
# ] setup(author=author,
author_email=author_email,
description=description,
license=license,
long_description=long_description,
install_requires=install_requires,
maintainer=maintainer,
name=name,
packages=find_packages(),
platforms=platforms,
# test_suite="tests",
)
上面 是我自己修改后的,有一些不是必须
模块打包好后,安装方法
python setup.py install
python模块打包方法的更多相关文章
- 详解Python模块导入方法
python常被昵称为胶水语言,它能很轻松的把用其他语言制作的各种模块(尤其是C/C++)轻松联结在一起.python包含子目录中的模块方法比较简单,关键是能够在sys.path里面找到通向模块文件的 ...
- Python模块安装方法
安装Python模块 电子邮件 distutils-sig @ python .组织 作为一个受欢迎的开源开发项目,Python具有活跃的贡献者和用户支持社区,并且根据开放源代码许可条款,其软件可供其 ...
- c#项目调用Python模块的方法
将Python模块用pyinstaller打包成exe程序 下载安装UPX((http://upx.sourceforge.net/)) ,并把路径加到环境变量中. UPX是开源的加壳和压缩exe的程 ...
- 两种动态载入修改后的python模块的方法
方案一:循环导入/删除模块 a.py import sys, time while True: from b import test test() del sys.modules(b) time.sl ...
- 使用 from import方法导入Python模块
比如我们导入一个数学计算的模块 math: >>> import math>>> print math<module 'math' (built-in)> ...
- Python模块常用的几种安装方式
Python模块安装方法 一.方法1: 单文件模块直接把文件拷贝到 $python_dir/Lib 二.方法2: 多文件模块,带setup.py 下载模块包,进行解压,进入模块文件夹,执行:pytho ...
- ipython和pip,模块安装方法
先下载 pip-.tar.gz 解压文件 cmd进入这个加压后的文件 执行 python setup.py install 然后配置环境变量 把 python 下的 Scripts 文件目录添加到 P ...
- python模块的打包
python模块的打包方法: http://blog.csdn.net/five3/article/details/7847551
- python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheetahcherrypy:一个WEB frameworkctype ...
随机推荐
- hadoop2.6.4【windows7】构建maven项目 系列2
准备windows版本的hadoop2.6.4 下载windows版本的hadoop2.6.4解压在本地 新建maven项目构建hadoop依赖 <?xml version="1.0& ...
- 【干货】2个小时教你hexo博客添加评论、打赏、RSS等功能 (转)
备注:该教程基于Hexo 2.x版本,目前Hexo是3.x版本,照本教程实现有可能会出现404错误,笔者目前还未找时间去解决,待笔者找时间解决该问题后,再写一篇该问题的解决教程,给各位读者带来困扰,还 ...
- Scala 基础(1)—— 定义变量 & 定义函数
1. 使用 val & var 定义变量 Scala 中的变量被分为2种:val 和 var.其含义于 Java 中的 final 关键字类似. val 等同于被 final 修饰过的变量, ...
- 少年Pi的奇幻漂流
选择怀疑作为生活哲学就像选择静止作为交通方式. 的确,我们遇见的人可能改变我们,有时候改变如此深刻,在那之后我们成了完全不同的人,甚至我们的名字都不一样了. 声音会消失,但伤害却留了下来,像小便蒸 ...
- 一键GHOST
软件简介: 一键GHOST是"DOS之家"首创的4种版本(硬盘版/光盘版/优盘版/软盘版)同步发布的启动盘,适应各种用户需要,既可独立使用,又能相互配合.主要功能包括:一键备份系统 ...
- rem、em、px之间的转换
rem是相对于根元素<html>,这样就意味着,我们只需要在根元素确定一个参考值,这个参考值设置为多少,完全可以根据您自己的需求来定. 我们知道,浏览器默认的字号16px,来看一些px单位 ...
- 使用vue-cli开发时跨域问题
打开config文件夹下的index.js,配置proxyTable: { ... dev:{ ... proxyTable: { '/api': { target: 'http://localhos ...
- 分享C# GC 非原创
一. 托管资源的分配 CLR在运行时管理着一段内存地址空间(虚拟地址空间,在运行中会映射到物理内存地址中),分为“托管堆”和“栈”两部分,栈用于存储值类型数据,它会在方法执行结束后自动销毁其中引用的值 ...
- xmlSerializer属性的使用
学习了XmlAttribute,XmlElement属性的定义和使用. Order类定义 using System; using System.Collections.Generic; using S ...
- GitHub上README写法暨markdown语法解读
原文: GitHub上README写法暨markdown语法解读 自从开始玩GitHub以来,就 越来越 感觉它有爱.最近对它的 README.md 文件颇为感兴趣.便写下这贴,帮助更多的还不会编写R ...