Browse Source

fix setup.py rendered code for readme file

shut-new-model
Niklas Rosenstein 9 months ago
parent
commit
32ea91bf42
No known key found for this signature in database GPG Key ID: 6D269B33D25F6C6
2 changed files with 7 additions and 4 deletions
  1. + 3
    - 3
      src/shut/commands/pkg/update.py
  2. + 4
    - 1
      src/shut/update/setuptools.py

+ 3
- 3
src/shut/commands/pkg/update.py

@ -23,18 +23,18 @@ import click
from shut.commands import project
from shut.commands.commons.new import write_files
from shut.commands.pkg import pkg
from shut.model import PackageModel
from shut.update import get_files
from . import pkg
@pkg.command()
@click.option('--dry', is_flag=True)
def update(dry):
"""
Update package files generated from the Package configuration.
Update files auto-generated from the configuration file.
"""
package = project.load(expect=PackageModel)
package = project.load_or_exit(expect=PackageModel)
files = get_files(package)
write_files(files, package.get_directory(), force=True, dry=dry)

+ 4
- 1
src/shut/update/setuptools.py

@ -264,6 +264,9 @@ class SetuptoolsRenderer(Renderer[PackageModel]):
@staticmethod
def _format_reqs(reqs: List[Requirement], level: int = 0) -> List[str]:
indent = ' ' * (level + 1)
reqs = [x for x in reqs if x.package != 'python']
if not reqs:
return '[]'
return '[\n' + ''.join(indent + '{!r},\n'.format(x.to_setuptools()) for x in reqs if x.package != 'python') + ']'
def _render_requirements(self, fp: TextIO, target: str, requirements: List[Requirement]):
@ -293,7 +296,7 @@ class SetuptoolsRenderer(Renderer[PackageModel]):
# If the readme file is _not_ inside the package directory, the setup.py will
# temporarily copy it. The filename at setup time is thus just the readme's
# base filename.
is_inside = nr.fs.issub(os.path.relpath(readme, package.get_directory()))
is_inside = nr.fs.issub(readme)
if is_inside:
readme_relative_path = readme
else:

Loading…
Cancel
Save