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

Question & Feature Request: How to build all sub packages? #1

Open
lqhuang opened this issue May 4, 2023 · 3 comments
Open

Question & Feature Request: How to build all sub packages? #1

lqhuang opened this issue May 4, 2023 · 3 comments

Comments

@lqhuang
Copy link

lqhuang commented May 4, 2023

Env setup

pdm-example-monorepo: a6b3f47
pdm: 2.5.3
python: 3.10
OS: macOS 13.3.1

Problem

  1. Fail to setup in project root
$ pdm install

The saved Python interpreter doesn't match the project's requirement. Trying to find another one.
python.use_venv is on, creating a virtualenv for this project...
Virtualenv is created successfully at /Users/lqhuang/Src/pdm-example-monorepo/.venv
See /var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-install-resolve-42si7wtx.log for detailed debug log.
[ResolutionImpossible]: [RequirementInformation(requirement=FileRequirement(name='pkg-core', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=True,
prerelease=False, url='file:///${PROJECT_ROOT}/packages/pkg-core', path=PosixPath('packages/pkg-core'), subdirectory=None), parent=None),
RequirementInformation(requirement=FileRequirement(name='pkg-core', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=False,
url='file:///Users/fming/wkspace/github/pdm-example-monorepo/packages/pkg-first/../pkg-core',
path=PosixPath('/Users/fming/wkspace/github/pdm-example-monorepo/packages/pkg-first/../pkg-core'), subdirectory=None), parent=<Candidate
pkg-first@file:///Users/lqhuang/Src/pdm-example-monorepo/packages/pkg-first>)]
Add '-v' to see the detailed traceback
  1. No alias to build specific sub packages or all defined sub-packages ?
$ pdm build pkg-core
Usage: pdm [-h] [-V] [-c CONFIG] [-v] [-I] [--pep582 [SHELL]]
           {add,build,cache,completion,config,export,fix,import,info,init,install,list,lock,publish,remove,run,search,self,plugin,show,sync,update,use,venv} ...
pdm: error: unrecognized arguments: pkg-core 

If run pdm build directly under root project, pdm will info us current pyproject.toml is broken or missing essential metadata.

$ pdm build
Building sdist...
See /var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-build-pfyzz2v9.log for detailed debug log.
[BuildError]: Build backend raised error: Showing the last 10 lines of the build output:
  File "/var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-build-env-uyzzgc4z-shared/lib/python3.10/site-packages/setuptools/dist.py", line 908, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-build-env-uyzzgc4z-shared/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 66, in
apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
  File "/var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-build-env-uyzzgc4z-shared/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 129, in
read_configuration
    validate(subset, filepath)
  File "/var/folders/9n/q2xsxp9x1l79r6rvgl_9h4sw0000gn/T/pdm-build-env-uyzzgc4z-shared/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 55, in
validate
    raise ValueError(f"{error}\n{summary}") from None
ValueError: invalid pyproject.toml config: `project`.
configuration error: `project` must contain ['name'] properties
Add '-v' to see the detailed traceback

Building packages by -p path option works well.

$ pdm build -p ./packages/pkg-core
Building sdist...
Built sdist at /Users/lqhuang/Src/pdm-example-monorepo/packages/pkg-core/dist/pkg_core-0.1.0.tar.gz
Building wheel...
Built wheel at /Users/lqhuang/Src/pdm-example-monorepo/packages/pkg-core/dist/pkg_core-0.1.0-py3-none-any.whl

What I expect?

  1. Could we add an option like --all to easily build all sub packages?
  2. (Optional) Using project alias or name (pdm build -n pkg-core) instead of path (-p) to build sub packages

Thanks for your efforts!

Best wishes,
Lanqing

@frostming
Copy link
Contributor

Yes, this requires the interface change which is planned in pdm-project/pdm#1505.

We have to use what we have now.

@sinogermany
Copy link

@lqhuang you can do something like this:

ls packages | xargs -I % sh -c "pdm build -p packages/%"

or taking one step further, create a pdm.sh:

ls packages | xargs -I % sh -c "pdm ${@} -p packages/%"

@lqhuang
Copy link
Author

lqhuang commented Apr 18, 2024

@sinogermany Oh, thanks! That's a good idea and could be wrapped as an alias or shell function 😂

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

No branches or pull requests

3 participants