2

I already had a look at the following question but I was not able to understand which is the solution...

I'm trying to write a setup.py file to build my code.

Here is the directory structure of the project:

project
|
├── setup.py
|
├── MANIFEST.in
|
├── package1
    ├── __init__.py
    ├── data.py
    |__ file.yml
    └── util_folder
├── package2
    ├── __init__.py
    ├── tool.py
    └── utils.py  
|___ script1.py
|___ script2.py

Here the main content of setup.py

setup(
     name = "MyProject",
     packages=['package1','package2'],
     include_package_data=True,
)

Here my MANIFEST.in to also include the util_folder under package1 and the two scripts located at the root folder.

include *.py
recursive-include package1 *

However, after running

python setup.py install

in my conda env, script1.py and script2.py are not copied to the destination, i.e.

path/to/my/conda/env/lib/python3.7/site-packages/MyProject-1.0-py3.7.egg/

Under that location I can see only package1 and package2.

What's wrong?

3
  • You might need either py_modules or scripts, depending on what the intention is. Should script1 and script2 be importable or executable? Commented Nov 20, 2020 at 8:33
  • Both scripts should be imported Commented Nov 29, 2020 at 20:52
  • 1
    Then use py_modules. Also I would not call these files scripts, but modules. Commented Nov 29, 2020 at 21:35

1 Answer 1

2

Looks to me like you should probably do something like:

import setuptools
setuptools.setup(
    # ...
    py_modules=[
        'script1',
        'script2',
    ],
)

Note than in such a case the preferred denomination is module, instead of script. From my point of view scripts are meant to be called and executed directly, and modules are meant to be imported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.