Skip to content
New issue

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

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

Already on GitHub? # to your account

How to generate this setup.py for a namespace subpackage? #356

Closed
2 tasks done
moigagoo opened this issue Jul 29, 2018 · 11 comments
Closed
2 tasks done

How to generate this setup.py for a namespace subpackage? #356

moigagoo opened this issue Jul 29, 2018 · 11 comments

Comments

@moigagoo
Copy link
Contributor

moigagoo commented Jul 29, 2018

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

Hi!

I'm moving all my projects to Poetry and have issues with some of them. Namely, it's packages that are subpackages to a bigger project.

Here is one example: https://github.com/foliant-docs/foliantcontrib.bump. It's an extension for https://github.com/foliant-docs/foliant.

It means that during installation, the file foliant/cli/bump.py should be placed in foliant/cli folder in Foliant installation. To accomplish this, I'm using namespace package in setup.py.

I haven't found a way to achieve the same thing with Poetry. Tried using packages in pyproject.toml, but that gives me a package name cli, not foliant.cli.

@nicktimko
Copy link

I think this sounds related: #167

@RaptDept
Copy link
Contributor

RaptDept commented Aug 3, 2018

Your pyproject.toml link leads to a 404. How did you use packages?

I've been able to use namespace packages in Poetry just fine, but my use case is slightly different. I don't have projects that share innermost (leaf) packages, so I'm not sure if this will work for you.

I have two projects, foo-project and bar-project:

foo-project
├── pyproject.toml
└── root_namespace
    └── nested_namespace
        └── subpackage_a
        │   └── __init__.py
        └── subpackage_b
            └── __init__.py
bar-project
├── pyproject.toml
└── root_namespace
    └── nested_namespace
        └── subpackage_c
            └── __init__.py

This is how I use packages in each pyproject.toml:

[tool.poetry]
...
packages = [{ include = "root_namespace" }]
...

This picks up root_namespace and the subpackages in the generated setup.py.

foo-project/setup.py:

packages = \
['root_namespace',
 'root_namespace.nested_namespace.subpackage_a',
 'root_namespace.nested_namespace.subpackage_b']

bar-project/setup.py:

packages = \
['root_namespace',
 'root_namespace.nested_namespace.subpackage_c']

Installing both places the files in the correct directories.

@moigagoo
Copy link
Contributor Author

moigagoo commented Aug 3, 2018

Sorry, I've updated the link.

Thanks for the code sample, I'll try to do something similar and report the result.

@RaptDept
Copy link
Contributor

RaptDept commented Aug 4, 2018

[{ include="foliant.cli" }]might be what you want. I think the from field is for specifying the parent directory of your package tree (e.g. src if the foliant directory is in src)

@moigagoo
Copy link
Contributor Author

moigagoo commented Aug 5, 2018

@RaptDept [{ include="foliant.cli" }] doesn't work because Poetry tries to look for foliant.cli folder, which is not there:

[ValueError]
C:\Users\moigagoo\Projects\foliantcontrib.bump\foliant.cli does not contain any element

[{ include="foliant" }] only adds foliant as a package. But if I put an empty __init__.py file in foliant/cli, both foliant and foliant.cli are detected. Even though I'd rather have only foliant.cli added to packages in setup.py and not add and empty __init__.py, it seems to work. Thanks!

@moigagoo moigagoo closed this as completed Aug 5, 2018
@moigagoo
Copy link
Contributor Author

moigagoo commented Aug 6, 2018

It turns out, putting __init__.py is a bad solution. It overwrites the __init__.py that's already there in the parent package during installation, which breaks stuff.

@moigagoo moigagoo reopened this Aug 6, 2018
@dfee
Copy link

dfee commented Aug 8, 2018

See my solution here: #167 (comment)

@moigagoo
Copy link
Contributor Author

moigagoo commented Aug 9, 2018

@dfee it's 404 unfortunately.

@dfee
Copy link

dfee commented Aug 9, 2018

@moigagoo Updated the link, glad you'd already found it.

@dfee
Copy link

dfee commented Aug 9, 2018

@moigagoo I'm not understanding how your project doesn't follow the PEP420 guidelines. Is it because you don't have and __init__.py https://github.com/foliant-docs/foliantcontrib.bump/tree/develop/foliant/cli

@tmirzoev tmirzoev mentioned this issue Nov 23, 2018
2 tasks
rkhwaja added a commit to rkhwaja/fs.googledrivefs that referenced this issue Dec 31, 2019
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants