0

Hi guys i have a problem with creating python package out of my project. I read some tutorials but every one leads to uploading files to pypi which i dont want to do. I just want to pip install it to my machine locally using tar.gz file. Here's a structure of my project folder:

root
├── src
│   ├── __init__.py
│   ├── config.py
│   └── sth_a
│   │   ├── __init__.py
│   │   └── a.py
│   └── sth_b
│       ├── __init__.py
│       └── b.py
└── setup.py

Here is how my setup.py file looks like:

from setuptools import setup, find_packages

setup(name="mypkg",
      version='0.0.1',
      author="whatever",
      packages=find_packages()
      )

First i run command:

python setup.py sdist bdist_wheel

then it creatates dist dictionary with tar.gz file and wheel file, so i just run

pip3 install dist/mypkg-0.0.1.tar.gz 

After this first problem emerges. To import these files somewhere else i need to write

from src.sth_a.a import *

but i want to do this like this

from mypgk.src.sth_a.a import *

or even if i just want to 'publish' for example functions from file a.py

from mypck.a import *

Also i was having another issues bit this answer helped me a bit but it is not still what i want pip install . creates only the dist-info not the package

F.Hand
  • 73
  • 1
  • 2
  • 13
  • The simple solution is to actually add this `mypkg` top-level package and move `src` into it. Otherwise you would need to do some tricks with `package_dir`. I wrote about it already, maybe in [one of those](https://stackoverflow.com/search?q=user%3A11138259+package_dir). – sinoroc Jun 03 '21 at 20:17
  • Your title asks one question ('how to build/use a package without using pypi'), but your explanation asks a different question ('how to build a package named 'mypkg' with src under a 'src' dir'). – pjz Jun 03 '21 at 20:50

0 Answers0