Python package not global accessable

Hi community.

I created a python package in our gitlab repo. (We are using vagrant as virtual machine, just fyi)

The package is called “simulation” and contains a setup.py, simulation.py, init.py and main.py file. In the simulation directory, i call “pip install -e .” which calls the setup.py and installs my package. This should be global accessable now.

To test accessability, i write some output from simulation.py (“init” and “run”).
When I call “python -m simulation” in /vagrant, (where the simulation folder is located next to some other folders), the output is plotted →

init
run

When i call the package in a directory, f.e. /vagrant/tools, then I see no output, but also no error. Thats the problem with this created package. I hope you can give me an advice, would be great.

Thanks and best regards!

setup.py:

import setuptools
from setuptools import setup

setup(name='simulation',
      version='0.0.0',
      description='Simulation environment',
      url='',
      author='',
      author_email='',
      license='',
      packages=setuptools.find_packages(),
      include_package_data=True,
      zip_safe=False)

simulation.py:

import os
from os import remove
from time import sleep

run = True

class Simulation:
    def __init__(self,
                args,
                launch_lat,
                launch_lon,
                launch_alt_asl):
        self.args = args
        self.launch_lat = launch_lat
        self.launch_lon = launch_lon
        self.launch_alt_asl = launch_alt_asl
        print("init")

    def run(self):
        print("hello")

main.py:

from os import path

from simulation import Simulation

args = 0
launch_lat = 0
launch_lon = 0
launch_alt_asl = 0

simulation = Simulation(args,
                        launch_lat,
                        launch_lon,
                        launch_alt_asl)

simulation.run()

init.py:

from .simulation import Simulation

The package is called “simulation” and contains a setup.py, simulation.py, init .py and main .py file.

If you mean that your folder is laid out like this:

simulation/
├── __init__.py
├── __main__.py
├── setup.py
└── simulation.py

then that’s wrong. The actual contents of your package (i.e., not setup.py) need to be in a subdirectory next to setup.py, i.e., it should look like this:

simulation/
├── setup.py
└── simulation/
    ├── __init__.py
    ├── __main__.py
    └── simulation.py

(Even better would be to use a src/ directory, but let’s take things one step at a time.) The way your project is now, it doesn’t constitute an importable package, and so find_packages() returns an empty list and nothing is installed. The only reason python -m simulation works when run from this directory is because there happens to be a simulation.py there.