我在官方教程https://docs.djangoproject.com/en/1.8/intro/reusable-apps/之后构建并安装了我的自定义Django应用程序
安装似乎很成功.
$ pip install --user ../horizon2fa-0.1.tar.gz
Processing /opt/stack/horizon2fa-0.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): horizon2fa==0.1 from file:///opt/stack/horizon2fa-0.1.tar.gz in /opt/stack/.local/lib/python2.7/site-packages
Building wheels for collected packages: horizon2fa
Running setup.py bdist_wheel for horizon2fa ... done
Stored in directory: /opt/stack/.cache/pip/wheels/a6/4a/f0/4533f85d90b8f1a274a35d3865a2e0b15ff85f0570a0708679
Successfully built horizon2fa
Run Code Online (Sandbox Code Playgroud)
我在哪里可以找到所有自定义类和方法的源代码?
我试图通过我的系统搜索它,但没有找到它们.代码编译了吗?
$ sudo find / -name "*horizon2fa*"
/root/.cache/pip/wheels/a0/9d/24/d8070ea2a01759ce7ebc03c34393db8a5aceccd380e60481c5/horizon2fa-0.1-cp27-none-any.whl
/opt/stack/.cache/pip/wheels/a6/4a/f0/4533f85d90b8f1a274a35d3865a2e0b15ff85f0570a0708679/horizon2fa-0.1-cp27-none-any.whl
/opt/stack/.local/lib/python2.7/site-packages/horizon2fa-0.1.dist-info
/opt/stack/horizon2fa-0.1.tar.gz
Run Code Online (Sandbox Code Playgroud)
该模块似乎未正确安装.
python -c "import horizon2fa; print(horizon2fa.__path__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named horizon2fa
Run Code Online (Sandbox Code Playgroud)
下面,您可以看到我的app目录结构.
trex@trex:~/Development/openstack2FA/horizon2fa$ tree
.
??? admin.py
??? dist
? ??? horizon2fa-0.1.tar.gz
??? enabled
? ??? _31000_myplugin.py
??? horizon2fa.egg-info
? ??? dependency_links.txt
? ??? PKG-INFO
? ??? SOURCES.txt
? ??? top_level.txt
??? __init__.py
??? LICENSE
??? main.py
??? MANIFEST.in
??? migrations
? ??? 0001_initial.py
? ??? __init__.py
??? models.py
??? panel.py
??? README.rst
??? setup.py
??? templates
? ??? base.html
? ??? horizon2fa
? ??? created.html
? ??? index.html
? ??? login.html
? ??? new.html
? ??? view.html
??? tests.py
??? urls.py
??? user.py
??? views.py
Run Code Online (Sandbox Code Playgroud)
还有我的setup.py脚本.
import os
from setuptools import find_packages, setup
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:
README = readme.read()
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup(
name='horizon2fa',
version='0.1',
packages=find_packages(),
include_package_data=True,
license='BSD License', # example license
description='A Django app.',
long_description=README,
url='http://www.trex.com/',
author='trex',
author_email='trex@trex.com',
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: X.Y', # replace "X.Y" as appropriate
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License', # example license
'Operating System :: OS Independent',
'Programming Language :: Python',
# Replace these appropriately if you are stuck on Python 2.
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)
Run Code Online (Sandbox Code Playgroud)
因为您使用了--user,所以该软件包是为当前用户(发布者pip install --user)安装的,而不是在系统site-packages目录中。请参阅site.USER_BASE的文档。~/.local/\n因此,您应该按照文档中的说明进行查找,可能是: /home/%user%/.local/lib/python%version%/site-packages/。
另外,考虑到该软件包已安装在 PYTHONPATH 上的某个位置,您可以尝试通过在 shell 中运行以下命令来找到它:
\n\npython -c "import %module%; print(%module%.__path__)"\nRun Code Online (Sandbox Code Playgroud)\n\nIE
\n\npython -c "import horizon2fa; print(horizon2fa.__path__)"\nRun Code Online (Sandbox Code Playgroud)\n\n关于您的问题更新:
\n\n您应该创建一个顶级目录,例如django-horizon2fa,并将setup.py、MANIFEST.in、README.RST和LICENSE.txt您的horizon2fa包目录放入其中。因此,与安装相关的文件位于新目录中,并且与模块相关的所有文件都位于该目录中的目录中。当前目录设置不允许find_packages()正确完成其工作。
django-horizon2fa\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 LICENSE\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 MANIFEST.in\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.rst\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 setup.py\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 horizon2fa\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 admin.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 urls.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 user.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 views.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 enabled\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 _31000_myplugin.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 migrations\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 0001_initial.py\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 __init__.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 models.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 panel.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 urls.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 user.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 views.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 templates\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 base.html\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 horizon2fa\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 created.html\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.html\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 login.html\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 new.html\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 view.html\nRun Code Online (Sandbox Code Playgroud)\n\nPS 单独使用MANIFEST.in有时可能会导致在分发中包含包数据(例如模板)时出现问题。在这种情况下,请考虑将字典MANIFEST.in中的文件提供给,请参阅文档中的详细信息package_datasetup()。
| 归档时间: |
|
| 查看次数: |
129 次 |
| 最近记录: |