简体   繁体   English

setuptools非常简单(一个源文件模块)配置

[英]setuptools very simple (one source file module) configuration

I want to use setuptools to create a package consisting of two files: foo.py (script) and foo.conf . 我想用setuptools创建一个包包括以下两个文件: foo.py (脚本)和foo.conf

Then I want to publish the package on my devpi-server and then install the package using pip . 然后,我想在我的devpi-server上发布该软件包,然后使用pip安装该软件包。

Suppose I that initially I have my current working directory clean 假设我最初的工作目录是干净的

$ ls -l
total 0

Then I issue pip install (or download ?) command 然后我发出pip install (或download ?)命令

$ pip install -i http://mydevpi.server foo

And get a dir with my two files created 并获得创建了我的两个文件的目录

$ tree
.
|
foo
|
|\_ foo.py
|
 \_ foo.conf

So questions are: 所以问题是:

  • what setuptools configuration should I use? 我应该使用哪种setuptools配置?
  • what exact pip command should I use to install the package the way I want? 我应该使用哪种确切的pip命令以所需方式安装软件包? Will pip install -i http://mydevpi.server --target=. pip install -i http://mydevpi.server --target=. do the trick? 绝招?

First write somethings as setup.py in foo directory like: 首先在foo目录中将内容写为setup.py ,例如:

import setuptools

setuptools.setup(
    name='foo_pip',
    version='1',
    packages=[''],
    url='1',
    license='1',
    author='1',
    author_email='1',
    description='1'
)

(You can use distutils or setuptools ) (您可以使用distutilssetuptools

Then python setup.py bdist_wheel -d TARGET and there will be a whl file in target directory, copy the path. 然后python setup.py bdist_wheel -d TARGETtarget目录中将有一个whl文件,复制路径。

You can now install using pip install the_wheel_file_path --prefix="the_path_to_install" 您现在可以使用pip install the_wheel_file_path --prefix="the_path_to_install"

Something like this 像这样

Processing .../TARGET/foo_pip-1-py2-none-any.whl
Installing collected packages: foo-pip
Successfully installed foo-pip-1

Then use it by import foo 然后通过import foo使用它

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

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