python-packaging

Can't access top level python package from sub packages

℡╲_俬逩灬. 提交于 2021-01-29 13:09:49
问题 I have a directory structure like below: chatbot/ __init__.py utils/ __init__.py parser.py nlu/ __init__.py training/ __init__.py module.py I want to access parser.py from module.py . I tried using this line from module.py : from chatbot.utils import parser And I got this error: ModuleNotFoundError: No module named 'chatbot' Any pointers to what I am doing wrong? I am using python3 and trying to run the script as python3 nlu/training/module.py . Thanks in advance! 回答1: I believe the right way

Can't access top level python package from sub packages

北城以北 提交于 2021-01-29 12:33:19
问题 I have a directory structure like below: chatbot/ __init__.py utils/ __init__.py parser.py nlu/ __init__.py training/ __init__.py module.py I want to access parser.py from module.py . I tried using this line from module.py : from chatbot.utils import parser And I got this error: ModuleNotFoundError: No module named 'chatbot' Any pointers to what I am doing wrong? I am using python3 and trying to run the script as python3 nlu/training/module.py . Thanks in advance! 回答1: I believe the right way

How to write a minimally working pyproject.toml file that can install packages?

孤街浪徒 提交于 2021-01-26 10:00:24
问题 Pip supports the pyproject.toml file but so far all practical usage of the new schema requires a 3rd party tool that auto-generates these files (e.g., poetry and pip). Unlike setup.py which is already human-writeable, pyproject.toml is not (yet). From setuptools docs, [build-system] requires = [ "setuptools >= 40.9.0", "wheel", ] build-backend = "setuptools.build_meta" However, this file does not include package dependencies (as it should not in PEP518 which only deals with build dependencies

How can I make pip install package data (a config file)?

南楼画角 提交于 2021-01-01 04:47:24
问题 I have a package called clana (Github, PyPI) with the following structure: . ├── clana │ ├── cli.py │ ├── config.yaml │ ├── __init__.py │ ├── utils.py │ └── visualize_predictions.py ├── docs/ ├── setup.cfg ├── setup.py ├── tests/ └── tox.ini The setup.py looks like this: from setuptools import find_packages from setuptools import setup requires_tests = [...] install_requires = [...] config = { "name": "clana", "version": "0.3.6", "author": "Martin Thoma", "author_email": "info@martin-thoma.de

How can I make pip install package data (a config file)?

最后都变了- 提交于 2021-01-01 04:47:05
问题 I have a package called clana (Github, PyPI) with the following structure: . ├── clana │ ├── cli.py │ ├── config.yaml │ ├── __init__.py │ ├── utils.py │ └── visualize_predictions.py ├── docs/ ├── setup.cfg ├── setup.py ├── tests/ └── tox.ini The setup.py looks like this: from setuptools import find_packages from setuptools import setup requires_tests = [...] install_requires = [...] config = { "name": "clana", "version": "0.3.6", "author": "Martin Thoma", "author_email": "info@martin-thoma.de

Automating Python package release process

女生的网名这么多〃 提交于 2020-12-27 08:58:07
问题 I've just started an open source Python project that I hope might be popular one day. At the moment to release a new version I have to do a few things. Test all the things. Edit mypackage.VERSION variable, which setup.py imports from __init__ Build packages and wheels with python setup.py sdist bdist_wheel Write a changelog entry to CHANGELOG file Commit my changes, echo some of that changelog Tag that commit as a release, copy that changelog entry over again. Drag in my built files so people

Problems with entrypoints (from other packages) when installing package through pip

两盒软妹~` 提交于 2020-12-15 07:13:48
问题 Trying to install a package, for example, pytorch pip install torch / pip install -U torch And I'm greeted with this Collecting torch Using cached torch-0.1.2.post2.tar.gz (128 kB) ERROR: Command errored out with exit status 1: command: 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aissy\\AppData\\Local\\Temp\\pip-install-35x5kco9\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\aissy\\AppData\

Python imports when scripts are run from different folder (ancestor)

断了今生、忘了曾经 提交于 2020-06-28 04:56:32
问题 I have a large repository with some fixed structure and I have extended it by some folders and python scripts to add extra functionality to it as a whole. The structure looks as follows: toplevelfolder featureA someModuleA.py __ init __.py featureB someModuleB.py __ init __.py application __ init __.py app.py Now someModuleA.py and someModuleB.py can be invoked via app.py but at the same time also have be able to be invoked directly, however this invocation must come from the toplevelfolder