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

Migrate examples to src-layout #25

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)
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,
)
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,
)
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,
)
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,
)
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,
)
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
Loading