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

Multiple packages in the same project #161

Closed
tlecarrour opened this issue May 30, 2018 · 11 comments
Closed

Multiple packages in the same project #161

tlecarrour opened this issue May 30, 2018 · 11 comments

Comments

@tlecarrour
Copy link

I'm migrating a project from setuptools to Poetry. The project contains 2 packages, and my setuptools setup was packaging them together. This doesn't seem to work with my Poetry setup!? But maybe it's because the only place I mentioned my second package is in the [package] include section.

Is it possible to do it with Poetry or is it considered as a bad practice ?!

@sdispater
Copy link
Member

I am not sure I understand. What do you mean? Also what does your pyproject.toml look like?

@tlecarrour
Copy link
Author

My apologies, I should have included both my setup.py and my pyproject.toml!

The setup.py I was using before migrating to Poetry looks like this:

from setuptools import setup, find_packages

setup(
    name='multiple_packages',
    version='0.1.0',
    description='',
    author='TLC',
    author_email='[email protected]',
    packages=find_packages()
)

My project folder layout is:

─ multiple_packages
   ├── setup.py
   ├── multiple_packages
   │   └── __init__.py
   └── second_package
       └── __init__.py

Using python setup.py sdist, I build a tar file that contains:

multiple_packages-0.1.0/
multiple_packages-0.1.0/second_package/
multiple_packages-0.1.0/second_package/__init__.py
multiple_packages-0.1.0/multiple_packages/
multiple_packages-0.1.0/multiple_packages/__init__.py

When I realized that the features I was missing was packages=find_packages(), I searched again it the issues and found #56 and #92. So I tried the "src layout", but I couldn't get the second_package to be included in the tar, even with the following pyproject.toml:

[tool.poetry]
name = "multiple_packages"
version = "0.1.0"
description = ""
authors = ["TLC <[email protected]>"]

[package]
include = ["src/second_package/*.py"]

And my layout is now:

 ─multiple_packages
   ├── pyproject.toml
   └── src
     ├── multiple_packages
     │   └── __init__.py
     └── second_package
          └── __init__.py

The tar file generated by poetry build (I use Poetry 0.9.1) contains:

multiple_packages-0.1.0/pyproject.toml
multiple_packages-0.1.0/src/multiple_packages/__init__.py
multiple_packages-0.1.0/setup.py

I must be doing something wrong. Either with my pyproject.toml or trying to distribute both packages at the same time. Anyway, thanks for your time!

@sdispater
Copy link
Member

Unless I am missing something, shouldn't your layout be:

─ setup.py
─ multiple_packages
   ├── __init__.py
   ├── multiple_packages
   │   └── __init__.py
   └── second_package
       └── __init__.py

and with poetry:

─ pyproject.toml
─ multiple_packages
   ├── __init__.py
   ├── multiple_packages
   │   └── __init__.py
   └── second_package
       └── __init__.py

@merwok
Copy link

merwok commented May 31, 2018

I think the OP really means two independent packages, not one package with sub-packages.

Distutils always supported to create a distribution with 0 or more modules, 0 or more packages, 0 or more scripts, or even only data files.

@tlecarrour
Copy link
Author

As @merwok said, I meant 2 independent packages, not 2 subpackages in a multiple_packages package.

I don't know if it's something that should be doable and if this issue is still relevant. In the mean time I moved the second_package to a different project, that's solved the problem for me. But now I want to publish it on a private repo and I'm getting a error on poetry update after adding [[tool.poetry.source]] in my pyproject.toml. … but that's a different problem and I'll first investigate by myself (and read the doc ^_^') before submitting a new issue.

Feel free to close this issue and thanks again for your time!

@sdispater
Copy link
Member

It is now supported with the packages property

@tlecarrour
Copy link
Author

Thanks !!! :-)

@aantn
Copy link

aantn commented Jul 6, 2021

Just to be clear, this refers to import packages not distribution packages, right? (Using the terminology from here: https://sinoroc.gitlab.io/kb/python/packaging.html)

@merwok
Copy link

merwok commented Jul 6, 2021

From the first messages, yes. A Python project can contain multiple modules, packages, scripts and data files.

@RoelantStegmann
Copy link

Just to be clear, this refers to import packages not distribution packages, right? (Using the terminology from here: https://sinoroc.gitlab.io/kb/python/packaging.html)

Wondering this too. Otherwise how could I separate the dependencies of the individual distribution packages?

For now I make a different poetry project for each, but there is quite some boiler plate double (ci/cd pipelines, etc)

Copy link

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants