Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package_dir option to setup.py #521

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slitayem
Copy link

@slitayem slitayem commented Nov 2, 2017

No description provided.

@slitayem slitayem force-pushed the master branch 3 times, most recently from 8bbb32a to 3c2ea92 Compare November 2, 2017 16:28
@AlexeySanko
Copy link
Contributor

Hi, @slitayem
Prefered way to pass arguments to setup function is distutils_... properties, like distutils_setup_keywords, distutils_entry_points or distutils_console_scripts.
Thanks

@AlexeySanko
Copy link
Contributor

I saw a lot of requests for more dynamic setup.py file. What do You think about changing this PR with adding dict property distutils_setup_args which will prodive values directly to setup.py?
And key package_dir with specific value will cover original problem.
Your thoughts?

@arcivanov
Copy link
Member

@slitayem I'm sorry, I don't understand the purpose of this. Could you please be a little more verbose about why you want this?

package_dir is used for custom layout of the sources. In PyB you can customize the location of your sources in the tree (defaulting to src/main/python), but in package they'll always be on top even if you customize your layout.

Additionally, in setuptools, find_packages can be used: https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages

What are you trying to achieve and what isn't working for you?

@jtsec92
Copy link

jtsec92 commented Jan 4, 2024

Hi, @arcivanov

I understand that in PyB you can customize the location of your sources in the tree (defaulting to src/main/python), but in package they'll always be on top even if you customize your layout.

Is there a simple way to customize the locations of the sources so that they are not always on the top?

Thanks,
J

@arcivanov
Copy link
Member

@jtsec92 what do you mean "they are not always on top"?
Could you provide a simple example of what your source tree looks like and what you want to see in the package?

@arcivanov
Copy link
Member

Hi, @arcivanov

I understand that in PyB you can customize the location of your sources in the tree (defaulting to src/main/python), but in package they'll always be on top even if you customize your layout.

Is there a simple way to customize the locations of the sources so that they are not always on the top?

Thanks, J

└── src
    ├── __init__.py
    └── main
        ├── python
        │   └── main.py
        └── scripts
            └── test2.sh

You need to move the __init__.py into src/main/python and your main will be where you want it to be. Otherwise the contents of the src/main/python appears as an implicit namespace of "" which you can't have per spec.

@jtsec92
Copy link

jtsec92 commented Jan 4, 2024

Thank you,

so should it be:

├── __pycache__
│   └── build.cpython-38.pyc
├── build.py
├── pyproject.toml
├── setup.py
└── src
    └── main
        ├── python
        │   ├── __init__.py
        │   └── main.py
        └── scripts
            └── test2.sh
Screen Shot 2024-01-04 at 5 34 52 PM

@jtsec92
Copy link

jtsec92 commented Jan 4, 2024

Unfortunately, after running pyb it still ends up at the project root level. I feel like I am missing something obvious.

Screen Shot 2024-01-04 at 5 53 01 PM

@arcivanov
Copy link
Member

Unfortunately, after running pyb it still ends up at the project root level. I feel like I am missing something obvious.

What is your desired layout IN THE WHEEL package?
I'm confused as to what you're trying to accomplish. Your main.py is at the root of the project, as you specified (src/main/python is the root in your case, so it translates to the root of your dist scratch build).

Your main.py is the root package. It is correctly located as a root package. Where do you think it should be and why does it matter?

@arcivanov
Copy link
Member

PS: As a second thought, you don't need the __init__.py at all. You can delete it.

@jtsec92
Copy link

jtsec92 commented Jan 4, 2024

I am trying to make the source and target package structure mirror each other. I want the target dist to look like this:

Screen Shot 2024-01-04 at 6 47 00 PM

Where main.py is in src/main/python instead of at the project root level.

@jtsec92
Copy link

jtsec92 commented Jan 4, 2024

PS: As a second thought, you don't need the __init__.py at all. You can delete it.

Thank you

@arcivanov
Copy link
Member

If your target package looks like src/main/python/main.py you will end up having to do import src.python.main.main.
src/main/python is the ROOT of the sources of the packages.

If you REALLY want to do what you're saying just create src/main/python/src/main/python and move your main.py there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants