Skip to content

Commit

Permalink
Merge pull request #25 from pypa/chrysle/src-layout
Browse files Browse the repository at this point in the history
Migrate examples to `src-layout`
  • Loading branch information
chrysle committed Apr 19, 2024
2 parents d6a93a1 + 8bfa373 commit 4f1c4b1
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 189 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/**/setup.py merge=ours
**/**/pyproject.toml merge=ours
table.md merge=ours
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ However, developers might be interested in carrying out a *staggered migration*
to mitigate the migration effort and spread the work load in time.

Based on the results for the scenarios mixing `pkg_resources` and other namespace methods reported in
[table.md](table.md) and [legacy_table.md](legacy_table.md),
we can see that (in principle) a staggered migration plan can be successful,
[table.md](table.md) and [legacy_table.md](https://github.com/pypa/sample-namespace-packages/blob/master/legacy_table.md)
(only available for flat layout), we can see that (in principle) a staggered migration plan can be successful,
as long as the developers are willing to accept some limitations:

- Deprecated installation methods will not be supported (e.g. `python setup.py install`),
Expand All @@ -57,4 +57,4 @@ specific use cases they are interested in supporting.


[^1]: If you would like to know about deprecated installation methods (e.g. via
`python setup.py install`) or Python 2.7, please have a look at [legacy_table.md](legacy_table.md).
`python setup.py install`) or Python 2.7 for the flat layout, please have a look at [legacy_table.md](https://github.com/pypa/sample-namespace-packages/blob/master/legacy_table.md).
162 changes: 0 additions & 162 deletions legacy_table.md

This file was deleted.

5 changes: 3 additions & 2 deletions native/pkg_a/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
author_email='jonwayne@google.com',

license='Apache Software License',

packages=['example_pkg.a'],
# This example uses automatic discovery. You can also implement custom discovery like this:
# packages=find_namespace_packages(where='src', include=['example_pkg.a']),
# package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
5 changes: 3 additions & 2 deletions native/pkg_b/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
author_email='jonwayne@google.com',

license='Apache Software License',

packages=['example_pkg.b'],
# This example uses automatic discovery. You can also implement custom discovery like this:
# packages=find_namespace_packages(where='src', include=['example_pkg.b']),
# package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
10 changes: 6 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@
USE_PYTHON_VERSIONS = USE_PYTHON_VERSIONS_DEFAULT


install_commands = (("pip", "install", "."), ("pip", "install", "-e", "."))

install_commands = (
('pip', 'install', '.'),
('pip', 'install', '-e', '.')
)

def install_packages(session, package_a, package_b, command_a, command_b):
env = {**os.environ, "PIP_CONSTRAINT": f"{HERE}/constraints.txt"}
session.install("--upgrade", "pip", env=env)
session.chdir(package_a)
session.run("rm", "-rf", "dist", "build", "*.egg-info")
session.run("rm", "-rf", "dist", "build", "*.egg-info", external=True)
session.run(*command_a, env=env)
session.chdir(HERE)
session.chdir(package_b)
session.run("rm", "-rf", "dist", "build", "*.egg-info")
session.run("rm", "-rf", "dist", "build", "*.egg-info", external=True)
session.run(*command_b, env=env)
session.chdir(HERE)

Expand Down
3 changes: 2 additions & 1 deletion pkg_resources/pkg_a/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

license='Apache Software License',

packages=find_packages(),
packages=find_packages(where='src'),
namespace_packages=['example_pkg'],
package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
3 changes: 2 additions & 1 deletion pkg_resources/pkg_b/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

license='Apache Software License',

packages=find_packages(),
packages=find_packages(where='src'),
namespace_packages=['example_pkg'],
package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
3 changes: 2 additions & 1 deletion pkgutil/pkg_a/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

license='Apache Software License',

packages=find_packages(),
packages=find_packages(where='src'),
package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion pkgutil/pkg_b/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

license='Apache Software License',

packages=find_packages(),
packages=find_packages(where='src'),
package_dir={'': 'src'},
zip_safe=False,
)
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -- PYTHON PACKAGE REQUIREMENTS:
# USE: pip install -r <THIS_FILE>

setuptools >= 68.2.2
nox >= 2023.04.22
Loading

0 comments on commit 4f1c4b1

Please sign in to comment.