0

Structure of code:

setup.cfg

pyproject.toml

project (a directory)

project directory:

a.py
b.py
c.py
__init__.py

for example, in a.py there is a line:

import b

When building the package:

pip install .

after that typing in ubuntu's terminal:

python

Python 3.6.9 (default, Dec  8 2021, 21:08:43)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import project
>>> dir(project)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> from project import a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...(cant show this)/project/a.py", line 1, in <module>
    import b
ModuleNotFoundError: No module named 'b'

setup config file:

[metadata]
name = project
version = 0.0.1
author = *****
author_email = *****
description = **********
long_description = file: README.md
long_description_content_type = text/markdown
url = **************************
classifiers =
    Programming Language :: Python :: 3
    Operating System :: OS Independent

[options]
python_requires = >=3.6
include_package_data = True
py_modules = project
package_dir =
        =project
packages = find:
install_requires =
    numpy
    pyproj
    requests
    scipy
    requests
    importlib

[options.packages.find]
where = project

My pyproject.toml file:

[build-system]
requires = [
    "setuptools>=42",
    "wheel"
]
build-backend = "setuptools.build_meta"

0 Answers0