[英]setup.py is installing into the root of folder site-packages
是的,我是 Python 打包的新手,但對 Python 並不陌生。 我開發的一個包有子包——比如“格式”和“工具箱”。 我的代碼在 Gitlab 下的存儲庫中。 服務器地址為https://git.wur.nl
在我的計算機上,我有幾個 Python 實例。 為了確保我調用了正確的 pip 實例,我移動到它的安裝位置 - 在子文件夾 Scripts 中。 為了在我的 Windows 機器上安裝我的包,我輸入:
C:\\Python36\\Scripts\\pip 安裝 git+https://git.wur.nl/myname/mypkg
然后安裝似乎進行得很順利。 我希望我的代碼最終會出現在目錄 C:\\Python36\\Lib\\site-packages\\mypkg 中,即在文件夾 mypkg 下有子文件夾“格式”和“工具箱”。 不幸的是,文件夾“格式”和“工具箱”最終位於 C:\\Python36\\Lib\\site-packages 的根目錄中。 當我嘗試在 Python 腳本左右導入 mypkg 時,我被告知包 mypkg 不存在 - 不足為奇。 下面是模塊 setup.py 的代碼...
這里出了什么問題?
from setuptools import setup, find_packages
import os
PACKAGE = "mypkg"
NAME = "Mypkg"
DESCRIPTION = 'Python raster GIS library with low memory requirements.'
AUTHOR = "Dobedani"
AUTHOR_EMAIL = 'dobedani@xyz.nl'
URL = 'https://git.wur.nl/myname/mypkg/'
LICENSE="LGPL"
VERSION = "1.0"
here = os.path.abspath(os.path.dirname(__file__))
long_description = 'Python raster GIS library with low memory requirements.'
setup(
name=NAME,
version=VERSION,
url=URL,
download_url='https://git.wur.nl/dobedani/mypkg/-/archive/master/mypkg-master.tar.gz',
license='LGPL',
author=AUTHOR,
install_requires=['pyshp>=2.1.0',
'pyproj>=1.9.5.1',
'numpy>=1.14.3',
'tifffile>=2019.3.18',
'tables>=3.5.2',
'netCDF4>=1.5.1.2',
'libtiff>=0.4.2'],
author_email=AUTHOR_EMAIL,
description=DESCRIPTION,
long_description=long_description,
packages=find_packages(),
include_package_data=True,
platforms='any',
test_suite='mypkg.tests.make_test_suite',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3.0 (LGPL 3.0)',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering']
)
下面給出了包的結構的概念:
mypkg
formats/
__init__.py
asciigrid.py
toolbox/
__init__.py
cliplib.py
setup.py
README.md
requirements.txt
MANIFEST.in
LICENSE
關於項目的頂級包是什么存在混淆。
如果您希望頂級包為mypkg
並且代碼可導入,如下所示:
import mypkg
# or
from mypkg import formats
from mypkg import toolbox
那么合適的目錄結構是:
mypkg/
mypkg/
__init__.py
formats/
__init__.py
asciigrid.py
toolbox/
__init__.py
cliplib.py
setup.py
README.md
requirements.txt
MANIFEST.in
LICENSE
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.